Package com.sleepycat.collections
Class StoredKeySet<K>
java.lang.Object
com.sleepycat.collections.StoredContainer
com.sleepycat.collections.StoredCollection<K>
com.sleepycat.collections.StoredKeySet<K>
- All Implemented Interfaces:
Cloneable,Iterable<K>,Collection<K>,Set<K>
- Direct Known Subclasses:
StoredSortedKeySet
The Set returned by Map.keySet() and which can also be constructed directly
if a Map is not needed.
Since this collection is a set it only contains one element for each key,
even when duplicates are allowed. Key set iterators are therefore
particularly useful for enumerating the unique keys of a store or index that
allows duplicates.
-
Field Summary
Fields inherited from class com.sleepycat.collections.StoredCollection
DEFAULT_ITERATOR_BLOCK_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionStoredKeySet(Database database, EntryBinding<K> keyBinding, boolean writeAllowed) Creates a key set view of aDatabase. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the specified key to this set if it is not already present (optional operation).booleanReturns true if this set contains the specified key.booleanRemoves the specified key from this set if it is present (optional operation).Methods inherited from class com.sleepycat.collections.StoredCollection
addAll, containsAll, equals, getIteratorBlockSize, hashCode, iterator, iterator, join, removeAll, retainAll, setIteratorBlockSize, size, storedIterator, storedIterator, toArray, toArray, toList, toStringMethods inherited from class com.sleepycat.collections.StoredContainer
areDuplicatesAllowed, areDuplicatesOrdered, areKeyRangesAllowed, areKeysRenumbered, clear, getCursorConfig, isEmpty, isOrdered, isSecondary, isTransactional, isWriteAllowedMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Constructor Details
-
StoredKeySet
Creates a key set view of aDatabase.- Parameters:
database- is the Database underlying the new collection.keyBinding- is the binding used to translate between key buffers and key objects.writeAllowed- is true to create a read-write collection or false to create a read-only collection.- Throws:
IllegalArgumentException- if formats are not consistently defined or a parameter is invalid.RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
-
Method Details
-
add
Adds the specified key to this set if it is not already present (optional operation). This method conforms to theSet.add(E)interface.WARNING: When a key is added the value in the underlying data store will be empty, i.e., the byte array will be zero length. Such a record cannot be accessed using the Map interface unless the value binding supports zero length byte arrays.
- Specified by:
addin interfaceCollection<K>- Specified by:
addin interfaceSet<K>- Throws:
UnsupportedOperationException- if the collection is indexed, or if the collection is read-only.RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
remove
Removes the specified key from this set if it is present (optional operation). If duplicates are allowed, this method removes all duplicates for the given key. This method conforms to theSet.remove(java.lang.Object)interface.- Specified by:
removein interfaceCollection<K>- Specified by:
removein interfaceSet<K>- Throws:
UnsupportedOperationException- if the collection is read-only.RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
contains
Returns true if this set contains the specified key. This method conforms to theSet.contains(java.lang.Object)interface.- Specified by:
containsin interfaceCollection<K>- Specified by:
containsin interfaceSet<K>- Throws:
RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-