|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object prefuse.util.collections.AbstractHashMap
public abstract class AbstractHashMap
Abstract base class for hash maps holding objects or primitive data types
such as int
, float
, etc. as keys and/or
values. First see the package summary and
javadoc tree view to get the broad picture.
Note that implementations are not synchronized.
HashMap
Field Summary | |
---|---|
protected static int |
defaultCapacity
|
protected static double |
defaultMaxLoadFactor
|
protected static double |
defaultMinLoadFactor
|
protected int |
distinct
The number of distinct associations in the map; its "size()". |
protected int |
highWaterMark
|
protected int |
lowWaterMark
The table capacity c=table.length always satisfies the invariant c * minLoadFactor <= s <= c * maxLoadFactor, where s=size() is the number of associations currently contained. |
protected double |
maxLoadFactor
The maximum load factor for the hashtable. |
protected double |
minLoadFactor
The minimum load factor for the hashtable. |
Constructor Summary | |
---|---|
protected |
AbstractHashMap()
Makes this class non instantiable, but still let's others inherit from it. |
Method Summary | |
---|---|
protected int |
chooseGrowCapacity(int size,
double minLoad,
double maxLoad)
Chooses a new prime table capacity optimized for growing that (approximately) satisfies the invariant c * minLoadFactor <= size <= c * maxLoadFactor and has at least one FREE slot for the given size. |
protected int |
chooseHighWaterMark(int capacity,
double maxLoad)
Returns new high water mark threshold based on current capacity and maxLoadFactor. |
protected int |
chooseLowWaterMark(int capacity,
double minLoad)
Returns new low water mark threshold based on current capacity and minLoadFactor. |
protected int |
chooseMeanCapacity(int size,
double minLoad,
double maxLoad)
Chooses a new prime table capacity neither favoring shrinking nor growing, that (approximately) satisfies the invariant c * minLoadFactor <= size <= c * maxLoadFactor and has at least one FREE slot for the given size. |
protected int |
chooseShrinkCapacity(int size,
double minLoad,
double maxLoad)
Chooses a new prime table capacity optimized for shrinking that (approximately) satisfies the invariant c * minLoadFactor <= size <= c * maxLoadFactor and has at least one FREE slot for the given size. |
abstract void |
clear()
Removes all (key,value) associations from the receiver. |
void |
ensureCapacity(int minCapacity)
Ensures that the receiver can hold at least the specified number of elements without needing to allocate new internal memory. |
boolean |
isEmpty()
Returns true if the receiver contains no (key,value) associations. |
protected int |
nextPrime(int desiredCapacity)
Returns a prime number which is >= desiredCapacity and
very close to desiredCapacity (within 11% if
desiredCapacity >= 1000 ). |
protected void |
setUp(int initialCapacity,
double minLoadFactor,
double maxLoadFactor)
Initializes the receiver. |
int |
size()
Returns the number of (key,value) associations currently contained. |
void |
trimToSize()
Trims the capacity of the receiver to be the receiver's current size. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int distinct
protected int lowWaterMark
protected int highWaterMark
protected double minLoadFactor
protected double maxLoadFactor
protected static final int defaultCapacity
protected static final double defaultMinLoadFactor
protected static final double defaultMaxLoadFactor
Constructor Detail |
---|
protected AbstractHashMap()
Method Detail |
---|
protected int chooseGrowCapacity(int size, double minLoad, double maxLoad)
protected int chooseHighWaterMark(int capacity, double maxLoad)
protected int chooseLowWaterMark(int capacity, double minLoad)
protected int chooseMeanCapacity(int size, double minLoad, double maxLoad)
protected int chooseShrinkCapacity(int size, double minLoad, double maxLoad)
public abstract void clear()
public void ensureCapacity(int minCapacity)
This method never need be called; it is for performance tuning only. Calling this method before put()ing a large number of associations boosts performance, because the receiver will grow only once instead of potentially many times.
This default implementation does nothing. Override this method if necessary.
minCapacity
- the desired minimum capacity.public boolean isEmpty()
protected int nextPrime(int desiredCapacity)
>= desiredCapacity
and
very close to desiredCapacity
(within 11% if
desiredCapacity >= 1000
).
desiredCapacity
- the capacity desired by the user.
protected void setUp(int initialCapacity, double minLoadFactor, double maxLoadFactor)
initialCapacity
- the initial capacity of the receiver.minLoadFactor
- the minLoadFactor of the receiver.maxLoadFactor
- the maxLoadFactor of the receiver.
java.lang.IllegalArgumentException
- if
initialCapacity < 0 || (minLoadFactor < 0.0 || minLoadFactor >= 1.0) || (maxLoadFactor <= 0.0 || maxLoadFactor >= 1.0) || (minLoadFactor >= maxLoadFactor).public int size()
public void trimToSize()
This default implementation does nothing. Override this method if necessary.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |