it.unimi.dsi.fastutil.longs
Interface Long2ObjectFunction<V>

All Superinterfaces:
Function<Long,V>
All Known Subinterfaces:
Long2ObjectMap<V>, Long2ObjectSortedMap<V>
All Known Implementing Classes:
AbstractLong2ObjectFunction, AbstractLong2ObjectMap, AbstractLong2ObjectSortedMap, Long2ObjectArrayMap, Long2ObjectAVLTreeMap, Long2ObjectFunctions.EmptyFunction, Long2ObjectFunctions.Singleton, Long2ObjectFunctions.SynchronizedFunction, Long2ObjectFunctions.UnmodifiableFunction, Long2ObjectLinkedOpenHashMap, Long2ObjectMaps.EmptyMap, Long2ObjectMaps.Singleton, Long2ObjectMaps.SynchronizedMap, Long2ObjectMaps.UnmodifiableMap, Long2ObjectOpenHashMap, Long2ObjectRBTreeMap, Long2ObjectSortedMaps.EmptySortedMap, Long2ObjectSortedMaps.Singleton, Long2ObjectSortedMaps.SynchronizedSortedMap, Long2ObjectSortedMaps.UnmodifiableSortedMap

public interface Long2ObjectFunction<V>
extends Function<Long,V>

A type-specific Function; provides some additional methods that use polymorphism to avoid (un)boxing.

Type-specific versions of get(), put() and remove() cannot rely on null to denote absence of a key. Rather, they return a default return value, which is set to 0 cast to the return type (false for booleans) at creation, but can be changed using the defaultReturnValue() method.

For uniformity reasons, even maps returning objects implement the default return value (of course, in this case the default return value is initialized to null).

Warning: to fall in line as much as possible with the standard map interface, it is strongly suggested that standard versions of get(), put() and remove() for maps with primitive-type values return null to denote missing keys rather than wrap the default return value in an object (of course, for maps with object keys and values this is not possible, as there is no type-specific version).

See Also:
Function

Method Summary
 boolean containsKey(long key)
           
 V defaultReturnValue()
          Gets the default return value.
 void defaultReturnValue(V rv)
          Sets the default return value.
 V get(long key)
          Returns the value to which the given key is mapped.
 V put(long key, V value)
          Adds a pair to the map.
 V remove(long key)
          Removes the mapping with the given key.
 
Methods inherited from interface it.unimi.dsi.fastutil.Function
clear, containsKey, get, put, remove, size
 

Method Detail

put

V put(long key,
      V value)
Adds a pair to the map.

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:
Function.put(Object,Object)

get

V get(long key)
Returns the value to which the given key is mapped.

Parameters:
key - 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)

remove

V remove(long key)
Removes the mapping with the given key.

Parameters:
key -
Returns:
the old value, or the default return value if no value was present for the given key.
See Also:
Function.remove(Object)

containsKey

boolean containsKey(long key)
See Also:
Function.containsKey(Object)

defaultReturnValue

void defaultReturnValue(V rv)
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.

Parameters:
rv - the new default return value.
See Also:
defaultReturnValue()

defaultReturnValue

V defaultReturnValue()
Gets the default return value.

Returns:
the current default return value.