cz.cuni.amis.utils.maps
Class HashMapSet<KEY,ITEM>

Package class diagram package HashMapSet
java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<KEY,Set<ITEM>>
          extended by cz.cuni.amis.utils.maps.HashMapSet<KEY,ITEM>
Type Parameters:
KEY -
ITEM -
All Implemented Interfaces:
Serializable, Cloneable, Map<KEY,Set<ITEM>>

public class HashMapSet<KEY,ITEM>
extends HashMap<KEY,Set<ITEM>>

Map containing sets. Whenever a set under some key is requested and does not exists, the HashMapSet automatically creates new one.

The implementation is unsynchronized, created sets are synchronized (just iteration over the set must be synchronized by the user as described in Java(tm) documentation).

Author:
Jimmy
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Constructor Summary
HashMapSet()
           
 
Method Summary
 void add(KEY key, ITEM item)
          Adds the item into the set under the key.
 boolean contains(KEY key, ITEM item)
          Tests whether an 'item' is inside the set under 'key'.
 Set<ITEM> get(Object primaryKey)
          The get method ensures that the requested set under primaryKey always exists!
 boolean remove(KEY key, ITEM item)
          Removes the item from the set under the key.
 Set<ITEM> remove(Object key)
          Remove returns the removed item, if item was non-existent, it returns empty set.
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, isEmpty, keySet, put, putAll, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

HashMapSet

public HashMapSet()
Method Detail

get

public Set<ITEM> get(Object primaryKey)
The get method ensures that the requested set under primaryKey always exists!

Specified by:
get in interface Map<KEY,Set<ITEM>>
Overrides:
get in class HashMap<KEY,Set<ITEM>>
Parameters:
primaryKey - must be instance of PRIMARY_KEY

add

public void add(KEY key,
                ITEM item)
Adds the item into the set under the key.

Parameters:
key -
item -

remove

public Set<ITEM> remove(Object key)
Remove returns the removed item, if item was non-existent, it returns empty set.

Specified by:
remove in interface Map<KEY,Set<ITEM>>
Overrides:
remove in class HashMap<KEY,Set<ITEM>>
Parameters:
primaryKey -
Returns:

remove

public boolean remove(KEY key,
                      ITEM item)
Removes the item from the set under the key.

Parameters:
key -
item -

contains

public boolean contains(KEY key,
                        ITEM item)
Tests whether an 'item' is inside the set under 'key'.

Parameters:
key -
item -
Returns:


Copyright © 2015 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.