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 |
|
/** |