com.sosnoski.util.hashset
Class PrimitiveSetBase
java.lang.Object
|
+--com.sosnoski.util.PrimitiveHashBase
|
+--com.sosnoski.util.hashset.PrimitiveSetBase
- Direct Known Subclasses:
- DoubleHashSet, IntHashSet
- public abstract class PrimitiveSetBase
- extends PrimitiveHashBase
Base class for type-specific hash set classes with primitive keys. This
class builds on the basic structure provided by
PrimitiveHashBase, 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.0
- Author:
- Dennis M. Sosnoski
- See Also:
PrimitiveHashBase
|
Method Summary |
protected void |
reallocate(int size)
Resize the base arrays after a size change. |
protected abstract void |
restructure(boolean[] flags,
java.lang.Object karray)
Restructure the table. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PrimitiveSetBase
public PrimitiveSetBase(int count,
double fill,
java.lang.Class ktype)
- Constructor with full specification.
- Parameters:
count - number of values to assume in initial sizing of tablefill - fraction full allowed for table before growingktype - type of primitives used for keys
PrimitiveSetBase
public PrimitiveSetBase(PrimitiveSetBase base)
- Copy (clone) constructor.
- Parameters:
base - instance being copied
restructure
protected abstract void restructure(boolean[] flags,
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 arrays. It should insert keys from the old array
directly into the table without adjusting the count present or checking
the table size.
- Parameters:
flags - array of flags for array slots usedkarray - array of keys
reallocate
protected void reallocate(int size)
- Resize the base arrays after a size change. This implementation of the
abstract base class method allocates the new arrays and then calls
another method for handling the actual transfer of the key set from the
old arrays to the new ones.
- Overrides:
reallocate in class PrimitiveHashBase
- Parameters:
size - new size for base arrays