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

java.lang.Object
  extended by org.millscript.commons.util.map.AbstractIMap<K,V>
All Implemented Interfaces:
org.millscript.commons.alert.AlertDecorator, IMap<K,V>
Direct Known Subclasses:
AbstractISet, AbstractITreeMap, AbstractUMap, IArrayMap, IEmptyMap, IHashMap, IJavaUtilMap, ILinkedHashMap, IMapletArrayMap, ITwoArrayMap

public abstract class AbstractIMap<K,V>
extends java.lang.Object
implements org.millscript.commons.alert.AlertDecorator, IMap<K,V>


Constructor Summary
protected AbstractIMap()
          Constructs a new abstract immutable map with a NullDefault as it's default.
protected AbstractIMap(IMapDefault<K,V> def)
          Constructs a new abstract immutable map with the specified default action.
 
Method Summary
 boolean contains(Maplet<? extends K,? extends V> entry)
          Returns true if this map contains the specified maplet.
 boolean containsAll(IMap<? extends K,? extends V> map)
          Returns true if this map contains all the mappings in the specified map.
 org.millscript.commons.alert.Alert decorate(org.millscript.commons.alert.Alert alert)
           
 boolean equals(java.lang.Object obj)
          Compares this map with the specified object for equality.
 IMapDefault<K,V> getDefault()
          Returns the default used by the IMap.get(Object) method when there is no mapping for a given key.
 int hashCode()
          Returns the integer hash code for this map.
 boolean isEmtpy()
          Returns true if this map has no mappings.
 IList<K> keyList(boolean share)
          Returns a List of the keys in this map.
 IList<Maplet<K,V>> mapletList(boolean share)
          Returns a List of the maplets in this map.
 void setDefault(IMapDefault<K,V> def)
          Sets the default for this map.
protected abstract  IList<K> sharedKeyList()
           
protected abstract  IList<Maplet<K,V>> sharedMapletList()
           
protected abstract  IList<V> sharedValueList()
           
 java.lang.String toString()
           
 IList<V> valueList(boolean share)
          Returns a List of the values in this map.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.millscript.commons.util.IMap
contains, containsKey, containsValue, get, iterator, size
 

Constructor Detail

AbstractIMap

protected AbstractIMap()
Constructs a new abstract immutable map with a NullDefault as it's default.


AbstractIMap

protected AbstractIMap(IMapDefault<K,V> def)
Constructs a new abstract immutable map with the specified default action.

Parameters:
def - the default action for this map
Method Detail

contains

public boolean contains(Maplet<? extends K,? extends V> entry)
Description copied from interface: IMap
Returns true if this map contains the specified maplet.

Specified by:
contains in interface IMap<K,V>
Parameters:
entry - the maplet whose presence to test
Returns:
true if this map contains the specified maplet
See Also:
IMap.contains(org.millscript.commons.util.Maplet)

containsAll

public boolean containsAll(IMap<? extends K,? extends V> map)
Description copied from interface: IMap
Returns true if this map contains all the mappings in the specified map.

Specified by:
containsAll in interface IMap<K,V>
Returns:
true if this map contains the specified maplet
See Also:
IMap.containsAll(org.millscript.commons.util.IMap)

decorate

public org.millscript.commons.alert.Alert decorate(org.millscript.commons.alert.Alert alert)
Specified by:
decorate in interface org.millscript.commons.alert.AlertDecorator
See Also:
AlertDecorator.decorate(org.millscript.commons.alert.Alert)

equals

public boolean equals(java.lang.Object obj)
Description copied from interface: IMap
Compares this map with the specified object for equality. The two maps are considered equal if they both contain the same number of mappings, mapping the same key to the same value.

Specified by:
equals in interface IMap<K,V>
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare with this map for equality
Returns:
true if this map and the specified object are equal and false otherwise
See Also:
IMap.equals(Object)

getDefault

public IMapDefault<K,V> getDefault()
Description copied from interface: IMap
Returns the default used by the IMap.get(Object) method when there is no mapping for a given key.

Specified by:
getDefault in interface IMap<K,V>
Returns:
the default to be used when a key has no mapping.
See Also:
IMap.getDefault()

hashCode

public int hashCode()
Description copied from interface: IMap
Returns the integer hash code for this map. The hash code is calculated as the simple sum of hash codes for each mapping in this map. For any two maps that are equal, they should have the same hash code.

We require a simple sum of Maplet hash codes as different IMap implementations may have different iteration orders. As a result the hash code method must return the same hash code regardless of iteration order.

Specified by:
hashCode in interface IMap<K,V>
Overrides:
hashCode in class java.lang.Object
Returns:
the integer hash code for this map
See Also:
IMap.hashCode()

isEmtpy

public boolean isEmtpy()
Description copied from interface: IMap
Returns true if this map has no mappings.

Specified by:
isEmtpy in interface IMap<K,V>
Returns:
true if this map contains no mappings
See Also:
IMap.isEmtpy()

keyList

public IList<K> keyList(boolean share)
Description copied from interface: IMap
Returns a List of the keys in this map. The ordering of the List will be dependant on the implementation and should match the order of iteration.

Specified by:
keyList 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:
a List of the keys in this map
See Also:
IMap.keyList(boolean)

mapletList

public IList<Maplet<K,V>> mapletList(boolean share)
Description copied from interface: IMap
Returns a List of the maplets in this map. The ordering of the List will be dependant on the implementation and should match the order of iteration.

Specified by:
mapletList 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:
a List of the keys in this map
See Also:
IMap.mapletList(boolean)

setDefault

public void setDefault(IMapDefault<K,V> def)
Description copied from interface: IMap
Sets the default for this map.

Specified by:
setDefault in interface IMap<K,V>
Parameters:
def - the new default
See Also:
IMap.setDefault(org.millscript.commons.util.IMapDefault)

sharedKeyList

protected abstract IList<K> sharedKeyList()

sharedMapletList

protected abstract IList<Maplet<K,V>> sharedMapletList()

sharedValueList

protected abstract IList<V> sharedValueList()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

valueList

public IList<V> valueList(boolean share)
Description copied from interface: IMap
Returns a List of the values in this map. The ordering of the List will be dependant on the implementation and should match the order of iteration.

Specified by:
valueList 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:
a List of the keys in this map
See Also:
IMap.valueList(boolean)


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