org.millscript.commons.util.map
Class EArrayMap<K,V>

java.lang.Object
  extended by org.millscript.commons.util.map.AbstractIMap<K,V>
      extended by org.millscript.commons.util.map.AbstractUMap<K,V>
          extended by org.millscript.commons.util.map.AbstractEMap<K,V>
              extended by org.millscript.commons.util.map.EArrayMap<K,V>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, org.millscript.commons.alert.AlertDecorator, EMap<K,V>, IMap<K,V>, UMap<K,V>

public class EArrayMap<K,V>
extends AbstractEMap<K,V>
implements java.lang.Cloneable, java.io.Serializable

This class provides a mutable Map implementation which is backed by an Object array containing alternate name-value objects.

See Also:
Serialized Form

Nested Class Summary
static class EArrayMap.ArrayMapMapIterator<K,V>
          This class implements a map iterator which iterates over an array containing alternating key-value objects, sharing the backing store with it's enclosing mutable map.
 
Constructor Summary
EArrayMap()
          Constructs a new, emtpy mutable array map.
EArrayMap(java.lang.Object[] objects)
          Constructs a new mutable array map with a copy of the specified backing array containing alternate name-value objects.
 
Method Summary
 java.lang.Object clone()
           
 boolean contains(K key, V value)
          Returns true if this map contains a mapping from the specified key to the specified value.
 boolean containsKey(K key)
          Returns true if this map contains an entry for the specified key.
 boolean containsValue(V value)
          Returns true if this map contains an entry with the specified value.
 V get(K key)
          Returns the value associated with the specified key, or the default value if no such mapping exists.
 void insert(K key, V value)
          Inserts the specified key-value pair into this map, associating the key with the value.
 void insertAll(IMap<? extends K,? extends V> map)
          Inserts all the mappings from the specified map into this map.
 MapIterator<K,V> iterator(boolean share)
          Returns an iterator over the mappings in this map.
 void remove(K key, V value)
          Removes the specified key-value pair from this map.
 void removeAll()
          Removes all the mappings from this map.
 void removeKey(K key)
          Removes the mapping for the specified key.
 void removeValue(V value)
          Removes any mappings from this map which map to the specified value.
protected  IList<K> sharedKeyList()
           
protected  IList<Maplet<K,V>> sharedMapletList()
           
protected  IList<V> sharedValueList()
           
 int size()
          Returns the number of mappings defined in this map.
 void update(K key, V value)
          Updates the mapping for the specified key with the specified value, changing the previous value.
 
Methods inherited from class org.millscript.commons.util.map.AbstractEMap
insert, remove, removeAll
 
Methods inherited from class org.millscript.commons.util.map.AbstractUMap
update, updateAll
 
Methods inherited from class org.millscript.commons.util.map.AbstractIMap
contains, containsAll, decorate, equals, getDefault, hashCode, isEmtpy, keyList, mapletList, setDefault, toString, valueList
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.millscript.commons.util.UMap
update, updateAll
 
Methods inherited from interface org.millscript.commons.util.IMap
contains, containsAll, equals, getDefault, hashCode, isEmtpy, keyList, mapletList, setDefault, valueList
 

Constructor Detail

EArrayMap

public EArrayMap()
Constructs a new, emtpy mutable array map.


EArrayMap

public EArrayMap(java.lang.Object[] objects)
Constructs a new mutable array map with a copy of the specified backing array containing alternate name-value objects.

Parameters:
objects - the backing array of alternate name-value objects to copy
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException
See Also:
Object.clone()

contains

public boolean contains(K key,
                        V value)
Description copied from interface: IMap
Returns true if this map contains a mapping from the specified key to the specified value.

Specified by:
contains in interface IMap<K,V>
Parameters:
key - the key whose presence to test
value - the value which must match that stored against the specified key
Returns:
true if this map contains a mapping for the specified key-value combination
See Also:
IMap.contains(java.lang.Object, java.lang.Object)

containsKey

public boolean containsKey(K key)
Description copied from interface: IMap
Returns true if this map contains an entry for the specified key.

Specified by:
containsKey in interface IMap<K,V>
Parameters:
key - the key whose presence to test
Returns:
true if this map contains a mapping for the specified key
See Also:
IMap.containsKey(java.lang.Object)

