it.unimi.dsi.fastutil.doubles
Class Double2LongMaps.SynchronizedMap

java.lang.Object
  extended by it.unimi.dsi.fastutil.doubles.AbstractDouble2LongFunction
      extended by it.unimi.dsi.fastutil.doubles.Double2LongFunctions.SynchronizedFunction
          extended by it.unimi.dsi.fastutil.doubles.Double2LongMaps.SynchronizedMap
All Implemented Interfaces:
Double2LongFunction, Double2LongMap, Function<Double,Long>, Serializable, Map<Double,Long>
Direct Known Subclasses:
Double2LongSortedMaps.SynchronizedSortedMap
Enclosing class:
Double2LongMaps

public static class Double2LongMaps.SynchronizedMap
extends Double2LongFunctions.SynchronizedFunction
implements Double2LongMap, Serializable

A synchronized wrapper class for maps.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface it.unimi.dsi.fastutil.doubles.Double2LongMap
Double2LongMap.Entry, Double2LongMap.FastEntrySet
 
Field Summary
protected  ObjectSet<Double2LongMap.Entry> entries
           
protected  DoubleSet keys
           
protected  Double2LongMap map
           
static long serialVersionUID
           
protected  LongCollection values
           
 
Fields inherited from class it.unimi.dsi.fastutil.doubles.Double2LongFunctions.SynchronizedFunction
function, sync
 
Fields inherited from class it.unimi.dsi.fastutil.doubles.AbstractDouble2LongFunction
defRetValue
 
Constructor Summary
protected Double2LongMaps.SynchronizedMap(Double2LongMap m)
           
