@Test public void testSize() throws Exception { final Set<String> authority = new HashSet<String>(); authority.add("1"); authority.add("2"); authority.add("3"); Set<String> set = new LargeSet<String>() { @Override public Iterator<String> sourceIterator() { return authority.iterator(); } @Override public int sourceSize() { return authority.size(); } }; Assert.assertEquals(3, set.size()); set.remove("1"); set.remove("2"); Assert.assertEquals(1, set.size()); authority.remove("2"); authority.remove("3"); Assert.assertEquals(0, set.size()); }
public final int size() { return Math.max(0, sourceSize() + addSet.size() - removeSet.size()); }
LargeCollection extends AbstractCollection < E > { public final int size() { return Math.max(0, sourceSize() + addSet.size() - removeSet.size()); } }
LargeCollection extends AbstractCollection < E > { public final int size() { return Math.max(0, sourceSize() + addSet.size() - removeSet.size()); } LargeCollection(); }
LargeCollection extends AbstractCollection < E > { public final int size() { return Math.max(0, sourceSize() + addSet.size() - removeSet.size()); } LargeCollection(); @Override final boolean add(final E obj); @Override final boolean contains(final Object obj); @Override final boolean remove(final Object obj); final boolean removeAll(final Collection < ? > removeCandidates); final Iterator < E > iterator(); final int size(); abstract Iterator < E > sourceIterator(); abstract int sourceSize(); }
LargeCollection extends AbstractCollection < E > { public final int size() { return Math.max(0, sourceSize() + addSet.size() - removeSet.size()); } LargeCollection(); @Override final boolean add(final E obj); @Override final boolean contains(final Object obj); @Override final boolean remove(final Object obj); final boolean removeAll(final Collection < ? > removeCandidates); final Iterator < E > iterator(); final int size(); abstract Iterator < E > sourceIterator(); abstract int sourceSize();  }