395 |
|
assertTrue(q.contains(i)); |
396 |
|
assertTrue(q.remove(i)); |
397 |
|
assertFalse(q.contains(i)); |
398 |
< |
assertTrue(q.contains(i-1)); |
398 |
> |
assertTrue(q.contains(i - 1)); |
399 |
|
} |
400 |
|
for (int i = 0; i < SIZE; i += 2) { |
401 |
|
assertTrue(q.contains(i)); |
402 |
|
assertTrue(q.remove(i)); |
403 |
|
assertFalse(q.contains(i)); |
404 |
< |
assertFalse(q.remove(i+1)); |
405 |
< |
assertFalse(q.contains(i+1)); |
404 |
> |
assertFalse(q.remove(i + 1)); |
405 |
> |
assertFalse(q.contains(i + 1)); |
406 |
|
} |
407 |
|
assertTrue(q.isEmpty()); |
408 |
|
} |
535 |
|
} |
536 |
|
for (int i = 0; i < SIZE; i += 2) { |
537 |
|
assertTrue(q.removeFirstOccurrence(new Integer(i))); |
538 |
< |
assertFalse(q.removeFirstOccurrence(new Integer(i+1))); |
538 |
> |
assertFalse(q.removeFirstOccurrence(new Integer(i + 1))); |
539 |
|
} |
540 |
|
assertTrue(q.isEmpty()); |
541 |
|
} |
550 |
|
} |
551 |
|
for (int i = 0; i < SIZE; i += 2) { |
552 |
|
assertTrue(q.removeLastOccurrence(new Integer(i))); |
553 |
< |
assertFalse(q.removeLastOccurrence(new Integer(i+1))); |
553 |
> |
assertFalse(q.removeLastOccurrence(new Integer(i + 1))); |
554 |
|
} |
555 |
|
assertTrue(q.isEmpty()); |
556 |
|
} |
781 |
|
final Random rng = new Random(); |
782 |
|
for (int iters = 0; iters < 100; ++iters) { |
783 |
|
int max = rng.nextInt(5) + 2; |
784 |
< |
int split = rng.nextInt(max-1) + 1; |
784 |
> |
int split = rng.nextInt(max - 1) + 1; |
785 |
|
for (int j = 1; j <= max; ++j) |
786 |
|
q.add(new Integer(j)); |
787 |
|
Iterator it = q.iterator(); |
788 |
|
for (int j = 1; j <= split; ++j) |
789 |
|
assertEquals(it.next(), new Integer(j)); |
790 |
|
it.remove(); |
791 |
< |
assertEquals(it.next(), new Integer(split+1)); |
791 |
> |
assertEquals(it.next(), new Integer(split + 1)); |
792 |
|
for (int j = 1; j <= split; ++j) |
793 |
|
q.remove(new Integer(j)); |
794 |
|
it = q.iterator(); |
795 |
< |
for (int j = split+1; j <= max; ++j) { |
795 |
> |
for (int j = split + 1; j <= max; ++j) { |
796 |
|
assertEquals(it.next(), new Integer(j)); |
797 |
|
it.remove(); |
798 |
|
} |
849 |
|
final Random rng = new Random(); |
850 |
|
for (int iters = 0; iters < 100; ++iters) { |
851 |
|
int max = rng.nextInt(5) + 2; |
852 |
< |
int split = rng.nextInt(max-1) + 1; |
852 |
> |
int split = rng.nextInt(max - 1) + 1; |
853 |
|
for (int j = max; j >= 1; --j) |
854 |
|
q.add(new Integer(j)); |
855 |
|
Iterator it = q.descendingIterator(); |
856 |
|
for (int j = 1; j <= split; ++j) |
857 |
|
assertEquals(it.next(), new Integer(j)); |
858 |
|
it.remove(); |
859 |
< |
assertEquals(it.next(), new Integer(split+1)); |
859 |
> |
assertEquals(it.next(), new Integer(split + 1)); |
860 |
|
for (int j = 1; j <= split; ++j) |
861 |
|
q.remove(new Integer(j)); |
862 |
|
it = q.descendingIterator(); |
863 |
< |
for (int j = split+1; j <= max; ++j) { |
863 |
> |
for (int j = split + 1; j <= max; ++j) { |
864 |
|
assertEquals(it.next(), new Integer(j)); |
865 |
|
it.remove(); |
866 |
|
} |