1+ import java .util .concurrent .ConcurrentSkipListMap ;
2+ import java .util .Comparator ;
3+ public class constructConcurrentSkipListMap2 {
4+ int no ;
5+ String name ;
6+ int value ;
7+ public constructConcurrentSkipListMap2 (int no , String name , int value ) {
8+ this .no = no ;
9+ this .name = name ;
10+ this .value = value ;
11+ }
12+ public String toString () {
13+ return "no:" + no + ", name:" + name + ", value:" + value ;
14+ }
15+
16+ }
17+
18+ class Temp1 implements Comparator <constructConcurrentSkipListMap2 >{
19+ @ Override
20+ public int compare (constructConcurrentSkipListMap2 o1 , constructConcurrentSkipListMap2 o2 ) {
21+ return o1 .no - o2 .no ;
22+ }
23+ }
24+
25+
26+ class Main {
27+ public static void main (String [] args ) {
28+ // ConcurrentSkipListMap(Comparator<? super K> comparator)
29+ ConcurrentSkipListMap <constructConcurrentSkipListMap2 , String > map = new ConcurrentSkipListMap <>(new Temp1 ());
30+ map .put (new constructConcurrentSkipListMap2 (1 , "a" , 100 ), "one" );
31+ map .put (new constructConcurrentSkipListMap2 (2 , "b" , 200 ), "two" );
32+ map .put (new constructConcurrentSkipListMap2 (3 , "c" , 300 ), "three" );
33+ map .put (new constructConcurrentSkipListMap2 (4 , "d" , 400 ), "four" );
34+ map .put (new constructConcurrentSkipListMap2 (5 , "e" , 500 ), "five" );
35+ map .put (new constructConcurrentSkipListMap2 (6 , "f" , 600 ), "six" );
36+ map .put (new constructConcurrentSkipListMap2 (7 , "g" , 700 ), "seven" );
37+ map .put (new constructConcurrentSkipListMap2 (8 , "h" , 800 ), "eight" );
38+ map .put (new constructConcurrentSkipListMap2 (9 , "i" , 900 ), "nine" );
39+ map .put (new constructConcurrentSkipListMap2 (10 , "j" , 1000 ), "ten" );
40+ System .out .println ("Map:" + map );
41+ }
42+ }
0 commit comments