public class CharKeyOpenHashMap extends AbstractCharKeyMap implements CharKeyMap, java.lang.Cloneable, java.io.Serializable
CharKeyChainedHashMap,
Map,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
private class |
CharKeyOpenHashMap.KeySet |
private class |
CharKeyOpenHashMap.ValueCollection |
| Modifier and Type | Field and Description |
|---|---|
private CharSet |
ckeys
A set view of the keys of this map.
|
private java.util.Collection |
cvalues
A collection view of the values of this map.
|
static int |
DEFAULT_CAPACITY
The default capacity of this map.
|
static int |
DEFAULT_GROWTH_CHUNK
The default chunk size with which to increase the capacity of this map.
|
static double |
DEFAULT_GROWTH_FACTOR
The default factor with which to increase the capacity of this map.
|
private static int |
DEFAULT_GROWTH_POLICY
The default growth policy of this map.
|
static double |
DEFAULT_LOAD_FACTOR
The default load factor of this map.
|
private static byte |
EMPTY |
private int |
expandAt
The next size at which to expand the data[].
|
private static int |
GROWTH_POLICY_ABSOLUTE
Constant indicating absolute growth policy.
|
private static int |
GROWTH_POLICY_RELATIVE
Constant indicating relative growth policy.
|
private int |
growthChunk
The growth chunk size of this map, if the growth policy is
absolute.
|
private double |
growthFactor
The growth factor of this map, if the growth policy is
relative.
|
private int |
growthPolicy
The growth policy of this map (0 is relative growth, 1 is absolute growth).
|
private CharHashFunction |
keyhash
The hash function used to hash keys in this map.
|
private char[] |
keys
The keys of this map.
|
private double |
loadFactor
The load factor of this map.
|
private static byte |
OCCUPIED |
private static byte |
REMOVED |
private int |
size
The size of this map.
|
private byte[] |
states
The states of each cell in the keys[] and values[].
|
private int |
used
The number of entries in use (removed or occupied).
|
private java.lang.Object[] |
values
The values of this map.
|
| Modifier | Constructor and Description |
|---|---|
|
CharKeyOpenHashMap()
Creates a new hash map with capacity 11, a relative
growth factor of 1.0, and a load factor of 75%.
|
|
CharKeyOpenHashMap(CharHashFunction keyhash)
Creates a new hash map with capacity 11, a relative
growth factor of 1.0, and a load factor of 75%.
|
|
CharKeyOpenHashMap(CharHashFunction keyhash,
double loadFactor)
Creates a new hash map with a capacity of 11, a relative
growth factor of 1.0, and a specified load factor.
|
|
CharKeyOpenHashMap(CharHashFunction keyhash,
int capacity)
Creates a new hash map with a specified capacity, a relative
growth factor of 1.0, and a load factor of 75%.
|
|
CharKeyOpenHashMap(CharHashFunction keyhash,
int capacity,
double loadFactor)
Creates a new hash map with a specified capacity and
load factor, and a relative growth factor of 1.0.
|
|
CharKeyOpenHashMap(CharHashFunction keyhash,
int capacity,
double loadFactor,
double growthFactor)
Creates a new hash map with a specified capacity,
load factor, and relative growth factor.
|
|
CharKeyOpenHashMap(CharHashFunction keyhash,
int capacity,
double loadFactor,
int growthChunk)
Creates a new hash map with a specified capacity,
load factor, and absolute growth factor.
|
private |
CharKeyOpenHashMap(CharHashFunction keyhash,
int capacity,
int growthPolicy,
double growthFactor,
int growthChunk,
double loadFactor) |
|
CharKeyOpenHashMap(CharKeyMap map)
Creates a new hash map with the same mappings as a specified map.
|
|
CharKeyOpenHashMap(double loadFactor)
Creates a new hash map with a capacity of 11, a relative
growth factor of 1.0, and a specified load factor.
|
|
CharKeyOpenHashMap(int capacity)
Creates a new hash map with a specified capacity, a relative
growth factor of 1.0, and a load factor of 75%.
|
|
CharKeyOpenHashMap(int capacity,
double loadFactor)
Creates a new hash map with a specified capacity and
load factor, and a relative growth factor of 1.0.
|
|
CharKeyOpenHashMap(int capacity,
double loadFactor,
double growthFactor)
Creates a new hash map with a specified capacity,
load factor, and relative growth factor.
|
|
CharKeyOpenHashMap(int capacity,
double loadFactor,
int growthChunk)
Creates a new hash map with a specified capacity,
load factor, and absolute growth factor.
|
private |
CharKeyOpenHashMap(int capacity,
int growthPolicy,
double growthFactor,
int growthChunk,
double loadFactor) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears this map.
|
java.lang.Object |
clone()
Returns a clone of this hash map.
|
boolean |
containsKey(char key)
Indicates whether this map contains a mapping from a specified
key.
|
boolean |
containsValue(java.lang.Object value)
Indicates whether this map contains a mapping to a specified
value.
|
private void |
ensureCapacity(int elements) |
CharKeyMapIterator |
entries()
Returns an iterator over the entries of this map.
|
java.lang.Object |
get(char key)
Maps a specified key to a value.
|
boolean |
isEmpty()
Indicates whether this map is empty.
|
CharSet |
keySet()
Returns a set view of the keys of this map.
|
java.lang.Object |
put(char key,
java.lang.Object value)
Adds a mapping from a specified key to a specified value to
this map.
|
private void |
readObject(java.io.ObjectInputStream s) |
java.lang.Object |
remove(char key)
Removes the mapping from a specified key from this map.
|
int |
size()
Returns the size of this map.
|
java.util.Collection |
values()
Returns a collection view of the values in this map.
|
private void |
writeObject(java.io.ObjectOutputStream s) |
equals, hashCode, putAll, toString, trimToSizefinalize, getClass, notify, notifyAll, wait, wait, waitequals, hashCode, putAllprivate static final int GROWTH_POLICY_RELATIVE
private static final int GROWTH_POLICY_ABSOLUTE
private static final int DEFAULT_GROWTH_POLICY
public static final double DEFAULT_GROWTH_FACTOR
public static final int DEFAULT_GROWTH_CHUNK
public static final int DEFAULT_CAPACITY
public static final double DEFAULT_LOAD_FACTOR
private CharHashFunction keyhash
private int size
private transient char[] keys
private transient java.lang.Object[] values
private transient byte[] states
private static final byte EMPTY
private static final byte OCCUPIED
private static final byte REMOVED
private transient int used
private int growthPolicy
private double growthFactor
private int growthChunk
private double loadFactor
private int expandAt
private transient CharSet ckeys
private transient java.util.Collection cvalues
private CharKeyOpenHashMap(CharHashFunction keyhash, int capacity, int growthPolicy, double growthFactor, int growthChunk, double loadFactor)
private CharKeyOpenHashMap(int capacity,
int growthPolicy,
double growthFactor,
int growthChunk,
double loadFactor)
public CharKeyOpenHashMap()
public CharKeyOpenHashMap(CharKeyMap map)
map - the map whose mappings to put into the new map.java.lang.NullPointerException - if map is null.public CharKeyOpenHashMap(int capacity)
capacity - the initial capacity of the map.java.lang.IllegalArgumentException - if capacity is negative.public CharKeyOpenHashMap(double loadFactor)
loadFactor - the load factor of the map.java.lang.IllegalArgumentException - if capacity is negative;
if loadFactor is not positive.public CharKeyOpenHashMap(int capacity,
double loadFactor)
capacity - the initial capacity of the map.loadFactor - the load factor of the map.java.lang.IllegalArgumentException - if capacity is negative;
if loadFactor is not positive.public CharKeyOpenHashMap(int capacity,
double loadFactor,
double growthFactor)
The map capacity increases to capacity()*(1+growthFactor). This strategy is good for avoiding many capacity increases, but the amount of wasted memory is approximately the size of the map.
capacity - the initial capacity of the map.loadFactor - the load factor of the map.growthFactor - the relative amount with which to increase the
the capacity when a capacity increase is needed.java.lang.IllegalArgumentException - if capacity is negative;
if loadFactor is not positive;
if growthFactor is not positive.public CharKeyOpenHashMap(int capacity,
double loadFactor,
int growthChunk)
The map capacity increases to capacity()+growthChunk. This strategy is good for avoiding wasting memory. However, an overhead is potentially introduced by frequent capacity increases.
capacity - the initial capacity of the map.loadFactor - the load factor of the map.growthChunk - the absolute amount with which to increase the
the capacity when a capacity increase is needed.java.lang.IllegalArgumentException - if capacity is negative;
if loadFactor is not positive;
if growthChunk is not positive.public CharKeyOpenHashMap(CharHashFunction keyhash)
keyhash - the hash function to use when hashing keys.java.lang.NullPointerException - if keyhash is null.public CharKeyOpenHashMap(CharHashFunction keyhash, int capacity)
keyhash - the hash function to use when hashing keys.capacity - the initial capacity of the map.java.lang.IllegalArgumentException - if capacity is negative.java.lang.NullPointerException - if keyhash is null.public CharKeyOpenHashMap(CharHashFunction keyhash, double loadFactor)
keyhash - the hash function to use when hashing keys.loadFactor - the load factor of the map.java.lang.IllegalArgumentException - if capacity is negative;
if loadFactor is not positive.java.lang.NullPointerException - if keyhash is null.public CharKeyOpenHashMap(CharHashFunction keyhash, int capacity, double loadFactor)
keyhash - the hash function to use when hashing keys.capacity - the initial capacity of the map.loadFactor - the load factor of the map.java.lang.IllegalArgumentException - if capacity is negative;
if loadFactor is not positive.java.lang.NullPointerException - if keyhash is null.public CharKeyOpenHashMap(CharHashFunction keyhash, int capacity, double loadFactor, double growthFactor)
The map capacity increases to capacity()*(1+growthFactor). This strategy is good for avoiding many capacity increases, but the amount of wasted memory is approximately the size of the map.
keyhash - the hash function to use when hashing keys.capacity - the initial capacity of the map.loadFactor - the load factor of the map.growthFactor - the relative amount with which to increase the
the capacity when a capacity increase is needed.java.lang.IllegalArgumentException - if capacity is negative;
if loadFactor is not positive;
if growthFactor is not positive.java.lang.NullPointerException - if keyhash is null.public CharKeyOpenHashMap(CharHashFunction keyhash, int capacity, double loadFactor, int growthChunk)
The map capacity increases to capacity()+growthChunk. This strategy is good for avoiding wasting memory. However, an overhead is potentially introduced by frequent capacity increases.
keyhash - the hash function to use when hashing keys.capacity - the initial capacity of the map.loadFactor - the load factor of the map.growthChunk - the absolute amount with which to increase the
the capacity when a capacity increase is needed.java.lang.IllegalArgumentException - if capacity is negative;
if loadFactor is not positive;
if growthChunk is not positive.java.lang.NullPointerException - if keyhash is null.private void ensureCapacity(int elements)
public CharSet keySet()
CharKeyMapkeySet in interface CharKeyMappublic java.lang.Object put(char key,
java.lang.Object value)
CharKeyMapput in interface CharKeyMapkey - the key of the mapping to add to this map.value - the value of the mapping to add to this map.public java.util.Collection values()
CharKeyMapvalues in interface CharKeyMappublic java.lang.Object clone()
clone in class java.lang.Objectpublic CharKeyMapIterator entries()
CharKeyMapentries in interface CharKeyMappublic void clear()
CharKeyMapclear in interface CharKeyMapclear in class AbstractCharKeyMappublic boolean containsKey(char key)
CharKeyMapcontainsKey in interface CharKeyMapcontainsKey in class AbstractCharKeyMapkey - the key to test for.public boolean containsValue(java.lang.Object value)
CharKeyMapcontainsValue in interface CharKeyMapcontainsValue in class AbstractCharKeyMapvalue - the value to test for.public java.lang.Object get(char key)
CharKeyMapget in interface CharKeyMapget in class AbstractCharKeyMapkey - the key to map to a value.public boolean isEmpty()
CharKeyMapisEmpty in interface CharKeyMapisEmpty in class AbstractCharKeyMappublic java.lang.Object remove(char key)
CharKeyMapremove in interface CharKeyMapremove in class AbstractCharKeyMapkey - the key whose mapping to remove from this map.public int size()
CharKeyMapsize in interface CharKeyMapsize in class AbstractCharKeyMapprivate void writeObject(java.io.ObjectOutputStream s)
throws java.io.IOException
java.io.IOExceptionprivate void readObject(java.io.ObjectInputStream s)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOExceptionjava.lang.ClassNotFoundException