Package com.uwyn.jhighlight.pcj.map
Class AbstractCharKeyMap
java.lang.Object
com.uwyn.jhighlight.pcj.map.AbstractCharKeyMap
- All Implemented Interfaces:
CharKeyMap
- Direct Known Subclasses:
CharKeyOpenHashMap
This class represents an abstract base for implementing
maps from char values to objects. All operations that can be implemented
using iterators
are implemented as such. In most cases, this is
hardly an efficient solution, and at least some of those
methods should be overridden by sub-classes.
- Since:
- 1.0
- Version:
- 1.0 2003/10/1
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault constructor to be invoked by sub-classes. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears this map.booleancontainsKey(char key) Indicates whether this map contains a mapping from a specified key.booleancontainsValue(Object value) Indicates whether this map contains a mapping to a specified value.booleanIndicates whether this map is equal to some object.get(char key) Maps a specified key to a value.inthashCode()Returns a hash code value for this map.booleanisEmpty()Indicates whether this map is empty.voidputAll(CharKeyMap map) Adds all mappings from a specified map to this map.remove(char key) Removes the mapping from a specified key from this map.intsize()Returns the size of this map.toString()Returns a string representation of this map.voidDoes nothing.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.uwyn.jhighlight.pcj.map.CharKeyMap
entries, keySet, put, values
-
Constructor Details
-
AbstractCharKeyMap
protected AbstractCharKeyMap()Default constructor to be invoked by sub-classes.
-
-
Method Details
-
clear
public void clear()Description copied from interface:CharKeyMapClears this map.- Specified by:
clearin interfaceCharKeyMap
-
remove
Description copied from interface:CharKeyMapRemoves the mapping from a specified key from this map.- Specified by:
removein interfaceCharKeyMap- Parameters:
key- the key whose mapping to remove from this map.- Returns:
- the old value (which can be null) if a mapping from the specified key already existed in this map; returns null otherwise.
-
putAll
Description copied from interface:CharKeyMapAdds all mappings from a specified map to this map. Any existing mappings whose keys collide with a new mapping is overwritten by the new mapping.- Specified by:
putAllin interfaceCharKeyMap- Parameters:
map- the map whose mappings to add to this map.
-
containsKey
public boolean containsKey(char key) Description copied from interface:CharKeyMapIndicates whether this map contains a mapping from a specified key.- Specified by:
containsKeyin interfaceCharKeyMap- Parameters:
key- the key to test for.- Returns:
- true if this map contains a mapping from the specified key; returns false otherwise.
-
get
Description copied from interface:CharKeyMapMaps a specified key to a value.- Specified by:
getin interfaceCharKeyMap- Parameters:
key- the key to map to a value.- Returns:
- the value that the specified key maps to; returns null, if no mapping exists for the specified key.
-
containsValue
Description copied from interface:CharKeyMapIndicates whether this map contains a mapping to a specified value.- Specified by:
containsValuein interfaceCharKeyMap- Parameters:
value- the value to test for.- Returns:
- true if this map contains at least one mapping to the specified value; returns false otherwise.
-
equals
Description copied from interface:CharKeyMapIndicates whether this map is equal to some object.- Specified by:
equalsin interfaceCharKeyMap- Overrides:
equalsin classObject- Parameters:
obj- the object with which to compare this map.- Returns:
- true if this map is equal to the specified object; returns false otherwise.
-
hashCode
public int hashCode()Description copied from interface:CharKeyMapReturns a hash code value for this map.- Specified by:
hashCodein interfaceCharKeyMap- Overrides:
hashCodein classObject- Returns:
- a hash code value for this map.
-
isEmpty
public boolean isEmpty()Description copied from interface:CharKeyMapIndicates whether this map is empty.- Specified by:
isEmptyin interfaceCharKeyMap- Returns:
- true if this map is empty; returns false otherwise.
-
size
public int size()Description copied from interface:CharKeyMapReturns the size of this map. The size is defined as the number of mappings from keys to values.- Specified by:
sizein interfaceCharKeyMap- Returns:
- the size of this map.
-
toString
Returns a string representation of this map. -
trimToSize
public void trimToSize()Does nothing. Sub-classes may provide an implementation to minimize memory usage, but this is not required since many implementations will always have minimal memory usage.
-