Interface Char2ObjectFunction<V>
-
- All Known Subinterfaces:
Char2ObjectMap<V>
- All Known Implementing Classes:
AbstractChar2ObjectFunction,AbstractChar2ObjectMap,Char2ObjectFunctions.EmptyFunction,Char2ObjectFunctions.Singleton,Char2ObjectFunctions.SynchronizedFunction,Char2ObjectFunctions.UnmodifiableFunction,Char2ObjectOpenHashMap
public interface Char2ObjectFunction<V> extends Function<Character,V>
A type-specificFunction; provides some additional methods that use polymorphism to avoid (un)boxing.Type-specific versions of
get(),put()andremove()cannot rely onnullto denote absence of a key. Rather, they return a default return value, which is set to 0 cast to the return type (falsefor booleans) at creation, but can be changed using thedefaultReturnValue()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()andremove()for maps with primitive-type values returnnullto 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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancontainsKey(char key)VdefaultReturnValue()Gets the default return value.voiddefaultReturnValue(V rv)Sets the default return value.Vget(char key)Returns the value to which the given key is mapped.Vput(char key, V value)Adds a pair to the map.Vremove(char key)Removes the mapping with the given key.
-
-
-
Method Detail
-
put
V put(char 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(char 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(char 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(char 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 ofget(),put()andremove()to denote that the map does not contain the specified key. It must be 0/false/nullby 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.
-
-