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 |
+ |
TreeMap 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 |
+ |
TreeMap 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 |
|
/** |
636 |
|
*/ |
637 |
|
public void testSubMapContents() { |
638 |
|
TreeMap map = map5(); |
639 |
< |
NavigableMap sm = map.navigableSubMap(two, true, four, false); |
639 |
> |
NavigableMap sm = map.subMap(two, true, four, false); |
640 |
|
assertEquals(two, sm.firstKey()); |
641 |
|
assertEquals(three, sm.lastKey()); |
642 |
|
assertEquals(2, sm.size()); |
674 |
|
|
675 |
|
public void testSubMapContents2() { |
676 |
|
TreeMap map = map5(); |
677 |
< |
NavigableMap sm = map.navigableSubMap(two, true, three, false); |
677 |
> |
NavigableMap sm = map.subMap(two, true, three, false); |
678 |
|
assertEquals(1, sm.size()); |
679 |
|
assertEquals(two, sm.firstKey()); |
680 |
|
assertEquals(two, sm.lastKey()); |
709 |
|
*/ |
710 |
|
public void testHeadMapContents() { |
711 |
|
TreeMap map = map5(); |
712 |
< |
NavigableMap sm = map.navigableHeadMap(four, false); |
712 |
> |
NavigableMap sm = map.headMap(four, false); |
713 |
|
assertTrue(sm.containsKey(one)); |
714 |
|
assertTrue(sm.containsKey(two)); |
715 |
|
assertTrue(sm.containsKey(three)); |
735 |
|
*/ |
736 |
|
public void testTailMapContents() { |
737 |
|
TreeMap map = map5(); |
738 |
< |
NavigableMap sm = map.navigableTailMap(two, true); |
738 |
> |
NavigableMap sm = map.tailMap(two, true); |
739 |
|
assertFalse(sm.containsKey(one)); |
740 |
|
assertTrue(sm.containsKey(two)); |
741 |
|
assertTrue(sm.containsKey(three)); |
779 |
|
assertEquals("E", e.getValue()); |
780 |
|
assertFalse(i.hasNext()); |
781 |
|
|
782 |
< |
NavigableMap ssm = sm.navigableTailMap(four, true); |
782 |
> |
NavigableMap ssm = sm.tailMap(four, true); |
783 |
|
assertEquals(four, ssm.firstKey()); |
784 |
|
assertEquals(five, ssm.lastKey()); |
785 |
|
assertTrue(ssm.remove(four) != null); |
808 |
|
check(map, 0, mapSize - 1, true); |
809 |
|
check(map.descendingMap(), 0, mapSize - 1, false); |
810 |
|
|
811 |
< |
bashSubMap(map.navigableSubMap(0, true, mapSize, false), |
811 |
> |
bashSubMap(map.subMap(0, true, mapSize, false), |
812 |
|
0, mapSize - 1, true); |
813 |
|
} |
814 |
|
|
915 |
|
|
916 |
|
// headMap - pick direction and endpoint inclusion randomly |
917 |
|
boolean incl = rnd.nextBoolean(); |
918 |
< |
NavigableMap<Integer,Integer> hm = map.navigableHeadMap(midPoint, incl); |
918 |
> |
NavigableMap<Integer,Integer> hm = map.headMap(midPoint, incl); |
919 |
|
if (ascending) { |
920 |
|
if (rnd.nextBoolean()) |
921 |
|
bashSubMap(hm, min, midPoint - (incl ? 0 : 1), true); |
932 |
|
|
933 |
|
// tailMap - pick direction and endpoint inclusion randomly |
934 |
|
incl = rnd.nextBoolean(); |
935 |
< |
NavigableMap<Integer,Integer> tm = map.navigableTailMap(midPoint,incl); |
935 |
> |
NavigableMap<Integer,Integer> tm = map.tailMap(midPoint,incl); |
936 |
|
if (ascending) { |
937 |
|
if (rnd.nextBoolean()) |
938 |
|
bashSubMap(tm, midPoint + (incl ? 0 : 1), max, true); |
957 |
|
boolean lowIncl = rnd.nextBoolean(); |
958 |
|
boolean highIncl = rnd.nextBoolean(); |
959 |
|
if (ascending) { |
960 |
< |
NavigableMap<Integer,Integer> sm = map.navigableSubMap( |
960 |
> |
NavigableMap<Integer,Integer> sm = map.subMap( |
961 |
|
endpoints[0], lowIncl, endpoints[1], highIncl); |
962 |
|
if (rnd.nextBoolean()) |
963 |
|
bashSubMap(sm, endpoints[0] + (lowIncl ? 0 : 1), |
966 |
|
bashSubMap(sm.descendingMap(), endpoints[0] + (lowIncl ? 0 : 1), |
967 |
|
endpoints[1] - (highIncl ? 0 : 1), false); |
968 |
|
} else { |
969 |
< |
NavigableMap<Integer,Integer> sm = map.navigableSubMap( |
969 |
> |
NavigableMap<Integer,Integer> sm = map.subMap( |
970 |
|
endpoints[1], highIncl, endpoints[0], lowIncl); |
971 |
|
if (rnd.nextBoolean()) |
972 |
|
bashSubMap(sm, endpoints[0] + (lowIncl ? 0 : 1), |