DB { synchronized public <K> Set<K> getHashSet(String name){ checkNotClosed(); Set<K> ret = (Set<K>) getFromWeakCollection(name); if(ret!=null) return ret; Long recid = nameDir.get(name); if(recid!=null){ HTreeMap<K,Object> m = new HTreeMap<K,Object>(engine, recid, defaultSerializer); if(m.hasValues) throw new ClassCastException("Collection is Map, not Set"); ret = m.keySet(); }else{ HTreeMap<K,Object> m = new HTreeMap<K,Object>(engine, false,Utils.RANDOM.nextInt(), defaultSerializer, null, null); ret = m.keySet(); nameDir.put(name, m.rootRecid); } collections.put(name, new WeakReference<Object>(ret)); return ret; } DB(final Engine engine); synchronized HTreeMap<K,V> getHashMap(String name); synchronized HTreeMap<K,V> createHashMap(
            String name, Serializer<K> keySerializer, Serializer<V> valueSerializer); synchronized Set<K> getHashSet(String name); synchronized Set<K> createHashSet(String name, Serializer<K> serializer); synchronized BTreeMap<K,V> getTreeMap(String name); synchronized BTreeMap<K,V> createTreeMap(
            String name, int nodeSize, boolean valuesStoredOutsideNodes,
            BTreeKeySerializer<K> keySerializer, Serializer<V> valueSerializer, Comparator<K> comparator); Map<String, Long> getNameDir(); synchronized NavigableSet<K> getTreeSet(String name); synchronized NavigableSet<K> createTreeSet(String name, int nodeSize, BTreeKeySerializer<K> serializer, Comparator<K> comparator); synchronized Queue<E> getQueue(String name); synchronized Queue<E> getStack(String name); synchronized Queue<E> getCircularQueue(String name); synchronized Queue<E> createQueue(String name, Serializer<E> serializer); synchronized Queue<E> createStack(String name, Serializer<E> serializer, boolean useLocks); synchronized Queue<E> createCircularQueue(String name, Serializer<E> serializer, long size); synchronized void close(); synchronized boolean isClosed(); synchronized void commit(); synchronized void rollback(); synchronized void compact(); synchronized DB snapshot(); Serializer getDefaultSerializer(); Engine getEngine();  }
@Test public void testGetHashSet() throws Exception { Set m1 = db.getHashSet("test"); m1.add(1); m1.add(2); assertTrue(m1 == db.getHashSet("test")); assertEquals(m1, new DB(engine).getHashSet("test")); }