oracle.adf.view.faces.util
Class ArrayMap

java.lang.Object
  extended byjava.util.AbstractMap
      extended byoracle.adf.view.faces.util.ArrayMap
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map
Direct Known Subclasses:
PropertyArrayMap

public class ArrayMap
extends java.util.AbstractMap
implements java.lang.Cloneable

A Map implementation that stores its contents in a single array. This approach is significantly faster for small sets of data than the use of a HashMap or Hashtable, though potentially much slower for very large sets.

ArrayMap is optimized for many-reads-few-write. In particular, it reallocates its array on any insertion or deletion.

ArrayMap also includes a series of static methods for managing the Object array. These may be used in place of instantiating an ArrayMap for clients that don't need a Map implementation. Clients using these methods must be careful to store the returned Object array on any mutator method. They also must provide their own synchronization, if needed. When using these static methods, clients can opt to search for objects by identity (via getByIdentity()) instead of equality, while the static get() method will try identity before equality. This latter approach is extremely fast but still safe for retrieval of Strings that have all been interned, especially if misses are infrequent (since misses do require a scan using Object.equals()). It's worth remembering that String constants are always interned, as required by the language specification.


Nested Class Summary
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
ArrayMap()
          Creates an empty ArrayMap, preallocating nothing.
ArrayMap(int size)
          Creates an ArrayMap, preallocating for a certain size.
ArrayMap(int size, int increment)
          Creates an ArrayMap, preallocating for a certain size.
 
Method Summary
 void clear()
          Removes all elements from the ArrayMap.
 java.lang.Object clone()
          Clones the map.
 boolean containsKey(java.lang.Object value)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set entrySet()
           
 java.lang.Object get(java.lang.Object key)
           
static java.lang.Object get(java.lang.Object[] array, java.lang.Object key)
          Gets the object stored with the given key.
static java.lang.Object getByEquality(java.lang.Object[] array, java.lang.Object key)
          Gets the object stored with the given key, using only object equality.
 java.lang.Object getByIdentity(java.lang.Object key)
           
static java.lang.Object getByIdentity(java.lang.Object[] array, java.lang.Object key)
          Gets the object stored with the given key, using only object identity.
 java.lang.Object getKey(int index)
          Returns the key at a specific index in the map.
static java.util.Iterator getKeys(java.lang.Object[] array)
          Returns an Iterator of keys in the array.
 java.lang.Object getValue(int index)
          Returns the value at a specific index in the map.
static java.util.Iterator getValues(java.lang.Object[] array)
          Returns an Iterator of values in the array.
 java.util.Iterator keys()
          Returns an enumeration of the keys in this map.
static java.lang.Object[] put(java.lang.Object[] array, java.lang.Object key, java.lang.Object value)
          Adds the key/value pair to the array, returning a new array if necessary.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 java.lang.Object remove(java.lang.Object key)
           
static java.lang.Object[] remove(java.lang.Object[] array, java.lang.Object key)
          Removes the value for the key from the array, returning a new array if necessary.
static java.lang.Object[] remove(java.lang.Object[] array, java.lang.Object key, boolean reallocate)
          Removes the value for the key from the array, returning a new array if necessary.
 int size()
           
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, isEmpty, keySet, putAll, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArrayMap

public ArrayMap()
Creates an empty ArrayMap, preallocating nothing.


ArrayMap

public ArrayMap(int size)
Creates an ArrayMap, preallocating for a certain size.

Parameters:
size - the number of elements to pre-allocate for

ArrayMap

public ArrayMap(int size,
                int increment)
Creates an ArrayMap, preallocating for a certain size.

Parameters:
size - the number of elements to pre-allocate for
increment - the number of additional elements to allocate for when overruning
Method Detail

getKey

public java.lang.Object getKey(int index)
Returns the key at a specific index in the map.


getValue

public java.lang.Object getValue(int index)
Returns the value at a specific index in the map.


get

public static java.lang.Object get(java.lang.Object[] array,
                                   java.lang.Object key)
Gets the object stored with the given key. Scans first by object identity, then by object equality.


getByIdentity

public static java.lang.Object getByIdentity(java.lang.Object[] array,
                                             java.lang.Object key)
Gets the object stored with the given key, using only object identity.


getByEquality

public static java.lang.Object getByEquality(java.lang.Object[] array,
                                             java.lang.Object key)
Gets the object stored with the given key, using only object equality.


put

public static java.lang.Object[] put(java.lang.Object[] array,
                                     java.lang.Object key,
                                     java.lang.Object value)
Adds the key/value pair to the array, returning a new array if necessary.


remove

public static java.lang.Object[] remove(java.lang.Object[] array,
                                        java.lang.Object key)
Removes the value for the key from the array, returning a new array if necessary.


remove

public static java.lang.Object[] remove(java.lang.Object[] array,
                                        java.lang.Object key,
                                        boolean reallocate)
Removes the value for the key from the array, returning a new array if necessary.


size

public int size()
Specified by:
size in interface java.util.Map

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map

containsKey

public boolean containsKey(java.lang.Object value)
Specified by:
containsKey in interface java.util.Map

keys

public java.util.Iterator keys()
Returns an enumeration of the keys in this map. the Iterator methods on the returned object to fetch the elements sequentially.

Returns:
an enumeration of the values in this dictionary.
Since:
JDK1.0
See Also:
java.util.Map#keys(), Iterator

getKeys

public static java.util.Iterator getKeys(java.lang.Object[] array)
Returns an Iterator of keys in the array.


getValues

public static java.util.Iterator getValues(java.lang.Object[] array)
Returns an Iterator of values in the array.


clone

public java.lang.Object clone()
Clones the map.


entrySet

public java.util.Set entrySet()
Specified by:
entrySet in interface java.util.Map

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map

getByIdentity

public java.lang.Object getByIdentity(java.lang.Object key)

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map

clear

public void clear()
Removes all elements from the ArrayMap.

Specified by:
clear in interface java.util.Map


Copyright © 2003-2007 Oracle Corporation. All Rights Reserved.