fulmine.util.collection
Class MapSet<KEY,SET_TYPE>

java.lang.Object
  extended by fulmine.util.collection.MapSet<KEY,SET_TYPE>
Type Parameters:
KEY - the type for the map keys
SET_TYPE - the type for the set entries
All Implemented Interfaces:
Map<KEY,Set<SET_TYPE>>

public final class MapSet<KEY,SET_TYPE>
extends Object

A Map that has Set values. The sets are auto-created via the get(Object) method with a size of 1.

This is not thread safe.

Author:
Ramon Servadei

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
protected static int DEFAULT_INITIAL_CAPACITY
          The default initial capacity - MUST be a power of two.
protected static float DEFAULT_LOAD_FACTOR
          The load factor used when none specified in constructor.
protected  Map<KEY,COLLECTION_TYPE> delegate
           
 
Constructor Summary
MapSet()
           
MapSet(int size)
           
MapSet(int size, float loadFactor)
           
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
protected  Set<SET_TYPE> createCollection()
          Overridden in sub-classes to provide the Collection type to store per key in the map.
 Set<Map.Entry<KEY,COLLECTION_TYPE>> entrySet()
           
 boolean equals(Object o)
           
 COLLECTION_TYPE get(Object key)
          Get the Collection type keyed against the object, creating the collection type if needed.
 int hashCode()
           
 boolean isEmpty()
           
 Set<KEY> keySet()
           
 COLLECTION_TYPE put(KEY key, COLLECTION_TYPE value)
           
 void putAll(Map<? extends KEY,? extends COLLECTION_TYPE> t)
           
 COLLECTION_TYPE remove(Object key)
           
 int size()
           
 String toString()
           
 Collection<COLLECTION_TYPE> values()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_INITIAL_CAPACITY

protected static final int DEFAULT_INITIAL_CAPACITY
The default initial capacity - MUST be a power of two.

See Also:
Constant Field Values

DEFAULT_LOAD_FACTOR

protected static final float DEFAULT_LOAD_FACTOR
The load factor used when none specified in constructor.

See Also:
Constant Field Values

delegate

protected final Map<KEY,COLLECTION_TYPE> delegate
Constructor Detail

MapSet

public MapSet()

MapSet

public MapSet(int size)

MapSet

public MapSet(int size,
              float loadFactor)
Method Detail

createCollection

protected Set<SET_TYPE> createCollection()
Overridden in sub-classes to provide the Collection type to store per key in the map.

Returns:
a created instance of the collection type for a new key added to the map

clear

public void clear()
Specified by:
clear in interface Map<KEY,COLLECTION_TYPE>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<KEY,COLLECTION_TYPE>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<KEY,COLLECTION_TYPE>

entrySet

public Set<Map.Entry<KEY,COLLECTION_TYPE>> entrySet()
Specified by:
entrySet in interface Map<KEY,COLLECTION_TYPE>

equals

public boolean equals(Object o)
Specified by:
equals in interface Map<KEY,COLLECTION_TYPE>
Overrides:
equals in class Object

get

public COLLECTION_TYPE get(Object key)
Get the Collection type keyed against the object, creating the collection type if needed.

Specified by:
get in interface Map<KEY,COLLECTION_TYPE>
See Also:
Map.get(Object)

hashCode

public int hashCode()
Specified by:
hashCode in interface Map<KEY,COLLECTION_TYPE>
Overrides:
hashCode in class Object

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<KEY,COLLECTION_TYPE>

keySet

public Set<KEY> keySet()
Specified by:
keySet in interface Map<KEY,COLLECTION_TYPE>

put

public COLLECTION_TYPE put(KEY key,
                           COLLECTION_TYPE value)
Specified by:
put in interface Map<KEY,COLLECTION_TYPE>

putAll

public void putAll(Map<? extends KEY,? extends COLLECTION_TYPE> t)
Specified by:
putAll in interface Map<KEY,COLLECTION_TYPE>

remove

public COLLECTION_TYPE remove(Object key)
Specified by:
remove in interface Map<KEY,COLLECTION_TYPE>

size

public int size()
Specified by:
size in interface Map<KEY,COLLECTION_TYPE>

values

public Collection<COLLECTION_TYPE> values()
Specified by:
values in interface Map<KEY,COLLECTION_TYPE>

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007-2009. All Rights Reserved.