gate.util
Class SimpleMapImpl

java.lang.Object
  |
  +--gate.util.SimpleMapImpl
All Implemented Interfaces:
Cloneable, Map, Serializable
Direct Known Subclasses:
SimpleFeatureMapImpl

class SimpleMapImpl
extends Object
implements Map, Cloneable, Serializable

Implements Map interface in using less memory. Very simple but usefull for small number of items on it.

See Also:
Serialized Form

Inner Class Summary
private static class SimpleMapImpl.Entry
          Auxiliary classes needed for the support of entrySet() method
 
Inner classes inherited from class java.util.Map
Map.Entry
 
Field Summary
(package private)  int capacity
          The capacity of the map
(package private)  int count
          The current number of elements of the map
(package private) static Object nullKey
          the Object instance that will represent the NULL keys in the map
(package private) static long serialVersionUID
          Freeze the serialization UID.
(package private)  Object[] theKeys
          Array keeping the keys of the entries in the map.
static HashMap theKeysHere
          the static 'all keys' collection
(package private)  Object[] theValues
          Array keeping the values of the entries in the map.
 
Constructor Summary
SimpleMapImpl()
          Constructor
 
Method Summary
(package private) static void ()
          additional static members initialization
 void clear()
          clear the map
 Object clone()
          Create a copy of the map including the data.
 boolean containsKey(Object key)
          return true if the key is in the map
 boolean containsValue(Object value)
          return true if the map contains that value
 Set entrySet()
           
 boolean equals(Object o)
           
 Object get(Object key)
          return the value associated with the key.
private  int getPostionByKey(Object key)
          return positive value as index of the key in the map.
private  int getPostionByValue(Object value)
          return positive value as index of the value in the map.
protected  int getSubsumeKey(Object key)
          return the index of the key in the map comparing them by reference only.
 int hashCode()
          return the hashCode for the map
private  void increaseCapacity()
           
 boolean isEmpty()
          return true if there are no elements in the map
 Set keySet()
          return the set of the keys in the map.
 Object put(Object key, Object value)
          put a value in the map using the given key.
 void putAll(Map t)
          put all the elements from a map
private  void readObject(ObjectInputStream s)
          readObject - calls the default readObject() and then initialises the transient data
 Object remove(Object key)
          remove value from the map using it's key.
 int size()
          return the number of elements in the map
 String toString()
           
 Collection values()
          Not supported.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

capacity

int capacity
The capacity of the map

count

int count
The current number of elements of the map

theKeys

Object[] theKeys
Array keeping the keys of the entries in the map. It is "synchrnized" with the values array - the Nth position in both arrays correspond to one and the same entry

theValues

Object[] theValues
Array keeping the values of the entries in the map. It is "synchrnized" with the keys array - the Nth position in both arrays correspond to one and the same entry

serialVersionUID

static final long serialVersionUID
Freeze the serialization UID.

nullKey

static transient Object nullKey
the Object instance that will represent the NULL keys in the map

theKeysHere

public static transient HashMap theKeysHere
the static 'all keys' collection
Constructor Detail

SimpleMapImpl

public SimpleMapImpl()
Constructor
Method Detail

static void ()
additional static members initialization

size

public int size()
return the number of elements in the map
Specified by:
size in interface Map

isEmpty

public boolean isEmpty()
return true if there are no elements in the map
Specified by:
isEmpty in interface Map

values

public Collection values()
Not supported. This method is here only to conform the Map interface
Specified by:
values in interface Map

keySet

public Set keySet()
return the set of the keys in the map. The changes in the set DO NOT affect the map.
Specified by:
keySet in interface Map

clear

public void clear()
clear the map
Specified by:
clear in interface Map

containsKey

public boolean containsKey(Object key)
return true if the key is in the map
Specified by:
containsKey in interface Map

containsValue

public boolean containsValue(Object value)
return true if the map contains that value
Specified by:
containsValue in interface Map

get

public Object get(Object key)
return the value associated with the key. If the key is not in the map returns null.
Specified by:
get in interface Map

put

public Object put(Object key,
                  Object value)
put a value in the map using the given key. If the key exist in the map the value is replaced and the old one is returned.
Specified by:
put in interface Map

remove

public Object remove(Object key)
remove value from the map using it's key.
Specified by:
remove in interface Map

putAll

public void putAll(Map t)
put all the elements from a map
Specified by:
putAll in interface Map

getPostionByKey

private int getPostionByKey(Object key)
return positive value as index of the key in the map. Negative value means that the key is not present in the map

getSubsumeKey

protected int getSubsumeKey(Object key)
return the index of the key in the map comparing them by reference only. This method is used in subsume check to speed it up.

getPostionByValue

private int getPostionByValue(Object value)
return positive value as index of the value in the map.

increaseCapacity

private void increaseCapacity()

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map

equals

public boolean equals(Object o)
Specified by:
equals in interface Map
Overrides:
equals in class Object

hashCode

public int hashCode()
return the hashCode for the map
Specified by:
hashCode in interface Map
Overrides:
hashCode in class Object

clone

public Object clone()
Create a copy of the map including the data.
Overrides:
clone in class Object

toString

public String toString()
Overrides:
toString in class Object

readObject

private void readObject(ObjectInputStream s)
                 throws IOException,
                        ClassNotFoundException
readObject - calls the default readObject() and then initialises the transient data