it.unimi.dsi.fastutil.objects
Class Reference2IntMaps.UnmodifiableMap<K>

java.lang.Object
  extended by it.unimi.dsi.fastutil.objects.AbstractReference2IntFunction<K>
      extended by it.unimi.dsi.fastutil.objects.Reference2IntFunctions.UnmodifiableFunction<K>
          extended by it.unimi.dsi.fastutil.objects.Reference2IntMaps.UnmodifiableMap<K>
All Implemented Interfaces:
Function<K,Integer>, Reference2IntFunction<K>, Reference2IntMap<K>, Serializable, Map<K,Integer>
Direct Known Subclasses:
Reference2IntSortedMaps.UnmodifiableSortedMap
Enclosing class:
Reference2IntMaps

public static class Reference2IntMaps.UnmodifiableMap<K>
extends Reference2IntFunctions.UnmodifiableFunction<K>
implements Reference2IntMap<K>, Serializable

An unmodifiable wrapper class for maps.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface it.unimi.dsi.fastutil.objects.Reference2IntMap
Reference2IntMap.Entry<K>, Reference2IntMap.FastEntrySet<K>
 
Field Summary
protected  ObjectSet<Reference2IntMap.Entry<K>> entries
           
protected  ReferenceSet<K> keys
           
protected  Reference2IntMap<K> map
           
static long serialVersionUID
           
protected  IntCollection values
           
 
Fields inherited from class it.unimi.dsi.fastutil.objects.Reference2IntFunctions.UnmodifiableFunction
function
 
Fields inherited from class it.unimi.dsi.fastutil.objects.AbstractReference2IntFunction
defRetValue
 
Constructor Summary
protected Reference2IntMaps.UnmodifiableMap(Reference2IntMap<K> m)
           
 
Method Summary
 void clear()
          Removes all associations from this function (optional operation).
 boolean containsKey(Object k)
          Returns true if this function contains a mapping for the specified key.
 boolean containsValue(int v)
           
 boolean containsValue(Object ov)
           
 int defaultReturnValue()
          Gets the default return value.
 void defaultReturnValue(int defRetValue)
          Sets the default return value.
 ObjectSet<Map.Entry<K,Integer>> entrySet()
          Returns a set view of the mappings contained in this map.
 int getInt(Object k)
          Returns the value to which the given key is mapped.
 boolean isEmpty()
           
 ReferenceSet<K> keySet()
          Returns a set view of the keys contained in this map.
 int put(K k, int v)
          Adds a pair to the map.
 void putAll(Map<? extends K,? extends Integer> m)
           
 ObjectSet<Reference2IntMap.Entry<K>> reference2IntEntrySet()
          Returns a type-specific set view of the mappings contained in this map.
 int removeInt(Object k)
          Removes the mapping with the given key.
 int size()
          Returns the intended number of keys in this function, or -1 if no such number exists.
 String toString()
           
 IntCollection values()
          Returns a set view of the values contained in this map.
 
Methods inherited from class it.unimi.dsi.fastutil.objects.AbstractReference2IntFunction
get, put, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface it.unimi.dsi.fastutil.Function
get, put, remove
 
Methods inherited from interface java.util.Map
equals, get, hashCode, put, remove
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values

map

protected final Reference2IntMap<K> map

entries

protected transient volatile ObjectSet<Reference2IntMap.Entry<K>> entries

keys

protected transient volatile ReferenceSet<K> keys

values

protected transient volatile IntCollection values
Constructor Detail

Reference2IntMaps.UnmodifiableMap

protected Reference2IntMaps.UnmodifiableMap(Reference2IntMap<K> m)
Method Detail

size

public int size()
Description copied from interface: Function
Returns the intended number of keys in this function, or -1 if no such number exists.

Most function implementations will have some knowledge of the intended number of keys in their domain. In some cases, however, this might not be possible.

Specified by:
size in interface Function<K,Integer>
Specified by:
size in interface Map<K,Integer>
Overrides:
size in class Reference2IntFunctions.UnmodifiableFunction<K>
Returns:
the intended number of keys in this function, or -1 if that number is not available.

containsKey

public boolean containsKey(Object k)
Description copied from interface: Function
Returns true if this function contains a mapping for the specified key.

Note that for some kind of functions (e.g., hashes) this method will always return true.

Specified by:
containsKey in interface Function<K,Integer>
Specified by:
containsKey in interface Map<K,Integer>
Overrides:
containsKey in class Reference2IntFunctions.UnmodifiableFunction<K>
Parameters:
k - the key.
Returns:
true if this function associates a value to key.
See Also:
Map.containsKey(Object)

