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
public class StoredKeySet<K>
- extends StoredCollection<K>
- implements Set<K>
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.
- Author:
- Mark Hayes
Methods inherited from class com.sleepycat.collections.StoredCollection |
add, addAll, blockIterator, checkIterAddAllowed, containsAll, equals, getFirstOrLast, getIndexOffset, getIteratorBlockSize, hashCode, iterator, iterator, join, makeIteratorData, removeAll, retainAll, setIteratorBlockSize, size, storedIterator, storedIterator, toArray, toArray, toList, toString |
Methods inherited from class com.sleepycat.collections.StoredContainer |
areDuplicatesAllowed, areDuplicatesOrdered, areKeyRangesAllowed, areKeysRenumbered, beginAutoCommit, clear, closeCursor, commitAutoCommit, configuredClone, containsKey, containsValue, convertException, getCursorConfig, getValue, handleException, initAfterClone, isEmpty, isOrdered, isSecondary, isTransactional, isWriteAllowed, putKeyValue, removeKey, removeValue, storedOrExternalIterator |
Methods inherited from interface java.util.Set |
addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray |
StoredKeySet
public StoredKeySet(Database database,
EntryBinding<K> keyBinding,
boolean writeAllowed)
- Creates a key set view of a
Database
.
- 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 a DatabaseException
on BDB (C Edition).
StoredKeySet
StoredKeySet(DataView keySetView)
add
public boolean add(K key)
- Adds the specified key to this set if it is not already present
(optional operation).
This method conforms to the
Set.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:
add
in interface Collection<K>
- Specified by:
add
in interface Set<K>
- Throws:
OperationFailureException
- if one of the Write
Operation Failures occurs.
EnvironmentFailureException
- if an unexpected, internal or
environment-wide failure occurs.
UnsupportedOperationException
- if the collection is indexed, or
if the collection is read-only.
RuntimeExceptionWrapper
- if a checked exception is thrown,
including a DatabaseException
on BDB (C Edition).
remove
public boolean remove(Object key)
- 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 the
Set.remove(java.lang.Object)
interface.
- Specified by:
remove
in interface Collection<K>
- Specified by:
remove
in interface Set<K>
- Throws:
OperationFailureException
- if one of the Write
Operation Failures occurs.
EnvironmentFailureException
- if an unexpected, internal or
environment-wide failure occurs.
UnsupportedOperationException
- if the collection is read-only.
RuntimeExceptionWrapper
- if a checked exception is thrown,
including a DatabaseException
on BDB (C Edition).
contains
public boolean contains(Object key)
- Returns true if this set contains the specified key.
This method conforms to the
Set.contains(java.lang.Object)
interface.
- Specified by:
contains
in interface Collection<K>
- Specified by:
contains
in interface Set<K>
- Throws:
OperationFailureException
- if one of the Read Operation
Failures occurs.
EnvironmentFailureException
- if an unexpected, internal or
environment-wide failure occurs.
RuntimeExceptionWrapper
- if a checked exception is thrown,
including a DatabaseException
on BDB (C Edition).
hasValues
boolean hasValues()
- Specified by:
hasValues
in class StoredCollection<K>
makeIteratorData
K makeIteratorData(BaseIterator iterator,
DatabaseEntry keyEntry,
DatabaseEntry priKeyEntry,
DatabaseEntry valueEntry)
- Specified by:
makeIteratorData
in class StoredCollection<K>
iterateDuplicates
boolean iterateDuplicates()
- Overrides:
iterateDuplicates
in class StoredCollection<K>
Copyright (c) 2004-2012 Oracle. All rights reserved.