org.abstracthorizon.extend.server.support
Class EnhancedMap<KeyType,ValueType>

java.lang.Object
  extended by org.abstracthorizon.extend.server.support.EnhancedMap<KeyType,ValueType>
All Implemented Interfaces:
Map<KeyType,ValueType>
Direct Known Subclasses:
DeploymentManagerImpl.DeployedModules

public class EnhancedMap<KeyType,ValueType>
extends Object
implements Map<KeyType,ValueType>

This map maintains separate set of values. This allows if two key/value pairs contain same value and remove(Object) method is called with value both values are going to be removed from the map. Also, having set of values values() method returns that set which is faster. Values set is implemented as LinkedHashSet


Nested Class Summary
protected  class EnhancedMap.InternalSet<Type>
          Internal implementation of LinkedHashSet so invoking HashSet.remove(Object) method removes all values from the map as well
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
protected  LinkedHashMap<KeyType,ValueType> map
          Map
protected  EnhancedMap.InternalSet<ValueType> values
          Values
 
Constructor Summary
EnhancedMap()
          Empty constractor
 
Method Summary
 void clear()
          Clears the map.
 boolean containsKey(Object key)
          Checks map if key exsits
 boolean containsValue(Object value)
          Checks values set if value exsits
 Set<Map.Entry<KeyType,ValueType>> entrySet()
          Returns entry set of a map
 ValueType get(Object key)
          Returns get value
 boolean isEmpty()
          Returns if is empty
 Set<KeyType> keySet()
          Returns key set
static void main(String[] args)
           
 ValueType put(KeyType key, ValueType value)
          Adds new element to the map
 void putAll(Map<? extends KeyType,? extends ValueType> t)
          Stores all
 ValueType remove(Object value)
          Removes value value
 int size()
          Returns map size
 Collection<ValueType> values()
          Returns values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

map

protected LinkedHashMap<KeyType,ValueType> map
Map


values

protected EnhancedMap.InternalSet<ValueType> values
Values

Constructor Detail

EnhancedMap

public EnhancedMap()
Empty constractor

Method Detail

get

public ValueType get(Object key)
Returns get value

Specified by:
get in interface Map<KeyType,ValueType>
Parameters:
key - key
Returns:
value

put

public ValueType put(KeyType key,
                     ValueType value)
Adds new element to the map

Specified by:
put in interface Map<KeyType,ValueType>
Parameters:
key - key
value - value
Returns:
previous value under that key

remove

public ValueType remove(Object value)
Removes value value

Specified by:
remove in interface Map<KeyType,ValueType>
Parameters:
value - value to be removed
Returns:
true if removed

clear

public void clear()
Clears the map.

Specified by:
clear in interface Map<KeyType,ValueType>

values

public Collection<ValueType> values()
Returns values

Specified by:
values in interface Map<KeyType,ValueType>
Returns:
values

containsKey

public boolean containsKey(Object key)
Checks map if key exsits

Specified by:
containsKey in interface Map<KeyType,ValueType>
Parameters:
key - key
Returns:
true if key exists

containsValue

public boolean containsValue(Object value)
Checks values set if value exsits

Specified by:
containsValue in interface Map<KeyType,ValueType>
Parameters:
value - value
Returns:
true if value exists

entrySet

public Set<Map.Entry<KeyType,ValueType>> entrySet()
Returns entry set of a map

Specified by:
entrySet in interface Map<KeyType,ValueType>
Returns:
entry set of a map

isEmpty

public boolean isEmpty()
Returns if is empty

Specified by:
isEmpty in interface Map<KeyType,ValueType>
Returns:
true if is empty

keySet

public Set<KeyType> keySet()
Returns key set

Specified by:
keySet in interface Map<KeyType,ValueType>
Returns:
key set

putAll

public void putAll(Map<? extends KeyType,? extends ValueType> t)
Stores all

Specified by:
putAll in interface Map<KeyType,ValueType>
Parameters:
t - map

size

public int size()
Returns map size

Specified by:
size in interface Map<KeyType,ValueType>
Returns:
map size

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.