org.beanfabrics.util
Class OrderPreservingMap<K,V>

java.lang.Object
  extended by org.beanfabrics.util.OrderPreservingMap<K,V>
Type Parameters:
K - the type of keys maintained by this map
V - the type of mapped values
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map<K,V>

public class OrderPreservingMap<K,V>
extends java.lang.Object
implements java.util.Map<K,V>, java.lang.Cloneable

The OrderPreservingMap is a Map that preserves the oder in which the elements where added. It gives access to it's values by a hash key but also by an index.


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
OrderPreservingMap()
           
OrderPreservingMap(java.util.Map<K,V> map, java.util.Collection<K> orderedKeys, java.util.Collection<V> orderedEntries)
           
OrderPreservingMap(OrderPreservingMap<K,V> other)
           
 
Method Summary
 void clear()
           
 java.lang.Object clone()
           
 boolean containsAll(java.util.Collection<V> list)
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Set<java.util.Map.Entry<K,V>> entrySet()
           
 java.util.Set<java.util.Map.Entry<K,V>> entrySetReference()
           
 V get(int i)
           
 V get(java.lang.Object key)
           
 java.util.Collection<V> getAll(java.util.Set<K> keys)
           
 K getKey(int index)
           
 int indexOf(java.lang.Object object)
           
 int indexOfKey(java.lang.Object key)
           
 boolean isEmpty()
           
 java.lang.Object[] keyArray()
           
 java.util.ListIterator<K> keyListIterator(int index)
           
 java.util.Set<K> keySet()
           
 java.util.Set<K> keySetReference()
           
 java.util.ListIterator<V> listIterator(int index)
           
 java.util.Collection<K> orderedKeys()
           
 java.util.Collection<K> orderedKeysReference()
           
 V put(K key, V value)
           
 V put(K key, V value, int toIndex)
           
 void putAll(java.util.Collection<java.util.Map.Entry<K,V>> entries)
           
 void putAll(java.util.Map<? extends K,? extends V> other)
           
 V remove(int index)
           
 V remove(java.lang.Object key)
           
 boolean removeAllKeys(java.util.Set<K> keys)
           
 void reorder(java.util.Collection<K> keys)
           
 void reorder(K[] keys)
           
 void retainAllKeys(java.util.Set<K> keys)
           
 void reverseOrder()
           
 int size()
           
 java.lang.Object[] toArray()
           
 V[] toArray(V[] dest)
           
 java.util.Collection<V> toCollection()
           
 java.util.Collection<V> values()
           
 java.util.Collection<V> valuesReference()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

OrderPreservingMap

public OrderPreservingMap()

OrderPreservingMap

public OrderPreservingMap(OrderPreservingMap<K,V> other)

OrderPreservingMap

public OrderPreservingMap(java.util.Map<K,V> map,
                          java.util.Collection<K> orderedKeys,
                          java.util.Collection<V> orderedEntries)
Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

putAll

public void putAll(java.util.Map<? extends K,? extends V> other)
Specified by:
putAll in interface java.util.Map<K,V>

putAll

public void putAll(java.util.Collection<java.util.Map.Entry<K,V>> entries)

put

public V put(K key,
             V value)
Specified by:
put in interface java.util.Map<K,V>

put

public V put(K key,
             V value,
             int toIndex)

keySet

public java.util.Set<K> keySet()
Specified by:
keySet in interface java.util.Map<K,V>

keySetReference

public java.util.Set<K> keySetReference()

keyArray

public java.lang.Object[] keyArray()

orderedKeys

public java.util.Collection<K> orderedKeys()

orderedKeysReference

public java.util.Collection<K> orderedKeysReference()

entrySet

public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
Specified by:
entrySet in interface java.util.Map<K,V>

entrySetReference

public java.util.Set<java.util.Map.Entry<K,V>> entrySetReference()

values

public java.util.Collection<V> values()
Specified by:
values in interface java.util.Map<K,V>

valuesReference

public java.util.Collection<V> valuesReference()

get

public V get(java.lang.Object key)
Specified by:
get in interface java.util.Map<K,V>

get

public V get(int i)

getKey

public K getKey(int index)

getAll

public java.util.Collection<V> getAll(java.util.Set<K> keys)

indexOfKey

public int indexOfKey(java.lang.Object key)

indexOf

public int indexOf(java.lang.Object object)

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map<K,V>

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map<K,V>

containsAll

public boolean containsAll(java.util.Collection<V> list)

reverseOrder

public void reverseOrder()

reorder

public void reorder(java.util.Collection<K> keys)

reorder

public void reorder(K[] keys)

remove

public V remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map<K,V>

remove

public V remove(int index)

removeAllKeys

public boolean removeAllKeys(java.util.Set<K> keys)

retainAllKeys

public void retainAllKeys(java.util.Set<K> keys)

clear

public void clear()
Specified by:
clear in interface java.util.Map<K,V>

size

public int size()
Specified by:
size in interface java.util.Map<K,V>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map<K,V>

toArray

public V[] toArray(V[] dest)

toArray

public java.lang.Object[] toArray()

toCollection

public java.util.Collection<V> toCollection()

listIterator

public java.util.ListIterator<V> listIterator(int index)

keyListIterator

public java.util.ListIterator<K> keyListIterator(int index)