PCJ API
Version 1.2

bak.pcj.map
Interface LongKeyIntMap

All Known Implementing Classes:
AbstractLongKeyIntMap, LongKeyIntChainedHashMap, LongKeyIntOpenHashMap, MapToLongKeyIntMapAdapter

public interface LongKeyIntMap

This interface represents maps from long values to int values. It is not possible to obtain a set of entries from primitive collections maps. Instead, an iterator over entries can be obtained. This removes a number of implementation constraints imposed by having to implement an entry interface.

Since:
1.0
See Also:
LongKeyIntMapIterator, Map

Method Summary
 void clear()
          Clears this map.
 boolean containsKey(long key)
          Indicates whether this map contains a mapping from a specified key.
 boolean containsValue(int value)
          Indicates whether this map contains a mapping to a specified value.
 LongKeyIntMapIterator entries()
          Returns an iterator over the entries of this map.
 boolean equals(Object obj)
          Indicates whether this map is equal to some object.
 int 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.
 LongSet keySet()
          Returns a set view of the keys of this map.
 int lget()
          Returns the last value corresponding to a positive result from containsKey(long).
 int put(long key, int value)
          Adds a mapping from a specified key to a specified value to this map.
 void putAll(LongKeyIntMap map)
          Adds all mappings from a specified map to this map.
 int remove(long key)
          Removes the mapping from a specified key from this map.
 int size()
          Returns the size of this map.
 int tget(long key)
          Maps a specified key to a value.
 void trimToSize()
          Minimizes the memory used by this map.
 IntCollection values()
          Returns a collection view of the values in this map.
 

Method Detail

clear

public void clear()
Clears this map.

Throws:
UnsupportedOperationException - if the operation is not supported by this map.

containsKey

public boolean containsKey(long key)
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.

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

containsValue

public boolean containsValue(int value)
Indicates whether this map contains a mapping to a specified value.

Parameters:
value - the value to test for.
Returns:
true if this map contains at least one mapping to the specified value; returns false otherwise.

entries

public LongKeyIntMapIterator entries()
Returns an iterator over the entries of this map. It is possible to remove entries from this map using the iterator provided that the concrete map supports removal of entries.

Returns:
an iterator over the entries of this map.

equals

public boolean equals(Object obj)
Indicates whether this map is equal to some object.

Parameters:
obj - the object with which to compare this map.
Returns:
true if this map is equal to the specified object; returns false otherwise.

get

public int get(long key)
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.

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, tget(long), lget()

hashCode

public int hashCode()
Returns a hash code value for this map.

Returns:
a hash code value for this map.

isEmpty

public boolean isEmpty()
Indicates whether this map is empty.

Returns:
true if this map is empty; returns false otherwise.

keySet

public LongSet keySet()
Returns a set view of the keys of this map. Removals from the returned set removes the corresponding entries in this map. Changes to the map are reflected in the set.

Returns:
a set view of the keys of this map.

lget

public int lget()
Returns the last value corresponding to a positive result from containsKey(long). This is useful for checking checking the existence of a mapping while avoiding two lookups on the same key.

Returns:
the value corresponding to the key from the last invokation of containsKey(long).
Throws:
IllegalStateException - if containsKey(long) has not been called or the last call resulted in a return value of false.
See Also:
get(long), tget(long), containsKey(long)

put

public int put(long key,
               int value)
Adds a mapping from a specified key to a specified value to this map. If a mapping already exists for the specified key it is overwritten by the new mapping.

Parameters:
key - the key of the mapping to add to this map.
value - the value of the mapping to add to 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.
Throws:
UnsupportedOperationException - if the operation is not supported by this map.
See Also:
MapDefaults

putAll

public void putAll(LongKeyIntMap map)
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.

Parameters:
map - the map whose mappings to add to this map.
Throws:
NullPointerException - if map is null.
UnsupportedOperationException - if the operation is not supported by this map.

remove

public int remove(long key)
Removes the mapping from a specified key from this map.

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.
Throws:
UnsupportedOperationException - if the operation is not supported by this map.
See Also:
MapDefaults

size

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

Returns:
the size of this map.

tget

public int tget(long key)
Maps a specified key to a value. This method should be used when the key is known to be in the map.

Parameters:
key - the key to map to a value.
Returns:
the value that the specified key maps to.
Throws:
NoSuchMappingException - if the specified key does not map to any value.
See Also:
get(long), lget()

trimToSize

public void trimToSize()
Minimizes the memory used by this map. The exact operation of this method depends on the class implementing it. Implementors may choose to ignore it completely.


values

public IntCollection values()
Returns a collection view of the values in this map. The collection is not modifiable, but changes to the map are reflected in the collection.

Returns:
a collection view of the values in this map.

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