Class COM.odi.util.OSHashSet

java.lang.Object
   |
   +----COM.odi.util.OSAbstractSet
           |
           +----COM.odi.util.OSHashSet

public class OSHashSet
extends OSAbstractSet
implements IPersistent, Cloneable, Set, FastContains, Serializable
OSHashSet implements a persistent set, as defined by the COM.odi.util.Set interface. The equals() and hashCode() methods are content-based, not reference-based (they differ in this way from the equals() and hashCode() methods on OSHashBag). Certain operations on OSHashSet that require comparison of objects might cause ObjectStore to throw ReferencedObjectNotFoundException. If this occurs, it indicates that one or more of the values referenced by the underlying hash table cannot be accessed, most likely because they have been destroyed. The OSHashSet class provides a clearDestroyed() operation that can be used to remove entries that contain these references to these destroyed objects.

Additional information about OSHashSet is in the user guide. Here are exceptions that might be thrown by many of the methods in this class:

DatabaseNotOpenException If the database containing the object is not open.

NoTransactionInProgressException If there is no transaction in progress.

ObjectNotFoundException If the object was not found, either because the object itself, its segment, or its database was destroyed.

ObjectException Ifthe object was local and was fetched in a previous transaction.

ObjectStoreException If the session implied by an argument to the call or the object the method is called on is not the same as the session associated with the current thread.

UpdateReadOnlyException If there is a readonly transaction in progress or if the database is open for readonly.

See Also:
IPersistent, Set

Constructor Index

 o OSHashSet()
Create a new, empty OSHashSet.
 o OSHashSet(int)
Create a new, empty OSHashSet, and allocate a backing hashtable of the specified size.

Method Index

 o add(Object)
Ensures that this Collection contains the specified element.
 o clear()
Removes all of the elements from this Collection.
 o clearDestroyed()
Removes from the hash table all entries which reference destroyed objects either as a key or value.
 o contains(Object)
Returns true if this Collection contains the specified element.
 o isEmpty()
Returns true if this Collection contains no elements.
 o iterator()
Returns an Iterator over the elements in this Collection.
 o remove(Object)
Removes a single instance of the specified element from this Collection, if it is present.
 o size()
Returns the number of elements in this Collection.
 o toArray()
Returns an array containing all of the elements in this Collection.

Constructors

 o OSHashSet
  public OSHashSet()
Create a new, empty OSHashSet.

 o OSHashSet
  public OSHashSet(int initSize)
Create a new, empty OSHashSet, and allocate a backing hashtable of the specified size.

Methods

 o clearDestroyed
  public void clearDestroyed()
Removes from the hash table all entries which reference destroyed objects either as a key or value. The current implementation of this method requires that all key, value objects referenced by the OSHashtable be fetched, which may require significant heap space.

 o size
  public int size()
Returns the number of elements in this Collection.

Overrides:
size in class OSAbstractSet
 o isEmpty
  public boolean isEmpty()
Returns true if this Collection contains no elements.

Overrides:
isEmpty in class OSAbstractSet
 o contains
  public boolean contains(Object o)
Returns true if this Collection contains the specified element. More formally, returns true if and only if this Collection contains at least one element e such that o.equals(e).

Parameters:
o - element whose presence in this Collection is to be tested.
Overrides:
contains in class OSAbstractSet
 o iterator
  public Iterator iterator()
Returns an Iterator over the elements in this Collection. There are no guarantees concerning the order in which the elements are returned.

Overrides:
iterator in class OSAbstractSet
 o toArray
  public Object[] toArray()
Returns an array containing all of the elements in this Collection. The returned array will be "safe" in that no references to it are maintained by the Collection. (In other words, this method must allocate a new array even if the Collection is backed by an Array). The caller is thus free to modify the returned array.

This method acts as bridge between array-based and Collection-based APIs.

Overrides:
toArray in class OSAbstractSet
 o add
  public boolean add(Object o)
Ensures that this Collection contains the specified element. Returns true if the Collection changed as a result of the call. Returns false if this Collection does not permit duplicates and already contains the specified element.

Parameters:
o - element whose presence in this Collection is to be ensured.
Returns:
true if the Collection changed as a result of the call.
Overrides:
add in class OSAbstractSet
 o remove
  public boolean remove(Object o)
Removes a single instance of the specified element from this Collection, if it is present. More formally, removes an element e such that o.equals(e), if the Collection contains one or more such elements. Returns true if the Collection contained the specified element (or equivalently, if the Collection changed as a result of the call).

Parameters:
o - element to be removed from this Collection, if present.
Returns:
true if the Collection changed as a result of the call.
Overrides:
remove in class OSAbstractSet
 o clear
  public void clear()
Removes all of the elements from this Collection. The Collection will be empty after this call returns.

Overrides:
clear in class OSAbstractSet

Copyright © 1996, 1997, 1998 Object Design, Inc. All rights reserved.