APCS Java Subset

ap.java.util
Class HashMap

java.lang.Object
  extended byap.java.util.HashMap
All Implemented Interfaces:
Map

public class HashMap
extends java.lang.Object
implements Map


Constructor Summary
HashMap()
           
 
Method Summary
 boolean containsKey(java.lang.Object key)
          Returns true if there is a value associated with key in this map, otherwise returns false.
 java.lang.Object get(java.lang.Object key)
          Return the value associated with key in this map, or null if there is no value associated wit key.
 Set keySet()
          Returns a Set of the keys in the maps.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Associates value with key in this map so that get(key) returns value.
 java.lang.Object remove(java.lang.Object key)
          Removes the mapping for this key from the map and returns the value previously associated with the key in the map.
 int size()
          Return the number of keys in this map, which is the same as the number of (key,value) pairs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HashMap

public HashMap()
Method Detail

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Description copied from interface: Map
Associates value with key in this map so that get(key) returns value. If key was mapped to a different value, the previous mapping is replaced.

Specified by:
put in interface Map
Parameters:
key - is what is mapped to/associated with value
value - is what key is mapped to
Returns:
the previous value associated with key or null if there was no previous mapping.

get

public java.lang.Object get(java.lang.Object key)
Description copied from interface: Map
Return the value associated with key in this map, or null if there is no value associated wit key.

Specified by:
get in interface Map
Parameters:
key - is the key whose associated value is returned
Returns:
the value associated with key or null if there is no such value.

containsKey

public boolean containsKey(java.lang.Object key)
Description copied from interface: Map
Returns true if there is a value associated with key in this map, otherwise returns false.

Specified by:
containsKey in interface Map
Parameters:
key - is the key for which the map is queried as to the existence of an associated value
Returns:
true if there is a (key,value) pair in the map for the specified key, otherwise return false

size

public int size()
Description copied from interface: Map
Return the number of keys in this map, which is the same as the number of (key,value) pairs.

Specified by:
size in interface Map
Returns:
the number of (key,value) pairs in the map

keySet

public Set keySet()
Description copied from interface: Map
Returns a Set of the keys in the maps. Removing a key from the associated set, e.g., via an iterator, removes it from the map as well. The terminology for this is that the set is backed by the map

Specified by:
keySet in interface Map
Returns:
a set of the keys in this map

remove

public java.lang.Object remove(java.lang.Object key)
Description copied from interface: Map
Removes the mapping for this key from the map and returns the value previously associated with the key in the map. If the map contains no value associated with key then null is returned.

Specified by:
remove in interface Map
Parameters:
key - is the key whose mapping is to be removed
Returns:
the previous value associated with key or null if there was no previous mapping.

unofficial documentation for the APCS Java Subset