it.unimi.dsi.fastutil.floats
Class AbstractFloat2ShortMap

java.lang.Object
  extended byit.unimi.dsi.fastutil.floats.AbstractFloat2ShortMap
All Implemented Interfaces:
Float2ShortMap, Map, Serializable
Direct Known Subclasses:
AbstractFloat2ShortSortedMap, Float2ShortMaps.EmptyMap, Float2ShortMaps.Singleton, Float2ShortMaps.SynchronizedMap, Float2ShortMaps.UnmodifiableMap, Float2ShortOpenHashMap

public abstract class AbstractFloat2ShortMap
extends Object
implements Float2ShortMap, Serializable

An abstract class providing basic methods for maps implementing a type-specific interface.

This class handles directly a default return value (including methods to access it). Instances of classes inheriting from this class have just to return defRetValue to denote lack of a key in type-specific methods. The value is serialized.

Optional operations just throw an UnsupportedOperationException. Generic versions of accessors delegate to the corresponding type-specific counterparts following the interface rules (they take care of returning null on a missing key).

As a further help, this class provides a BasicEntry inner class that implements a type-specific version of Map.Entry; it is particularly useful for those classes that do not implement their own entries (e.g., most immutable maps).

See Also:
Serialized Form

Nested Class Summary
static class AbstractFloat2ShortMap.BasicEntry
          This class provides a basic but complete type-specific entry class for all those maps implementations that do not have entries on their own (e.g., most immutable maps).
 
Nested classes inherited from class it.unimi.dsi.fastutil.floats.Float2ShortMap
Float2ShortMap.Entry
 
Method Summary
 void clear()
           
 boolean containsKey(float k)
          Checks whether the given value is contained in keySet().
 boolean containsKey(Object ok)
           
 boolean containsValue(Object ov)
           
 boolean containsValue(short v)
          Checks whether the given value is contained in values().
 short defaultReturnValue()
          Gets the default return value.
 void defaultReturnValue(short rv)
          Sets the default return value.
 boolean equals(Object o)
           
 Object get(Object ok)
          Delegates to the corresponding type-specific method, taking care of returning null on a missing key.
 short getDefRetValue()
           
 int hashCode()
          Returns a hash code for this map.
 boolean isEmpty()
           
 Set keySet()
          Returns a type-specific-set view of the keys of this map.
 short put(float key, short value)
          Adds a pair to the map.
 Object put(Object ok, Object ov)
          Delegates to the corresponding type-specific method, taking care of returning null on a missing key.
 void putAll(Map m)
          Puts all pairs in the given map.
 short remove(float key)
          Removes the mapping with the given key.
 Object remove(Object ok)
          Delegates to the corresponding type-specific method, taking care of returning null on a missing key.
 void setDefRetValue(short rv)
           
 String toString()
           
 Collection values()
          Returns a type-specific-set view of the values of this map.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface it.unimi.dsi.fastutil.floats.Float2ShortMap
get
 
Methods inherited from interface java.util.Map
entrySet, size
 

Method Detail

setDefRetValue

public void setDefRetValue(short rv)
Specified by:
setDefRetValue in interface Float2ShortMap
Parameters:
rv - the new default return value.
See Also:
Float2ShortMap.getDefRetValue(), Float2ShortMap.defaultReturnValue()

getDefRetValue

public short getDefRetValue()
Specified by:
getDefRetValue in interface Float2ShortMap
Returns:
the current default return value.
See Also:
Float2ShortMap.defaultReturnValue()

defaultReturnValue

public void defaultReturnValue(short rv)
Description copied from interface: Float2ShortMap
Sets the default return value. This value must be returned by type-specific versions of get(), put() and remove() to denote that the map does not contain the specified key. It must be 0/false/null by default.

Specified by:
defaultReturnValue in interface Float2ShortMap
Parameters:
rv - the new default return value.
See Also:
Float2ShortMap.defaultReturnValue()

defaultReturnValue

public short defaultReturnValue()
Description copied from interface: Float2ShortMap
Gets the default return value.

Specified by:
defaultReturnValue in interface Float2ShortMap
Returns:
the current default return value.

put

public short put(float key,
                 short value)
Description copied from interface: Float2ShortMap
Adds a pair to the map.

Specified by:
put in interface Float2ShortMap
Parameters:
key - the key.
value - the value.
Returns:
the old value, or the default return value if no value was present for the given key.
See Also:
Map.put(Object,Object)

remove

public short remove(float key)
Description copied from interface: Float2ShortMap
Removes the mapping with the given key.

Specified by:
remove in interface Float2ShortMap
Parameters:
key -
Returns:
the old value, or the default return value if no value was present for the given key.
See Also:
Map.remove(Object)

clear

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

get

public Object get(Object ok)
Delegates to the corresponding type-specific method, taking care of returning null on a missing key.

This method must check whether the provided key is in the map using containsKey(). Thus, it probes the map twice. Implementors of subclasses should override it with a more efficient method.

Specified by:
get in interface Map

put

public Object put(Object ok,
                  Object ov)
Delegates to the corresponding type-specific method, taking care of returning null on a missing key.

This method must check whether the provided key is in the map using containsKey(). Thus, it probes the map twice. Implementors of subclasses should override it with a more efficient method.

Specified by:
put in interface Map

remove

public Object remove(Object ok)
Delegates to the corresponding type-specific method, taking care of returning null on a missing key.

This method must check whether the provided key is in the map using containsKey(). Thus, it probes the map twice. Implementors of subclasses should override it with a more efficient method.

Specified by:
remove in interface Map

containsValue

public boolean containsValue(Object ov)
Specified by:
containsValue in interface Map

containsKey

public boolean containsKey(Object ok)
Specified by:
containsKey in interface Map

containsValue

public boolean containsValue(short v)
Checks whether the given value is contained in values().

Specified by:
containsValue in interface Float2ShortMap
See Also:
Map.containsValue(Object)

containsKey

public boolean containsKey(float k)
Checks whether the given value is contained in keySet().

Specified by:
containsKey in interface Float2ShortMap
See Also:
Map.containsKey(Object)

putAll

public void putAll(Map m)
Puts all pairs in the given map. If the map implements the interface of this map, it uses the faster iterators.

Specified by:
putAll in interface Map
Parameters:
m - a map.

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map

keySet

public Set keySet()
Returns a type-specific-set view of the keys of this map.

The view is backed by the set returned by Map.entrySet(). Note that no attempt is made at caching the result of this method, as this would require adding some attributes that lightweight implementations would not need. Subclasses may easily override this policy by calling this method and caching the result, but implementors are encouraged to write more efficient ad-hoc implementations.

Specified by:
keySet in interface Map
Returns:
a set view of the keys of this map; it may be safely cast to a type-specific interface.

values

public Collection values()
Returns a type-specific-set view of the values of this map.

The view is backed by the set returned by Map.entrySet(). Note that no attempt is made at caching the result of this method, as this would require adding some attributes that lightweight implementations would not need. Subclasses may easily override this policy by calling this method and caching the result, but implementors are encouraged to write more efficient ad-hoc implementations.

Specified by:
values in interface Map
Returns:
a set view of the values of this map; it may be safely cast to a type-specific interface.

hashCode

public int hashCode()
Returns a hash code for this map. The hash code of a map is computed by summing the hash codes of its entries.

Specified by:
hashCode in interface Map
Returns:
a hash code for this map.

equals

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

toString

public String toString()