|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unimi.dsi.fastutil.chars.AbstractChar2ShortMap
An abstract class providing basic methods for maps implementing a type-specific interface.
This class handles directly a default return
value} (including methods to access
it). Instances of classes inheriting from this class have just to return
defRetValue
to denote lack of a key in type-specific methods. The value
is serialized.
Optional operations just throw an UnsupportedOperationException
. Generic versions of accessors delegate to
the corresponding type-specific counterparts following the interface rules
(they take care of returning null
on a missing key).
As a further help, this class provides a BasicEntry
inner class
that implements a type-specific version of Map.Entry
; it
is particularly useful for those classes that do not implement their own
entries (e.g., most immutable maps).
Nested Class Summary | |
static class |
AbstractChar2ShortMap.BasicEntry
This class provides a basic but complete type-specific entry class for all those maps implementations that do not have entries on their own (e.g., most immutable maps). |
Nested classes inherited from class it.unimi.dsi.fastutil.chars.Char2ShortMap |
Char2ShortMap.Entry |
Method Summary | |
void |
clear()
|
boolean |
containsKey(char k)
Checks whether the given value is contained in keySet() . |
boolean |
containsKey(Object ok)
|
boolean |
containsValue(Object ov)
|
boolean |
containsValue(short v)
Checks whether the given value is contained in values() . |
short |
defaultReturnValue()
Gets the default return value. |
void |
defaultReturnValue(short rv)
Sets the default return value. |
boolean |
equals(Object o)
|
Object |
get(Object ok)
Delegates to the corresponding type-specific method, taking care of returning null on a missing key.
|
short |
getDefRetValue()
|
int |
hashCode()
Returns a hash code for this map. |
boolean |
isEmpty()
|
Set |
keySet()
Returns a type-specific-set view of the keys of this map. |
short |
put(char key,
short value)
Adds a pair to the map. |
Object |
put(Object ok,
Object ov)
Delegates to the corresponding type-specific method, taking care of returning null on a missing key.
|
void |
putAll(Map m)
Puts all pairs in the given map. |
short |
remove(char key)
Removes the mapping with the given key. |
Object |
remove(Object ok)
Delegates to the corresponding type-specific method, taking care of returning null on a missing key.
|
void |
setDefRetValue(short rv)
|
String |
toString()
|
Collection |
values()
Returns a type-specific-set view of the values of this map. |
Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface it.unimi.dsi.fastutil.chars.Char2ShortMap |
get |
Methods inherited from interface java.util.Map |
entrySet, size |
Method Detail |
public void setDefRetValue(short rv)
setDefRetValue
in interface Char2ShortMap
rv
- the new default return value.Char2ShortMap.getDefRetValue()
,
Char2ShortMap.defaultReturnValue()
public short getDefRetValue()
getDefRetValue
in interface Char2ShortMap
Char2ShortMap.defaultReturnValue()
public void defaultReturnValue(short rv)
Char2ShortMap
get()
, put()
and remove()
to
denote that the map does not contain the specified key. It must be
0/false
/null
by default.
defaultReturnValue
in interface Char2ShortMap
rv
- the new default return value.Char2ShortMap.defaultReturnValue()
public short defaultReturnValue()
Char2ShortMap
defaultReturnValue
in interface Char2ShortMap
public short put(char key, short value)
Char2ShortMap
put
in interface Char2ShortMap
key
- the key.value
- the value.
Map.put(Object,Object)
public short remove(char key)
Char2ShortMap
remove
in interface Char2ShortMap
key
-
Map.remove(Object)
public void clear()
clear
in interface Map
public Object get(Object ok)
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.
get
in interface Map
public Object put(Object ok, Object ov)
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.
put
in interface Map
public Object remove(Object ok)
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.
remove
in interface Map
public boolean containsValue(Object ov)
containsValue
in interface Map
public boolean containsKey(Object ok)
containsKey
in interface Map
public boolean containsValue(short v)
values()
.
containsValue
in interface Char2ShortMap
Map.containsValue(Object)
public boolean containsKey(char k)
keySet()
.
containsKey
in interface Char2ShortMap
Map.containsKey(Object)
public void putAll(Map m)
putAll
in interface Map
m
- a map.public boolean isEmpty()
isEmpty
in interface Map
public Set keySet()
The view is backed by the set returned by Map.entrySet()
. Note that
no attempt is made at caching the result of this method, as this would
require adding some attributes that lightweight implementations would
not need. Subclasses may easily override this policy by calling
this method and caching the result, but implementors are encouraged to
write more efficient ad-hoc implementations.
keySet
in interface Map
public Collection values()
The view is backed by the set returned by Map.entrySet()
. Note that
no attempt is made at caching the result of this method, as this would
require adding some attributes that lightweight implementations would
not need. Subclasses may easily override this policy by calling
this method and caching the result, but implementors are encouraged to
write more efficient ad-hoc implementations.
values
in interface Map
public int hashCode()
hashCode
in interface Map
public boolean equals(Object o)
equals
in interface Map
public String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |