@SuppressWarnings("ModifyingCollectionWithItself") @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="DMI_VACUOUS_SELF_COLLECTION_CALL", justification="Intended vacuous containsAll call on 'c'") private void verify(ConcatenatedLists<Long> c, int last) { assertEquals((last == -1), c.isEmpty()); assertEquals(last + 1, c.size()); // This check is O(n^2), test with care assertTrue(c.containsAll(c)); Long[] array = c.toArray(new Long[c.size()]); List<Long> all = new ArrayList<>(); Iterator<Long> iter = c.iterator(); for (Long i = 0L; i <= last; ++i) { assertTrue(iter.hasNext()); assertEquals(i, iter.next()); assertEquals(i, array[i.intValue()]); assertTrue(c.contains(i)); assertTrue(c.containsAll(Arrays.asList(i))); all.add(i); } assertTrue(c.containsAll(all)); assertFalse(iter.hasNext()); try { iter.next(); fail("Should have thrown"); } catch (NoSuchElementException nsee) { } } }
@Override public boolean containsAll(Collection<?> c) { for (Object o : c) { if (!contains(o)) return false; } return true; }
@SuppressWarnings("ModifyingCollectionWithItself") @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="DMI_VACUOUS_SELF_COLLECTION_CALL", justification="Intended vacuous containsAll call on 'c'") private void verify(ConcatenatedLists<Long> c, int last) { assertEquals((last == -1), c.isEmpty()); assertEquals(last + 1, c.size()); // This check is O(n^2), test with care assertTrue(c.containsAll(c)); Long[] array = c.toArray(new Long[c.size()]); List<Long> all = new ArrayList<>(); Iterator<Long> iter = c.iterator(); for (Long i = 0L; i <= last; ++i) { assertTrue(iter.hasNext()); assertEquals(i, iter.next()); assertEquals(i, array[i.intValue()]); assertTrue(c.contains(i)); assertTrue(c.containsAll(Arrays.asList(i))); all.add(i); } assertTrue(c.containsAll(all)); assertFalse(iter.hasNext()); try { iter.next(); fail("Should have thrown"); } catch (NoSuchElementException nsee) { } } }
@SuppressWarnings("ModifyingCollectionWithItself") @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="DMI_VACUOUS_SELF_COLLECTION_CALL", justification="Intended vacuous containsAll call on 'c'") private void verify(ConcatenatedLists<Long> c, int last) { assertEquals((last == -1), c.isEmpty()); assertEquals(last + 1, c.size()); // This check is O(n^2), test with care assertTrue(c.containsAll(c)); Long[] array = c.toArray(new Long[c.size()]); List<Long> all = new ArrayList<>(); Iterator<Long> iter = c.iterator(); for (Long i = 0L; i <= last; ++i) { assertTrue(iter.hasNext()); assertEquals(i, iter.next()); assertEquals(i, array[i.intValue()]); assertTrue(c.contains(i)); assertTrue(c.containsAll(Arrays.asList(i))); all.add(i); } assertTrue(c.containsAll(all)); assertFalse(iter.hasNext()); try { iter.next(); fail("Should have thrown"); } catch (NoSuchElementException nsee) { } } }