PCJ API
Version 1.2

bak.pcj.map
Class AbstractLongKeyBooleanMap

java.lang.Object
  extended bybak.pcj.map.AbstractLongKeyBooleanMap
All Implemented Interfaces:
LongKeyBooleanMap
Direct Known Subclasses:
LongKeyBooleanChainedHashMap, LongKeyBooleanOpenHashMap, MapToLongKeyBooleanMapAdapter

public abstract class AbstractLongKeyBooleanMap
extends Object
implements LongKeyBooleanMap

This class represents an abstract base for implementing maps from long values to boolean values. 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

Constructor Summary
protected AbstractLongKeyBooleanMap()
          Default constructor to be invoked by sub-classes.
 
Method Summary
 void clear()
          Clears this map.
 boolean containsKey(long key)
          Indicates whether this map contains a mapping from a specified key.
 boolean containsValue(boolean value)
          Indicates whether this map contains a mapping to a specified value.
 boolean equals(Object obj)
          Indicates whether this map is equal to some object.
 boolean get(long key)
          Maps a specified key to a value.
 int hashCode()
          Returns a hash code value for this map.
 boolean isEmpty()
          Indicates whether this map is empty.
 void putAll(LongKeyBooleanMap map)
          Adds all mappings from a specified map to this map.
 boolean remove(long key)
          Removes the mapping from a specified key from this map.
 int size()
          Returns the size of this map.
 boolean tget(long key)
          Maps a specified key to a value.
 String toString()
          Returns a string representation of this map.
 void trimToSize()
          Does nothing.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface bak.pcj.map.LongKeyBooleanMap
entries, keySet, lget, put, values
 

Constructor Detail

AbstractLongKeyBooleanMap

protected AbstractLongKeyBooleanMap()
Default constructor to be invoked by sub-classes.

Method Detail

clear

public void clear()
Description copied from interface: LongKeyBooleanMap
Clears this map.

Specified by:
clear in interface LongKeyBooleanMap

remove

public boolean remove(long key)
Description copied from interface: LongKeyBooleanMap
Removes the mapping from a specified key from this map.

Specified by:
remove in interface LongKeyBooleanMap
Parameters:
key - the key whose mapping to remove from this map.
Returns:
the old value if a mapping from the specified key already existed in this map; otherwise returns a default value as specified by the MapDefaults class.
See Also:
MapDefaults

putAll

public void putAll(LongKeyBooleanMap map)
Description copied from interface: LongKeyBooleanMap
Adds 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:
putAll in interface LongKeyBooleanMap
Parameters:
map - the map whose mappings to add to this map.

containsKey

public boolean containsKey(long key)
Description copied from interface: LongKeyBooleanMap
Indicates whether this map contains a mapping from a specified key. If the key is contained in this map, a succeeding call to lget() will return the corresponding value.

Specified by:
containsKey in interface LongKeyBooleanMap
Parameters:
key - the key to test for.
Returns:
true if this map contains a mapping from the specified key; returns false otherwise.
See Also:
LongKeyBooleanMap.lget()

get

public boolean get(long key)
Description copied from interface: LongKeyBooleanMap
Maps a specified key to a value. Returns a default value as specified by the MapDefaults class if no mapping exists for the specified key.

Specified by:
get in interface LongKeyBooleanMap
Parameters:
key - the key to map to a value.
Returns:
the value that the specified key maps to, or a default value, if no such mapping exists.
See Also:
MapDefaults, LongKeyBooleanMap.tget(long), LongKeyBooleanMap.lget()

containsValue

public boolean containsValue(boolean value)
Description copied from interface: LongKeyBooleanMap
Indicates whether this map contains a mapping to a specified value.

Specified by:
containsValue in interface LongKeyBooleanMap
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

public boolean equals(Object obj)
Description copied from interface: LongKeyBooleanMap
Indicates whether this map is equal to some object.

Specified by:
equals in interface LongKeyBooleanMap

hashCode

public int hashCode()
Description copied from interface: LongKeyBooleanMap
Returns a hash code value for this map.

Specified by:
hashCode in interface LongKeyBooleanMap

isEmpty

public boolean isEmpty()
Description copied from interface: LongKeyBooleanMap
Indicates whether this map is empty.

Specified by:
isEmpty in interface LongKeyBooleanMap
Returns:
true if this map is empty; returns false otherwise.

size

public int size()
Description copied from interface: LongKeyBooleanMap
Returns the size of this map. The size is defined as the number of mappings from keys to values.

Specified by:
size in interface LongKeyBooleanMap
Returns:
the size of this map.

tget

public boolean tget(long key)
Description copied from interface: LongKeyBooleanMap
Maps a specified key to a value. This method should be used when the key is known to be in the map.

Specified by:
tget in interface LongKeyBooleanMap
Parameters:
key - the key to map to a value.
Returns:
the value that the specified key maps to.
See Also:
LongKeyBooleanMap.get(long), LongKeyBooleanMap.lget()

toString

public String toString()
Returns a string representation of this map.

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.

Specified by:
trimToSize in interface LongKeyBooleanMap

PCJ API
Version 1.2

Report a bug or request a feature.
Further information on the development and latest release of PCJ can be found at the project homepage.

Primitive Collections for Java is released under the GNU Lesser General Public License.
Copyright © 2002, 2003 Søren Bak. All Rights Reserved.

Hosted by SourceForge.net
SourceForge.net Logo