169 |
|
Iterator i = s.iterator(); |
170 |
|
Integer last = (Integer)i.next(); |
171 |
|
assertEquals(last, one); |
172 |
+ |
int count = 1; |
173 |
|
while (i.hasNext()) { |
174 |
|
Integer k = (Integer)i.next(); |
175 |
|
assertTrue(last.compareTo(k) < 0); |
176 |
|
last = k; |
177 |
+ |
++count; |
178 |
|
} |
179 |
+ |
assertEquals(count ,5); |
180 |
+ |
} |
181 |
+ |
|
182 |
+ |
/** |
183 |
+ |
* descending iterator of key set is inverse ordered |
184 |
+ |
*/ |
185 |
+ |
public void testKeySetDescendingIteratorOrder() { |
186 |
+ |
ConcurrentSkipListMap map = map5(); |
187 |
+ |
NavigableSet s = map.navigableKeySet(); |
188 |
+ |
Iterator i = s.descendingIterator(); |
189 |
+ |
Integer last = (Integer)i.next(); |
190 |
+ |
assertEquals(last, five); |
191 |
+ |
int count = 1; |
192 |
+ |
while (i.hasNext()) { |
193 |
+ |
Integer k = (Integer)i.next(); |
194 |
+ |
assertTrue(last.compareTo(k) > 0); |
195 |
+ |
last = k; |
196 |
+ |
++count; |
197 |
+ |
} |
198 |
+ |
assertEquals(count ,5); |
199 |
|
} |
200 |
|
|
201 |
|
/** |
207 |
|
Iterator i = s.iterator(); |
208 |
|
Integer last = (Integer)i.next(); |
209 |
|
assertEquals(last, five); |
210 |
+ |
int count = 1; |
211 |
|
while (i.hasNext()) { |
212 |
|
Integer k = (Integer)i.next(); |
213 |
|
assertTrue(last.compareTo(k) > 0); |
214 |
|
last = k; |
215 |
+ |
++count; |
216 |
|
} |
217 |
+ |
assertEquals(count, 5); |
218 |
|
} |
219 |
|
|
220 |
+ |
/** |
221 |
+ |
* descending iterator of descendingKeySet is ordered |
222 |
+ |
*/ |
223 |
+ |
public void testDescendingKeySetDescendingIteratorOrder() { |
224 |
+ |
ConcurrentSkipListMap map = map5(); |
225 |
+ |
NavigableSet s = map.descendingKeySet(); |
226 |
+ |
Iterator i = s.descendingIterator(); |
227 |
+ |
Integer last = (Integer)i.next(); |
228 |
+ |
assertEquals(last, one); |
229 |
+ |
int count = 1; |
230 |
+ |
while (i.hasNext()) { |
231 |
+ |
Integer k = (Integer)i.next(); |
232 |
+ |
assertTrue(last.compareTo(k) < 0); |
233 |
+ |
last = k; |
234 |
+ |
++count; |
235 |
+ |
} |
236 |
+ |
assertEquals(count, 5); |
237 |
+ |
} |
238 |
|
|
239 |
|
/** |
240 |
|
* Values.toArray contains all values |
841 |
|
*/ |
842 |
|
public void testSubMapContents() { |
843 |
|
ConcurrentSkipListMap map = map5(); |
844 |
< |
NavigableMap sm = map.navigableSubMap(two, true, four, false); |
844 |
> |
NavigableMap sm = map.subMap(two, true, four, false); |
845 |
|
assertEquals(two, sm.firstKey()); |
846 |
|
assertEquals(three, sm.lastKey()); |
847 |
|
assertEquals(2, sm.size()); |
879 |
|
|
880 |
|
public void testSubMapContents2() { |
881 |
|
ConcurrentSkipListMap map = map5(); |
882 |
< |
NavigableMap sm = map.navigableSubMap(two, true, three, false); |
882 |
> |
NavigableMap sm = map.subMap(two, true, three, false); |
883 |
|
assertEquals(1, sm.size()); |
884 |
|
assertEquals(two, sm.firstKey()); |
885 |
|
assertEquals(two, sm.lastKey()); |
914 |
|
*/ |
915 |
|
public void testHeadMapContents() { |
916 |
|
ConcurrentSkipListMap map = map5(); |
917 |
< |
NavigableMap sm = map.navigableHeadMap(four, false); |
917 |
> |
NavigableMap sm = map.headMap(four, false); |
918 |
|
assertTrue(sm.containsKey(one)); |
919 |
|
assertTrue(sm.containsKey(two)); |
920 |
|
assertTrue(sm.containsKey(three)); |
940 |
|
*/ |
941 |
|
public void testTailMapContents() { |
942 |
|
ConcurrentSkipListMap map = map5(); |
943 |
< |
NavigableMap sm = map.navigableTailMap(two, true); |
943 |
> |
NavigableMap sm = map.tailMap(two, true); |
944 |
|
assertFalse(sm.containsKey(one)); |
945 |
|
assertTrue(sm.containsKey(two)); |
946 |
|
assertTrue(sm.containsKey(three)); |
984 |
|
assertEquals("E", e.getValue()); |
985 |
|
assertFalse(i.hasNext()); |
986 |
|
|
987 |
< |
NavigableMap ssm = sm.navigableTailMap(four, true); |
987 |
> |
NavigableMap ssm = sm.tailMap(four, true); |
988 |
|
assertEquals(four, ssm.firstKey()); |
989 |
|
assertEquals(five, ssm.lastKey()); |
990 |
|
assertTrue(ssm.remove(four) != null); |
1013 |
|
check(map, 0, mapSize - 1, true); |
1014 |
|
check(map.descendingMap(), 0, mapSize - 1, false); |
1015 |
|
|
1016 |
< |
bashSubMap(map.navigableSubMap(0, true, mapSize, false), |
1016 |
> |
bashSubMap(map.subMap(0, true, mapSize, false), |
1017 |
|
0, mapSize - 1, true); |
1018 |
|
} |
1019 |
|
|
1120 |
|
|
1121 |
|
// headMap - pick direction and endpoint inclusion randomly |
1122 |
|
boolean incl = rnd.nextBoolean(); |
1123 |
< |
NavigableMap<Integer,Integer> hm = map.navigableHeadMap(midPoint, incl); |
1123 |
> |
NavigableMap<Integer,Integer> hm = map.headMap(midPoint, incl); |
1124 |
|
if (ascending) { |
1125 |
|
if (rnd.nextBoolean()) |
1126 |
|
bashSubMap(hm, min, midPoint - (incl ? 0 : 1), true); |
1137 |
|
|
1138 |
|
// tailMap - pick direction and endpoint inclusion randomly |
1139 |
|
incl = rnd.nextBoolean(); |
1140 |
< |
NavigableMap<Integer,Integer> tm = map.navigableTailMap(midPoint,incl); |
1140 |
> |
NavigableMap<Integer,Integer> tm = map.tailMap(midPoint,incl); |
1141 |
|
if (ascending) { |
1142 |
|
if (rnd.nextBoolean()) |
1143 |
|
bashSubMap(tm, midPoint + (incl ? 0 : 1), max, true); |
1162 |
|
boolean lowIncl = rnd.nextBoolean(); |
1163 |
|
boolean highIncl = rnd.nextBoolean(); |
1164 |
|
if (ascending) { |
1165 |
< |
NavigableMap<Integer,Integer> sm = map.navigableSubMap( |
1165 |
> |
NavigableMap<Integer,Integer> sm = map.subMap( |
1166 |
|
endpoints[0], lowIncl, endpoints[1], highIncl); |
1167 |
|
if (rnd.nextBoolean()) |
1168 |
|
bashSubMap(sm, endpoints[0] + (lowIncl ? 0 : 1), |
1171 |
|
bashSubMap(sm.descendingMap(), endpoints[0] + (lowIncl ? 0 : 1), |
1172 |
|
endpoints[1] - (highIncl ? 0 : 1), false); |
1173 |
|
} else { |
1174 |
< |
NavigableMap<Integer,Integer> sm = map.navigableSubMap( |
1174 |
> |
NavigableMap<Integer,Integer> sm = map.subMap( |
1175 |
|
endpoints[1], highIncl, endpoints[0], lowIncl); |
1176 |
|
if (rnd.nextBoolean()) |
1177 |
|
bashSubMap(sm, endpoints[0] + (lowIncl ? 0 : 1), |