containsValue

public boolean containsValue(int v)
Specified by:
containsValue in interface Reference2IntMap<K>
See Also:
Map.containsValue(Object)

defaultReturnValue

public int defaultReturnValue()
Description copied from interface: Reference2IntFunction
Gets the default return value.

Specified by:
defaultReturnValue in interface Reference2IntFunction<K>
Overrides:
defaultReturnValue in class Reference2IntFunctions.UnmodifiableFunction<K>
Returns:
the current default return value.

defaultReturnValue

public void defaultReturnValue(int defRetValue)
Description copied from interface: Reference2IntFunction
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 Reference2IntFunction<K>
Overrides:
defaultReturnValue in class Reference2IntFunctions.UnmodifiableFunction<K>
Parameters:
defRetValue - the new default return value.
See Also:
Reference2IntFunction.defaultReturnValue()

put

public int put(K k,
               int v)
Description copied from interface: Reference2IntFunction
Adds a pair to the map.

Specified by:
put in interface Reference2IntFunction<K>
Overrides:
put in class Reference2IntFunctions.UnmodifiableFunction<K>
Parameters:
k - the key.
v - the value.
Returns:
the old value, or the default return value if no value was present for the given key.
See Also:
Function.put(Object,Object)

putAll

public void putAll(Map<? extends K,? extends Integer> m)
Specified by:
putAll in interface Map<K,Integer>

reference2IntEntrySet

public ObjectSet<Reference2IntMap.Entry<K>> reference2IntEntrySet()
Description copied from interface: Reference2IntMap
Returns a type-specific set view of the mappings contained in this map.

This method is necessary because there is no inheritance along type parameters: it is thus impossible to strengthen Reference2IntMap.entrySet() so that it returns an ObjectSet of objects of type Reference2IntMap.Entry (the latter makes it possible to access keys and values with type-specific methods).

Specified by:
reference2IntEntrySet in interface Reference2IntMap<K>
Returns:
a type-specific set view of the mappings contained in this map.
See Also:
Reference2IntMap.entrySet()

keySet

public ReferenceSet<K> keySet()
Description copied from interface: Reference2IntMap
Returns a set view of the keys contained in this map.

Note that this specification strengthens the one given in Map.keySet().

Specified by:
keySet in interface Reference2IntMap<K>
Specified by:
keySet in interface Map<K,Integer>
Returns:
a set view of the keys contained in this map.
See Also:
Map.keySet()

values

public IntCollection values()
Description copied from interface: Reference2IntMap
Returns a set view of the values contained in this map.

Note that this specification strengthens the one given in Map.values().

Specified by:
values in interface Reference2IntMap<K>
Specified by:
values in interface Map<K,Integer>
Returns:
a set view of the values contained in this map.
See Also:
Map.values()

clear

public void clear()
Description copied from interface: Function
Removes all associations from this function (optional operation).

Specified by:
clear in interface Function<K,Integer>
Specified by:
clear in interface Map<K,Integer>
Overrides:
clear in class Reference2IntFunctions.UnmodifiableFunction<K>
See Also:
Map.clear()

toString

public String toString()
Overrides:
toString in class Reference2IntFunctions.UnmodifiableFunction<K>

containsValue

public boolean containsValue(Object ov)
Specified by:
containsValue in interface Map<K,Integer>

removeInt

public int removeInt(Object k)
Description copied from interface: Reference2IntFunction
Removes the mapping with the given key.

Specified by:
removeInt in interface Reference2IntFunction<K>
Overrides:
removeInt in class Reference2IntFunctions.UnmodifiableFunction<K>
Returns:
the old value, or the default return value if no value was present for the given key.
See Also:
Function.remove(Object)

getInt

public int getInt(Object k)
Description copied from interface: Reference2IntFunction
Returns the value to which the given key is mapped.

Specified by:
getInt in interface Reference2IntFunction<K>
Overrides:
getInt in class Reference2IntFunctions.UnmodifiableFunction<K>
Parameters:
k - the key.
Returns:
the corresponding value, or the default return value if no value was present for the given key.
See Also:
Function.get(Object)

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<K,Integer>

entrySet

public ObjectSet<Map.Entry<K,Integer>> entrySet()
Description copied from interface: Reference2IntMap
Returns a set view of the mappings contained in this map.

Note that this specification strengthens the one given in Map.entrySet().

Specified by:
entrySet in interface Reference2IntMap<K>
Specified by:
entrySet in interface Map<K,Integer>
Returns:
a set view of the mappings contained in this map.
See Also:
Map.entrySet()


Copyright © 2011. All Rights Reserved.