|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap<K,V>
ariba.util.core.GrowOnlyHashtable<K,V>
public class GrowOnlyHashtable<K,V>
A version of Hashtable that... - Is built on the code base of the ariba.util.core.Hashtable - Only has methods for querying and putting elements. There is no ability to remove an element. - Has synchronization built in to allow the following: 1) No synchronization is necessary (either internally or externally) on get() operations 2) The put() method is internally synchronized on the this ref. If the program is not concerned about which object ends up in the table after two concurrent puts, no additional synchronization is needed. But if a program desires to ensure that only one is entered, external synchronization can be done on the object to allow synchronization between a retry of a failed get and a put. See the ariba.util.core.InternCharToString for an example of this. -- I believe that a clear() method could also be added without requiring synchronization, however I do not have the time to validate this.
Nested Class Summary | |
---|---|
static class |
GrowOnlyHashtable.IdentityMap<K,V>
|
Nested classes/interfaces inherited from class java.util.AbstractMap |
---|
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
Nested classes/interfaces inherited from interface java.util.Map |
---|
java.util.Map.Entry<K,V> |
Field Summary | |
---|---|
static java.lang.String |
ClassName
|
Constructor Summary | |
---|---|
GrowOnlyHashtable()
Constructs an empty Hashtable. |
|
GrowOnlyHashtable(int initialCapacity)
Constructs a Hashtable capable of holding at least initialCapacity elements before needing to grow. |
Method Summary | |
---|---|
int |
capacity()
Returns the current capacity of the GrowOnlyHashtable. |
boolean |
contains(V element)
Returns true if the GrowOnlyHashtable contains the element. |
boolean |
containsKey(java.lang.Object key)
Returns true if the GrowOnlyHashtable contains the key key. |
int |
count()
Returns the number of elements in the GrowOnlyHashtable. |
java.lang.Object[] |
elementsArray()
Returns an Object array containing the Hashtable's elements. |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet()
|
V |
get(java.lang.Object key)
Returns the element associated with the key. |
boolean |
isEmpty()
Returns true if there are no elements in the GrowOnlyHashtable. |
java.lang.Object[] |
keysArray()
Returns an Object array containing the Hashtable's keys. |
java.util.List<K> |
keysList()
Returns a List containing the Hashtable's keys. |
V |
put(K key,
V element)
Places the key/element pair in the GrowOnlyHashtable. |
int |
size()
Returns the number of elements in the GrowOnlyHashtable. |
java.lang.String |
toString()
|
Methods inherited from class java.util.AbstractMap |
---|
clear, containsValue, equals, hashCode, keySet, putAll, remove, values |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ClassName
Constructor Detail |
---|
public GrowOnlyHashtable()
public GrowOnlyHashtable(int initialCapacity)
Method Detail |
---|
public int count()
public int size()
size
in interface java.util.Map<K,V>
size
in class java.util.AbstractMap<K,V>
public int capacity()
public boolean isEmpty()
isEmpty
in interface java.util.Map<K,V>
isEmpty
in class java.util.AbstractMap<K,V>
public java.lang.Object[] keysArray()
public java.lang.Object[] elementsArray()
public boolean contains(V element)
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<K,V>
containsKey
in class java.util.AbstractMap<K,V>
public V get(java.lang.Object key)
get
in interface java.util.Map<K,V>
get
in class java.util.AbstractMap<K,V>
public V put(K key, V element)
put
in interface java.util.Map<K,V>
put
in class java.util.AbstractMap<K,V>
public java.util.List<K> keysList()
public java.lang.String toString()
toString
in class java.util.AbstractMap<K,V>
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
entrySet
in interface java.util.Map<K,V>
entrySet
in class java.util.AbstractMap<K,V>
Map.entrySet()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |