|
|||||||||
| 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
|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Field Summary | |
|---|---|
static 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(Object key)
Returns true if the GrowOnlyHashtable contains the key key. |
int |
count()
Returns the number of elements in the GrowOnlyHashtable. |
V[] |
elementsArray()
Returns an Object array containing the Hashtable's elements. |
Set<Map.Entry<K,V>> |
entrySet()
|
V |
get(Object key)
Returns the element associated with the key. |
boolean |
isEmpty()
Returns true if there are no elements in the GrowOnlyHashtable. |
K[] |
keysArray()
Returns an Object array containing the Hashtable's keys. |
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. |
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 String ClassName
| Constructor Detail |
|---|
public GrowOnlyHashtable()
public GrowOnlyHashtable(int initialCapacity)
| Method Detail |
|---|
public int count()
public int size()
size in interface Map<K,V>size in class AbstractMap<K,V>public int capacity()
public boolean isEmpty()
isEmpty in interface Map<K,V>isEmpty in class AbstractMap<K,V>public K[] keysArray()
public V[] elementsArray()
public boolean contains(V element)
public boolean containsKey(Object key)
containsKey in interface Map<K,V>containsKey in class AbstractMap<K,V>public V get(Object key)
get in interface Map<K,V>get in class AbstractMap<K,V>
public V put(K key,
V element)
put in interface Map<K,V>put in class AbstractMap<K,V>public List<K> keysList()
public String toString()
toString in class AbstractMap<K,V>public Set<Map.Entry<K,V>> entrySet()
entrySet in interface Map<K,V>entrySet in class AbstractMap<K,V>Map.entrySet()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||