|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.enough.polish.util.HashMap<K,V>
K - when you use the enough-polish-client-java5.jar you can parameterize the HashMap, e.g. HashMap<User, Message> = new HashMap<User, Message>(10);V - when you use the enough-polish-client-java5.jar you can parameterize the HashMap, e.g. HashMap<User, Message> = new HashMap<User, Message>(10);public class HashMap<K,V>
Provides the functionality of the J2SE java.util.HashMap for J2ME applications.
In contrast to the java.util.Hashtable (which is available on J2ME platforms), this implementation is not synchronized and faster.
This implementation uses chains for resolving collisions, that means when a key-value pair has the same hash code as a previous inserted item, the new item is linked to the previous item. Depending on your situation The OpenAddressingHashMap implementation might be better, especially when you do not have many collisions (items with the same hash code).
Copyright (c) Enough Software 2005 - 2009
history
30-Nov-2005 - rob creation
| Field Summary | |
|---|---|
static int |
DEFAULT_INITIAL_CAPACITY
The default capacity is 16, this results in an internal size of 21 |
static int |
DEFAULT_LOAD_FACTOR
The default load factor is 75 (=75%), so the HashMap is increased when 75% of it's capacity is reached |
| Constructor Summary | |
|---|---|
HashMap()
Creates a new HashMap with the default initial capacity 16 and a load factor of 75%. |
|
HashMap(int initialCapacity)
Creates a new HashMap with the specified initial capacity. |
|
HashMap(int initialCapacity,
int loadFactor)
Creates a new HashMap with the specified initial capacity and the specified load factor. |
|
| Method Summary | |
|---|---|
void |
clear()
Removes all elements from this map. |
boolean |
containsKey(K key)
Checks if a value has been stored in this map. |
boolean |
containsValue(V value)
Checks the given value has been stored in this map. |
V |
get(K key)
Gets the value that has been stored for the specified key. |
boolean |
isEmpty()
Determines whether this map is empty. |
Object[] |
keys()
Retrieves all keys that have been stored in this map. |
K[] |
keys(K[] objects)
Retrieves all keys that have been stored in this map. |
Iterator |
keysIterator()
Iterates over the keys of this map. |
V |
put(K key,
V value)
Adds a key-value pair to this map. |
V |
remove(K key)
Removes the key-value pair from this map. |
int |
size()
The size of this map. |
String |
toString()
Returns String containing the String representations of all objects of this map. |
Object[] |
values()
Retrieves all values that have been stored in this map. |
V[] |
values(V[] objects)
Retrieves all values that have been stored in this map. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_INITIAL_CAPACITY
public static final int DEFAULT_LOAD_FACTOR
| Constructor Detail |
|---|
public HashMap()
public HashMap(int initialCapacity)
initialCapacity - the initial number of elements that this map can hold without needing to
increase it's internal size. Must not be 0.
public HashMap(int initialCapacity,
int loadFactor)
initialCapacity - the initial number of elements that this map can hold without needing to
increase it's internal size.loadFactor - the loadfactor in percent, a number between 0 and 100. When the loadfactor is 100,
the size of this map is only increased after all slots have been filled.
IllegalArgumentException - when the initialCapacity is less than 1| Method Detail |
|---|
public V put(K key,
V value)
Map
put in interface Map<K,V>key - the keyvalue - the value
public V get(K key)
Map
get in interface Map<K,V>key - the key
public V remove(K key)
Map
remove in interface Map<K,V>key - the key
public boolean isEmpty()
Map
isEmpty in interface Map<K,V>public int size()
Map
size in interface Map<K,V>public boolean containsKey(K key)
Map
containsKey in interface Map<K,V>key - the key
public boolean containsValue(V value)
Map
containsValue in interface Map<K,V>value - the value
public void clear()
Map
clear in interface Map<K,V>public Object[] values()
Map
values in interface Map<K,V>public V[] values(V[] objects)
Map
values in interface Map<K,V>objects - the typed array in which the elements are stored
public Object[] keys()
Map
keys in interface Map<K,V>public K[] keys(K[] objects)
Map
keys in interface Map<K,V>objects - the typed array in which the keys are stored
public String toString()
toString in class Objectpublic Iterator keysIterator()
Map
keysIterator in interface Map<K,V>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||