Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Berkeley DB Java Edition version 1.7.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sleepycat.collections
Class StoredKeySet

    java.lang.Object
      com.sleepycat.collections.StoredContainer
          com.sleepycat.collections.StoredCollection
              com.sleepycat.collections.StoredKeySet

All Implemented Interfaces:
  Cloneable, Collection, Set

Direct Known Subclasses:
  StoredSortedKeySet

public class StoredKeySet
extends StoredCollection
implements Set

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.

Note that this class does not conform to the standard Java collections interface in the following ways:

- The `StoredContainer.size()` method always throws `UnsupportedOperationException` because, for performance reasons, databases do not maintain their total record count.
- All iterators must be explicitly closed using `StoredIterator.close()` or `StoredIterator.close(java.util.Iterator)` to release the underlying database cursor resources.

Author:
  Mark Hayes

Constructor Summary
`StoredKeySet(Database database, EntryBinding keyBinding, boolean writeAllowed)` Creates a key set view of a `Database`.

Method Summary
`boolean` | `add(Object key)` Adds the specified key to this set if it is not already present (optional operation).
`boolean` | `contains(Object key)` Returns true if this set contains the specified key.
`boolean` | `remove(Object key)` Removes the specified key from this set if it is present (optional operation).

Methods inherited from class com.sleepycat.collections.StoredCollection
`addAll, containsAll, equals, hashCode, iterator, iterator, join, removeAll, retainAll, toArray, toArray, toList, toString`

Methods inherited from class com.sleepycat.collections.StoredContainer
`areDuplicatesAllowed, areDuplicatesOrdered, areKeysRenumbered, clear, isDirtyRead, isDirtyReadAllowed, isEmpty, isOrdered, isSecondary, isTransactional, isWriteAllowed, size`

Methods inherited from class java.lang.Object
`getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface java.util.Set
`addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray`

Constructor Detail

### StoredKeySet

    public StoredKeySet(Database database,
                        EntryBinding 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 `DatabaseException` is thrown.

Method Detail

### add

    public boolean add(Object key)

  Adds the specified key to this set if it is not already present (optional operation). When a key is added the value in the underlying data store will be empty. This method conforms to the `Set.add(java.lang.Object)` interface.

  Specified by:
    `add` in interface `Set`
  Throws:
    `UnsupportedOperationException` - if the collection is indexed, or if the collection is read-only.
    `RuntimeExceptionWrapper` - if a `DatabaseException` is thrown.

### 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 `Set`
  Throws:
    `UnsupportedOperationException` - if the collection is read-only.
    `RuntimeExceptionWrapper` - if a `DatabaseException` is thrown.

### 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 `Set`
  Throws:
    `RuntimeExceptionWrapper` - if a `DatabaseException` is thrown.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Berkeley DB Java Edition version 1.7.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 1996-2005 Sleepycat Software, Inc. - All rights reserved.