protected Double2LongMaps.SynchronizedMap(Double2LongMap m, Object sync)
           
 
Method Summary
 void clear()
          Removes all associations from this function (optional operation).
 boolean containsKey(double k)
           
 boolean containsKey(Object ok)
          Returns true if this function contains a mapping for the specified key.
 boolean containsValue(long v)
           
 boolean containsValue(Object ov)
           
 long defaultReturnValue()
          Gets the default return value.
 void defaultReturnValue(long defRetValue)
          Sets the default return value.
 ObjectSet<Double2LongMap.Entry> double2LongEntrySet()
          Returns a type-specific set view of the mappings contained in this map.
 ObjectSet<Map.Entry<Double,Long>> entrySet()
          Returns a set view of the mappings contained in this map.
 boolean equals(Object o)
           
 long get(double k)
          Returns the value to which the given key is mapped.
 int hashCode()
           
 boolean isEmpty()
           
 DoubleSet keySet()
          Returns a set view of the keys contained in this map.
 long put(double k, long v)
          Adds a pair to the map.
 Long put(Double k, Long v)
          Delegates to the corresponding type-specific method, taking care of returning null on a missing key.
 void putAll(Map<? extends Double,? extends Long> m)
           
 long remove(double 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()
           
 LongCollection values()
          Returns a set view of the values contained in this map.
 
Methods inherited from class it.unimi.dsi.fastutil.doubles.Double2LongFunctions.SynchronizedFunction
get, remove
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface it.unimi.dsi.fastutil.Function
get, remove
 
Methods inherited from interface java.util.Map
get, remove
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values

map

protected final Double2LongMap map

entries

protected transient volatile ObjectSet<Double2LongMap.Entry> entries

keys

protected transient volatile DoubleSet keys

values

protected transient volatile LongCollection values
Constructor Detail

Double2LongMaps.SynchronizedMap

protected Double2LongMaps.SynchronizedMap(Double2LongMap m,
                                          Object sync)

Double2LongMaps.SynchronizedMap

protected Double2LongMaps.SynchronizedMap(Double2LongMap 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<Double,Long>
Specified by:
size in interface Map<Double,Long>
Overrides:
size in class Double2LongFunctions.SynchronizedFunction
Returns:
the intended number of keys in this function, or -1 if that number is not available.

containsKey

public boolean containsKey(double k)
Specified by:
containsKey in interface Double2LongFunction
Overrides:
containsKey in class Double2LongFunctions.SynchronizedFunction
See Also:
Function.containsKey(Object)

containsValue

public boolean containsValue(long v)
Specified by:
containsValue in interface Double2LongMap
See Also:
Map.containsValue(Object)

defaultReturnValue

public long defaultReturnValue()
Description copied from interface: Double2LongFunction
Gets the default return value.

Specified by:
defaultReturnValue in interface Double2LongFunction
Overrides:
defaultReturnValue in class Double2LongFunctions.SynchronizedFunction
Returns:
the current default return value.

defaultReturnValue

public void defaultReturnValue(long defRetValue)
Description copied from interface: Double2LongFunction
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 Double2LongFunction
Overrides:
defaultReturnValue in class Double2LongFunctions.SynchronizedFunction
Parameters:
defRetValue - the new default return value.
See Also:
Double2LongFunction.defaultReturnValue()

put

public long put(double k,
                long v)
Description copied from interface: Double2LongFunction
Adds a pair to the map.

Specified by:
put in interface Double2LongFunction
Overrides:
put in class Double2LongFunctions.SynchronizedFunction
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 Double,? extends Long> m)
Specified by:
putAll in interface Map<Double,Long>

double2LongEntrySet

public ObjectSet<Double2LongMap.Entry> double2LongEntrySet()
Description copied from interface: Double2LongMap
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 Double2LongMap.entrySet() so that it returns an ObjectSet of objects of type Double2LongMap.Entry (the latter makes it possible to access keys and values with type-specific methods).

Specified by:
double2LongEntrySet in interface Double2LongMap
Returns:
a type-specific set view of the mappings contained in this map.
See Also:
Double2LongMap.entrySet()

keySet

public DoubleSet keySet()
Description copied from interface: Double2LongMap
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 Double2LongMap
Specified by:
keySet in interface Map<Double,Long>
Returns:
a set view of the keys contained in this map.
See Also:
Map.keySet()

values

public LongCollection values()
Description copied from interface: Double2LongMap
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 Double2LongMap
Specified by:
values in interface Map<Double,Long>
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<Double,Long>
Specified by:
clear in interface Map<Double,Long>
Overrides:
clear in class Double2LongFunctions.SynchronizedFunction
See Also:
Map.clear()

toString

public String toString()
Overrides:
toString in class Double2LongFunctions.SynchronizedFunction

put

public Long put(Double k,
                Long v)
Description copied from class: AbstractDouble2LongFunction
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 Function<Double,Long>
Specified by:
put in interface Map<Double,Long>
Overrides:
put in class Double2LongFunctions.SynchronizedFunction
Parameters:
k - the key.
v - the value.
Returns:
the old value, or null if no value was present for the given key.
See Also:
Map.put(Object,Object)

remove

public long remove(double k)
Description copied from interface: Double2LongFunction
Removes the mapping with the given key.

Specified by:
remove in interface Double2LongFunction
Overrides:
remove in class Double2LongFunctions.SynchronizedFunction
Returns:
the old value, or the default return value if no value was present for the given key.
See Also:
Function.remove(Object)

get

public long get(double k)
Description copied from interface: Double2LongFunction
Returns the value to which the given key is mapped.

Specified by:
get in interface Double2LongFunction
Overrides:
get in class Double2LongFunctions.SynchronizedFunction
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)

containsKey

public boolean containsKey(Object ok)
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<Double,Long>
Specified by:
containsKey in interface Map<Double,Long>
Overrides:
containsKey in class Double2LongFunctions.SynchronizedFunction
Parameters:
ok - the key.
Returns:
true if this function associates a value to key.
See Also:
Map.containsKey(Object)

containsValue

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

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<Double,Long>

entrySet

public ObjectSet<Map.Entry<Double,Long>> entrySet()
Description copied from interface: Double2LongMap
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 Double2LongMap
Specified by:
entrySet in interface Map<Double,Long>
Returns:
a set view of the mappings contained in this map.
See Also:
Map.entrySet()

hashCode

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

equals

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


Copyright © 2011. All Rights Reserved.