containsValue

public boolean containsValue(V value)
Description copied from interface: IMap
Returns true if this map contains an entry with the specified value.

Specified by:
containsValue in interface IMap<K,V>
Parameters:
value - the value whose presence to test
Returns:
true if this map contains a mapping with the specified value
See Also:
IMap.containsValue(java.lang.Object)

get

public V get(K key)
Description copied from interface: IMap
Returns the value associated with the specified key, or the default value if no such mapping exists.

Specified by:
get in interface IMap<K,V>
Parameters:
key - the key whose associated value to return
Returns:
the value associated with the specified key, or the default value if there is no mapping for the key
See Also:
IMap.get(java.lang.Object)

insert

public void insert(K key,
                   V value)
Description copied from interface: EMap
Inserts the specified key-value pair into this map, associating the key with the value.

Specified by:
insert in interface EMap<K,V>
Parameters:
key - the key to associate the value with
value - the value to associate the key with
See Also:
EMap.insert(java.lang.Object, java.lang.Object)

insertAll

public void insertAll(IMap<? extends K,? extends V> map)
Description copied from interface: EMap
Inserts all the mappings from the specified map into this map.

Specified by:
insertAll in interface EMap<K,V>
Overrides:
insertAll in class AbstractEMap<K,V>
Parameters:
map - the map to copy all mappings from
See Also:
EMap.insertAll(org.millscript.commons.util.IMap)

iterator

public MapIterator<K,V> iterator(boolean share)
Description copied from interface: IMap
Returns an iterator over the mappings in this map. The order of iteration is implementation dependant and should follow any ordering the implementation provides.

Specified by:
iterator in interface IMap<K,V>
Parameters:
share - if true this instances backing store should be shared with the returned list, otherwise any backing store will be copied.
Returns:
an iterator over this maps mappings
See Also:
IMap.iterator(boolean)

remove

public void remove(K key,
                   V value)
Description copied from interface: EMap
Removes the specified key-value pair from this map. For this removal to be successful the specified mapping must exist in this map.

Specified by:
remove in interface EMap<K,V>
Parameters:
key - the key to remove from this map if it is associated with the specified value
value - the value to remove from this map if it is associated with the specified key
See Also:
EMap.remove(java.lang.Object, java.lang.Object)

removeAll

public void removeAll()
Description copied from interface: EMap
Removes all the mappings from this map.

Specified by:
removeAll in interface EMap<K,V>
See Also:
EMap.removeAll()

removeKey

public void removeKey(K key)
Description copied from interface: EMap
Removes the mapping for the specified key.

Specified by:
removeKey in interface EMap<K,V>
Parameters:
key - the key to remove from this map
See Also:
EMap.removeKey(java.lang.Object)

removeValue

public void removeValue(V value)
Description copied from interface: EMap
Removes any mappings from this map which map to the specified value.

Specified by:
removeValue in interface EMap<K,V>
Parameters:
value - the value to remove from this map
See Also:
EMap.removeValue(java.lang.Object)

sharedKeyList

protected IList<K> sharedKeyList()
Specified by:
sharedKeyList in class AbstractIMap<K,V>
See Also:
AbstractIMap.sharedKeyList()

sharedMapletList

protected IList<Maplet<K,V>> sharedMapletList()
Specified by:
sharedMapletList in class AbstractIMap<K,V>
See Also:
AbstractIMap.sharedMapletList()

sharedValueList

protected IList<V> sharedValueList()
Specified by:
sharedValueList in class AbstractIMap<K,V>
See Also:
AbstractIMap.sharedValueList()

size

public int size()
Description copied from interface: IMap
Returns the number of mappings defined in this map.

Specified by:
size in interface IMap<K,V>
Returns:
the number of mappings in this map
See Also:
IMap.size()

update

public void update(K key,
                   V value)
Description copied from interface: UMap
Updates the mapping for the specified key with the specified value, changing the previous value.

Specified by:
update in interface UMap<K,V>
Parameters:
key - the key to associate the value with
value - the value to associate the key with
See Also:
UMap.update(java.lang.Object, java.lang.Object)


Copyright © 2005-2007 Open World Ltd. All Rights Reserved.