439 |
|
assertTrue(q.contains(i)); |
440 |
|
assertTrue(q.remove(i)); |
441 |
|
assertFalse(q.contains(i)); |
442 |
< |
assertTrue(q.contains(i-1)); |
442 |
> |
assertTrue(q.contains(i - 1)); |
443 |
|
} |
444 |
|
for (int i = 0; i < SIZE; i += 2) { |
445 |
|
assertTrue(q.contains(i)); |
446 |
|
assertTrue(q.remove(i)); |
447 |
|
assertFalse(q.contains(i)); |
448 |
< |
assertFalse(q.remove(i+1)); |
449 |
< |
assertFalse(q.contains(i+1)); |
448 |
> |
assertFalse(q.remove(i + 1)); |
449 |
> |
assertFalse(q.contains(i + 1)); |
450 |
|
} |
451 |
|
assertTrue(q.isEmpty()); |
452 |
|
} |
550 |
|
} |
551 |
|
for (int i = 0; i < SIZE; i += 2) { |
552 |
|
assertTrue(q.removeFirstOccurrence(new Integer(i))); |
553 |
< |
assertFalse(q.removeFirstOccurrence(new Integer(i+1))); |
553 |
> |
assertFalse(q.removeFirstOccurrence(new Integer(i + 1))); |
554 |
|
} |
555 |
|
assertTrue(q.isEmpty()); |
556 |
|
} |
565 |
|
} |
566 |
|
for (int i = 0; i < SIZE; i += 2) { |
567 |
|
assertTrue(q.removeLastOccurrence(new Integer(i))); |
568 |
< |
assertFalse(q.removeLastOccurrence(new Integer(i+1))); |
568 |
> |
assertFalse(q.removeLastOccurrence(new Integer(i + 1))); |
569 |
|
} |
570 |
|
assertTrue(q.isEmpty()); |
571 |
|
} |
753 |
|
final Random rng = new Random(); |
754 |
|
for (int iters = 0; iters < 100; ++iters) { |
755 |
|
int max = rng.nextInt(5) + 2; |
756 |
< |
int split = rng.nextInt(max-1) + 1; |
756 |
> |
int split = rng.nextInt(max - 1) + 1; |
757 |
|
for (int j = 1; j <= max; ++j) |
758 |
|
q.add(new Integer(j)); |
759 |
|
Iterator it = q.iterator(); |
760 |
|
for (int j = 1; j <= split; ++j) |
761 |
|
assertEquals(it.next(), new Integer(j)); |
762 |
|
it.remove(); |
763 |
< |
assertEquals(it.next(), new Integer(split+1)); |
763 |
> |
assertEquals(it.next(), new Integer(split + 1)); |
764 |
|
for (int j = 1; j <= split; ++j) |
765 |
|
q.remove(new Integer(j)); |
766 |
|
it = q.iterator(); |
767 |
< |
for (int j = split+1; j <= max; ++j) { |
767 |
> |
for (int j = split + 1; j <= max; ++j) { |
768 |
|
assertEquals(it.next(), new Integer(j)); |
769 |
|
it.remove(); |
770 |
|
} |
821 |
|
final Random rng = new Random(); |
822 |
|
for (int iters = 0; iters < 100; ++iters) { |
823 |
|
int max = rng.nextInt(5) + 2; |
824 |
< |
int split = rng.nextInt(max-1) + 1; |
824 |
> |
int split = rng.nextInt(max - 1) + 1; |
825 |
|
for (int j = max; j >= 1; --j) |
826 |
|
q.add(new Integer(j)); |
827 |
|
Iterator it = q.descendingIterator(); |
828 |
|
for (int j = 1; j <= split; ++j) |
829 |
|
assertEquals(it.next(), new Integer(j)); |
830 |
|
it.remove(); |
831 |
< |
assertEquals(it.next(), new Integer(split+1)); |
831 |
> |
assertEquals(it.next(), new Integer(split + 1)); |
832 |
|
for (int j = 1; j <= split; ++j) |
833 |
|
q.remove(new Integer(j)); |
834 |
|
it = q.descendingIterator(); |
835 |
< |
for (int j = split+1; j <= max; ++j) { |
835 |
> |
for (int j = split + 1; j <= max; ++j) { |
836 |
|
assertEquals(it.next(), new Integer(j)); |
837 |
|
it.remove(); |
838 |
|
} |