com.myjavatools.lib.foundation
Class KeyValueArrayMap<X,Y>

java.lang.Object
  extended by java.util.AbstractMap<X,Y>
      extended by com.myjavatools.lib.foundation.KeyValueArrayMap<X,Y>
All Implemented Interfaces:
java.util.Map<X,Y>

public class KeyValueArrayMap<X,Y>
extends java.util.AbstractMap<X,Y>

KeyValueArrayMap is a helper class that implements Map which is based on a key/value array Note that this class does not take any additional memory; lazy evaluation uses only the array provided. It is very inefficient; to improve performance, you will have to create a copy of the Map using a concrete Map implementation from Collections framework.

Since:
5.0
Version:
6.0 05/04/06
See Also:
Maps, Map

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
KeyValueArrayMap(java.lang.Object... array)
          constructor
 
Method Summary
 boolean containsKey(java.lang.Object x)
          Returns true if this map contains a mapping for the specified key.
 java.util.Set<java.util.Map.Entry<X,Y>> entrySet()
          Returns a set view of the mappings contained in this map.
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsValue, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KeyValueArrayMap

public KeyValueArrayMap(java.lang.Object... array)
constructor

Parameters:
array - Object... even elements contains keys, odd elements contain values
Method Detail

containsKey

public boolean containsKey(java.lang.Object x)
Returns true if this map contains a mapping for the specified key.

Specified by:
containsKey in interface java.util.Map<X,Y>
Overrides:
containsKey in class java.util.AbstractMap<X,Y>
Parameters:
x - key whose presence in this map is to be tested.
Returns:
true if this map contains a mapping for the specified key.

entrySet

public java.util.Set<java.util.Map.Entry<X,Y>> entrySet()
Returns a set view of the mappings contained in this map.

Specified by:
entrySet in interface java.util.Map<X,Y>
Specified by:
entrySet in class java.util.AbstractMap<X,Y>
Returns:
a set view of the mappings contained in this map. Implementation note. Actually no large object is created; the returned set is a lazy evaluation implementation of Set.