ch.javasoft.util.intcoll
Class DefaultIntIntMap

java.lang.Object
  extended by java.util.AbstractMap<Integer,Integer>
      extended by ch.javasoft.util.intcoll.AbstractIntIntMap
          extended by ch.javasoft.util.intcoll.DefaultIntIntMap
All Implemented Interfaces:
IntIntMap, IntMap<Integer>, Serializable, Cloneable, Map<Integer,Integer>

public class DefaultIntIntMap
extends AbstractIntIntMap
implements Serializable, Cloneable

DefaultIntIntMap is an mutable mapping from int to int. It is implemented with two lists for keys and values, and the key list is sorted.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class ch.javasoft.util.intcoll.AbstractIntIntMap
AbstractIntIntMap.ImmutableIntIntEntry, AbstractIntIntMap.SimpleIntIntEntry
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface ch.javasoft.util.intcoll.IntIntMap
IntIntMap.IntIntEntry
 
Nested classes/interfaces inherited from interface ch.javasoft.util.intcoll.IntMap
IntMap.IntEntry<V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
DefaultIntIntMap()
          Constructor for a new empty map
DefaultIntIntMap(DefaultIntIntMap copy)
           
DefaultIntIntMap(int capacity)
          Constructor for a new empty map of the given initial capacity
DefaultIntIntMap(Map<Integer,Integer> map)
           
 
Method Summary
 void clear()
           
 DefaultIntIntMap clone()
           
 boolean containsKey(int key)
           
 boolean containsValue(int value)
           
 boolean equals(Object o)
           
 int getInt(int key)
          Returns the int value for the specified key, or throws a NoSuchElementException otherwise
 Set<IntIntMap.IntIntEntry> intIntEntrySet()
           
 boolean isEmpty()
           
 IntSet keySet()
           
 Integer put(int key, int value)
           
 void putAll(IntIntMap map)
           
 Integer remove(int key)
           
 int size()
           
 int[] toKeyArray()
          Returns the keys as a sorted int array.
 int[] toValueArray()
          Returns the values as an int array.
 IntCollection values()
           
 
Methods inherited from class ch.javasoft.util.intcoll.AbstractIntIntMap
containsKey, containsValue, entrySet, get, get, intEntrySet, put, put, putAll, putAll, remove
 
Methods inherited from class java.util.AbstractMap
hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
hashCode
 

Constructor Detail

DefaultIntIntMap

public DefaultIntIntMap()
Constructor for a new empty map


DefaultIntIntMap

public DefaultIntIntMap(int capacity)
Constructor for a new empty map of the given initial capacity


DefaultIntIntMap

public DefaultIntIntMap(DefaultIntIntMap copy)

DefaultIntIntMap

public DefaultIntIntMap(Map<Integer,Integer> map)
Method Detail

getInt

public int getInt(int key)
Description copied from interface: IntIntMap
Returns the int value for the specified key, or throws a NoSuchElementException otherwise

Specified by:
getInt in interface IntIntMap
Parameters:
key - the key for which the value shall be returned
Returns:
the value associated with the given key

containsKey

public boolean containsKey(int key)
Specified by:
containsKey in interface IntIntMap
Specified by:
containsKey in interface IntMap<Integer>
Overrides:
containsKey in class AbstractIntIntMap

containsValue

public boolean containsValue(int value)
Specified by:
containsValue in interface IntIntMap

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<Integer,Integer>
Overrides:
isEmpty in class AbstractIntIntMap

size

public int size()
Specified by:
size in interface Map<Integer,Integer>
Overrides:
size in class AbstractMap<Integer,Integer>

keySet

public IntSet keySet()
Specified by:
keySet in interface IntMap<Integer>
Specified by:
keySet in interface Map<Integer,Integer>
Specified by:
keySet in class AbstractIntIntMap

intIntEntrySet

public Set<IntIntMap.IntIntEntry> intIntEntrySet()
Specified by:
intIntEntrySet in interface IntIntMap

values

public IntCollection values()
Specified by:
values in interface IntIntMap
Specified by:
values in interface Map<Integer,Integer>
Specified by:
values in class AbstractIntIntMap

toKeyArray

public int[] toKeyArray()
Returns the keys as a sorted int array. The key at position i corresponds to the value at position i as returned by toValueArray()

Returns:
a copy of the sorted key array

toValueArray

public int[] toValueArray()
Returns the values as an int array. The value at position i corresponds to the key at position i as returned by toKeyArray()

Returns:
a copy of the value array

equals

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

put

public Integer put(int key,
                   int value)
Specified by:
put in interface IntIntMap

putAll

public void putAll(IntIntMap map)
Specified by:
putAll in interface IntIntMap
Overrides:
putAll in class AbstractIntIntMap

clear

public void clear()
Specified by:
clear in interface Map<Integer,Integer>
Overrides:
clear in class AbstractMap<Integer,Integer>

remove

public Integer remove(int key)
Specified by:
remove in interface IntMap<Integer>

clone

public DefaultIntIntMap clone()
Overrides:
clone in class AbstractMap<Integer,Integer>