64 |
|
randomOp(deque); |
65 |
|
|
66 |
|
// Test iterator occasionally |
67 |
< |
if ((i & 1023) == 0) |
67 |
> |
if ((i & 1023) == 0) { |
68 |
|
testIter(deque); |
69 |
+ |
testDescendingIter(deque); |
70 |
+ |
} |
71 |
|
|
72 |
|
// Test serialization and copying |
73 |
|
if ((i & 4095) == 0) { |
99 |
|
throw new Exception("Element "+ j + " != " + (next-1)); |
100 |
|
count++; |
101 |
|
} |
102 |
+ |
if (count != size()) |
103 |
+ |
throw new Exception("Count " + count + " != " + size()); |
104 |
+ |
} |
105 |
+ |
|
106 |
+ |
static void testDescendingIter(Deque<Integer> deque) throws Exception { |
107 |
+ |
int next = deque.size() + nextHead; |
108 |
+ |
int count = 0; |
109 |
+ |
for (Iterator<Integer> it = deque.descendingIterator(); it.hasNext();) { |
110 |
+ |
int j = it.next(); |
111 |
+ |
if (j != next--) |
112 |
+ |
throw new Exception("Element "+ j + " != " + (next-1)); |
113 |
+ |
count++; |
114 |
+ |
} |
115 |
|
if (count != size()) |
116 |
|
throw new Exception("Count " + count + " != " + size()); |
117 |
|
} |