com.sosnoski.util.hashset
Class ObjectSetBase

java.lang.Object
  |
  +--com.sosnoski.util.ObjectHashBase
        |
        +--com.sosnoski.util.hashset.ObjectSetBase
Direct Known Subclasses:
ObjectHashSet, StringHashSet

public abstract class ObjectSetBase
extends ObjectHashBase

Base class for type-specific hash set classes with object keys. This class builds on the basic structure provided by ObjectHashBase, specializing it for the case of a hash set where the keys are the only data. See the base class description for details of the implementation.

Hash sets based on this class are unsynchronized in order to provide the best possible performance for typical usage scenarios, so explicit synchronization must be implemented by the subclass or the application in cases where they are to be modified in a multithreaded environment.

Subclasses need to implement the abstract methods defined by the base class for working with the key array, and the abstract restructuring method defined by this class, as well as the actual data access methods (at least the basic add, contains, and remove methods).

Version:
1.1
Author:
Dennis M. Sosnoski

Fields inherited from class com.sosnoski.util.ObjectHashBase
DEFAULT_FILL, IDENTITY_COMP, IDENTITY_HASH, m_arraySize, m_entryCount, m_entryLimit, m_fillFraction, m_hitOffset, m_identCompare, m_identHash, MINIMUM_SIZE, STANDARD_HASH
 
Constructor Summary
ObjectSetBase(int count, double fill, java.lang.Class type, java.lang.Object tech)
          Constructor with full specification.
ObjectSetBase(ObjectSetBase base)
          Copy (clone) constructor.
 
Method Summary
protected  void internalRemove(int slot)
          Internal remove item from the table.
 java.util.Iterator iterator()
          Return an iterator for the Objects in this set.
protected  void reallocate(int size)
          Resize the base array after a size change.
protected abstract  boolean reinsert(int slot)
          Reinsert an entry into the table.
protected abstract  void restructure(java.lang.Object karray)
          Restructure the table.
 
Methods inherited from class com.sosnoski.util.ObjectHashBase
clear, ensureCapacity, freeSlot, getKeyArray, growCapacity, setKeyArray, size, standardFind, standardSlot, stepSlot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectSetBase

public ObjectSetBase(int count,
                     double fill,
                     java.lang.Class type,
                     java.lang.Object tech)
Constructor with full specification.
Parameters:
count - number of values to assume in initial sizing of table
fill - fraction full allowed for table before growing
type - type of objects contained in table
tech - hash technique specifier (one of STANDARD_HASH, IDENTITY_COMP, or IDENTITY_HASH, inherited from ObjectSetBase)

ObjectSetBase

public ObjectSetBase(ObjectSetBase base)
Copy (clone) constructor.
Parameters:
base - instance being copied
Method Detail

reinsert

protected abstract boolean reinsert(int slot)
Reinsert an entry into the table. This method is used when the table is being directly modified by the base class, and should not adjust the count present or check the table capacity.
Parameters:
slot - position of entry to be reinserted into table
Returns:
true if the slot number used by the entry has has changed, false if not

restructure

protected abstract void restructure(java.lang.Object karray)
Restructure the table. This abstract method is used when the table is increasing or decreasing in size, and works directly with the old table representation array. It should insert keys from the old array directly into the table without adjusting the count present or checking the table size.
Parameters:
karray - array of keys

reallocate

protected void reallocate(int size)
Resize the base array after a size change. This implementation of the abstract base class method allocates the new array and then calls another method for handling the actual transfer of the key set from the old array to the new one.
Overrides:
reallocate in class ObjectHashBase
Parameters:
size - new size for base arrays

internalRemove

protected void internalRemove(int slot)
Internal remove item from the table. Removes the item from the table by setting the key entry to null and adjusting the count present, then chains through the table to reinsert any other items which may have collided with the removed item.
Parameters:
slot - index number of item to be removed

iterator

public final java.util.Iterator iterator()
Return an iterator for the Objects in this set. The iterator returns all items in arbitrary order, but is not "live". Any changes to the set while the iteration is in progress will give indeterminant results.
Returns:
iterator for values in set


Company Web Site

XML Benchmark Home