|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A type-specific Map
; provides some additional methods that use polymorphism to reduce type juggling, and handling of a default return value.
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
). This very useful for maps containing null
keys.
A submap or subset may or may not have an independent default return value (which however must be initialized to the default return value of the originator).
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).
Map
Nested Class Summary | |
static interface |
Byte2ByteMap.Entry
A type-specific Map.Entry ; provides some additional methods
to access its content reducing type juggling. |
Method Summary | |
boolean |
containsKey(byte key)
|
boolean |
containsValue(byte value)
|
byte |
defaultReturnValue()
Gets the default return value. |
void |
defaultReturnValue(byte rv)
Sets the default return value. |
byte |
get(byte key)
Returns the value to which the given key is mapped. |
byte |
getDefRetValue()
Deprecated. As of fastutil 2.0, replaced by defaultReturnValue() . |
byte |
put(byte key,
byte value)
Adds a pair to the map. |
byte |
remove(byte key)
Removes the mapping with the given key. |
void |
setDefRetValue(byte rv)
Deprecated. As of fastutil 2.0, replaced by defaultReturnValue() . |
Methods inherited from interface java.util.Map |
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
Method Detail |
public byte put(byte key, byte value)
key
- the key.value
- the value.
Map.put(Object,Object)
public byte get(byte key)
key
- the key.
Map.get(Object)
public byte remove(byte key)
key
-
Map.remove(Object)
public boolean containsKey(byte key)
Map.containsKey(Object)
public boolean containsValue(byte value)
Map.containsValue(Object)
public void setDefRetValue(byte rv)
fastutil
2.0, replaced by defaultReturnValue()
.
rv
- the new default return value.getDefRetValue()
,
defaultReturnValue()
public byte getDefRetValue()
fastutil
2.0, replaced by defaultReturnValue()
.
defaultReturnValue()
public void defaultReturnValue(byte rv)
get()
, put()
and remove()
to
denote that the map does not contain the specified key. It must be
0/false
/null
by default.
rv
- the new default return value.defaultReturnValue()
public byte defaultReturnValue()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |