@Test void add() { hugeSet.add("test"); assertEquals(1, hugeSet.size()); }
@Override public boolean add(E obj) { if (hashSet.size() == THRESHOLD) { File dbFile; try { dbFile = File.createTempFile("mapdb", "temp"); } catch (IOException e) { throw new UncheckedIOException(e); } mapDB = DBMaker.newFileDB(dbFile).deleteFilesAfterClose().transactionDisable().make(); set = mapDB.createHashSet("set").make(); set.addAll(hashSet); hashSet.clear(); } if (set == null) { return hashSet.add(obj); } return set.add(obj); }
HugeSet implements Set<E>, Closeable { @Override public boolean add(E obj) { if (hashSet.size() == THRESHOLD) { File dbFile; try { dbFile = File.createTempFile("mapdb", "temp"); } catch (IOException e) { throw new UncheckedIOException(e); } mapDB = DBMaker.newFileDB(dbFile).deleteFilesAfterClose().transactionDisable().make(); set = mapDB.createHashSet("set").make(); set.addAll(hashSet); hashSet.clear(); } if (set == null) { return hashSet.add(obj); } return set.add(obj); } }
HugeSet implements Set<E>, Closeable { @Override public boolean add(E obj) { if (hashSet.size() == THRESHOLD) { File dbFile; try { dbFile = File.createTempFile("mapdb", "temp"); } catch (IOException e) { throw new UncheckedIOException(e); } mapDB = DBMaker.newFileDB(dbFile).deleteFilesAfterClose().transactionDisable().make(); set = mapDB.createHashSet("set").make(); set.addAll(hashSet); hashSet.clear(); } if (set == null) { return hashSet.add(obj); } return set.add(obj); }  }
HugeSet implements Set<E>, Closeable { @Override public boolean add(E obj) { if (hashSet.size() == THRESHOLD) { File dbFile; try { dbFile = File.createTempFile("mapdb", "temp"); } catch (IOException e) { throw new UncheckedIOException(e); } mapDB = DBMaker.newFileDB(dbFile).deleteFilesAfterClose().transactionDisable().make(); set = mapDB.createHashSet("set").make(); set.addAll(hashSet); hashSet.clear(); } if (set == null) { return hashSet.add(obj); } return set.add(obj); }  @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<E> iterator(); @Override Object[] toArray(); @Override T[] toArray(T[] a); @Override boolean add(E obj); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends E> c); @Override boolean retainAll(Collection<?> c); @Override boolean removeAll(Collection<?> c); @Override void clear(); @Override void close(); }
HugeSet implements Set<E>, Closeable { @Override public boolean add(E obj) { if (hashSet.size() == THRESHOLD) { File dbFile; try { dbFile = File.createTempFile("mapdb", "temp"); } catch (IOException e) { throw new UncheckedIOException(e); } mapDB = DBMaker.newFileDB(dbFile).deleteFilesAfterClose().transactionDisable().make(); set = mapDB.createHashSet("set").make(); set.addAll(hashSet); hashSet.clear(); } if (set == null) { return hashSet.add(obj); } return set.add(obj); }  @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<E> iterator(); @Override Object[] toArray(); @Override T[] toArray(T[] a); @Override boolean add(E obj); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends E> c); @Override boolean retainAll(Collection<?> c); @Override boolean removeAll(Collection<?> c); @Override void clear(); @Override void close();  }