LowMemorySet extends AbstractSet<T> implements Set<T> { @Override public boolean add(T t) { if (contains(t)) return false; backing.add(t); this.sort(); return true; } protected  LowMemorySet(List<T> list); static LowMemorySet<T> create(); static LowMemorySet<T> copyOf(Collection<T> c); @Override int size(); @Override boolean contains(Object o); @Override Iterator<T> iterator(); @Override Object[] toArray(); @Override T1[] toArray(T1[] a); @Override boolean add(T t); @Override boolean remove(Object o); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override @SuppressWarnings("unchecked") boolean addAll(Collection<? extends T> c); @Override void clear(); @Override void forEach(Consumer<? super T> action); @Override Stream<T> stream(); @Override Stream<T> parallelStream(); @Override boolean removeIf(Predicate<? super T> filter);  }
@Test public void testAdd() { LowMemorySet<String> set = LowMemorySet.copyOf(ELEMENTS); assertFalse(set.contains("Techcable")); set.add("Techcable"); assertTrue(set.contains("Techcable")); set.addAll(ImmutableList.of("Techcable", "PhanaticD", "Dragonslayer293", "Aikar")); assertTrue(set.contains("Techcable")); assertTrue(set.contains("PhanaticD")); assertTrue(set.contains("Aikar")); assertFalse(set.contains("md_5")); }