|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--freaklamarsch.util.FLMHashMap
Nested Class Summary | |
(package private) static class |
FLMHashMap.Entry
Returns a shallow copy of this HashMap instance: the keys and values themselves are not cloned. |
Field Summary | |
(package private) static int |
DEFAULT_INITIAL_CAPACITY
The default initial capacity - MUST be a power of two. |
(package private) static float |
DEFAULT_LOAD_FACTOR
The load fast used when none specified in constructor. |
(package private) float |
loadFactor
The load factor for the hash table. |
(package private) static int |
MAXIMUM_CAPACITY
The maximum capacity, used if a higher value is implicitly specified by either of the constructors with arguments. |
(package private) static java.lang.Object |
NULL_KEY
Value representing null keys inside tables. |
(package private) int |
size
The number of key-value mappings contained in this identity hash map. |
(package private) FLMHashMap.Entry[] |
table
The table, resized as necessary. |
(package private) int |
threshold
The next size value at which to resize (capacity * load factor). |
Constructor Summary | |
FLMHashMap()
Constructs an empty HashMap with the default initial capacity (16) and the default load factor (0.75). |
|
FLMHashMap(int initialCapacity)
Constructs an empty HashMap with the specified initial capacity and the default load factor (0.75). |
|
FLMHashMap(int initialCapacity,
float loadFactor)
Constructs an empty HashMap with the specified initial capacity and load factor. |
Method Summary | |
(package private) void |
addEntry(int hash,
java.lang.Object key,
java.lang.Object value,
int bucketIndex)
Add a new entry with the specified key, value and hash code to the specified bucket. |
void |
clear()
Removes all mappings from this map. |
(package private) void |
createEntry(int hash,
java.lang.Object key,
java.lang.Object value,
int bucketIndex)
Like addEntry except that this version is used when creating entries as part of Map construction or "pseudo-construction" (cloning, deserialization). |
(package private) boolean |
eq(java.lang.Object x,
java.lang.Object y)
Check for equality of non-null reference x and possibly-null y. |
java.lang.Object |
get(java.lang.Object key)
Returns the value to which the specified key is mapped in this identity hash map, or null if the map contains no mapping for this key. |
(package private) int |
hash(java.lang.Object x)
Returns a hash code for non-null Object x. |
(package private) static int |
indexFor(int h,
int length)
Returns index for hash code h. |
(package private) void |
init()
Initialization hook for subclasses. |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings. |
(package private) static java.lang.Object |
maskNull(java.lang.Object key)
Returns internal representation for key. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Associates the specified value with the specified key in this map. |
java.lang.Object |
remove(java.lang.Object key)
Removes the mapping for this key from this map if present. |
(package private) FLMHashMap.Entry |
removeEntryForKey(java.lang.Object key)
Removes and returns the entry associated with the specified key in the HashMap. |
(package private) void |
resize(int newCapacity)
Rehashes the contents of this map into a new HashMap instance with a larger capacity. |
int |
size()
Returns the number of key-value mappings in this map. |
(package private) void |
transfer(FLMHashMap.Entry[] newTable)
Transfer all entries from current table to newTable. |
(package private) static java.lang.Object |
unmaskNull(java.lang.Object key)
Returns key represented by specified internal representation. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
static final int DEFAULT_INITIAL_CAPACITY
static final int MAXIMUM_CAPACITY
static final float DEFAULT_LOAD_FACTOR
FLMHashMap.Entry[] table
int size
int threshold
float loadFactor
static final java.lang.Object NULL_KEY
Constructor Detail |
public FLMHashMap(int initialCapacity, float loadFactor)
initialCapacity
- The initial capacity.loadFactor
- The load factor.
java.lang.IllegalArgumentException
- if the initial capacity is negative
or the load factor is nonpositive.public FLMHashMap(int initialCapacity)
initialCapacity
- the initial capacity.
java.lang.IllegalArgumentException
- if the initial capacity is negative.public FLMHashMap()
Method Detail |
void init()
static java.lang.Object maskNull(java.lang.Object key)
static java.lang.Object unmaskNull(java.lang.Object key)
int hash(java.lang.Object x)
boolean eq(java.lang.Object x, java.lang.Object y)
static int indexFor(int h, int length)
public int size()
public boolean isEmpty()
public java.lang.Object get(java.lang.Object key)
key
- the key whose associated value is to be returned.
put(Object, Object)
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
void resize(int newCapacity)
newCapacity
- the new capacity, MUST be a power of two.void transfer(FLMHashMap.Entry[] newTable)
public java.lang.Object remove(java.lang.Object key)
key
- key whose mapping is to be removed from the map.
FLMHashMap.Entry removeEntryForKey(java.lang.Object key)
public void clear()
void addEntry(int hash, java.lang.Object key, java.lang.Object value, int bucketIndex)
void createEntry(int hash, java.lang.Object key, java.lang.Object value, int bucketIndex)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |