HashMap
Keywords: weiss.util.HashMap class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## weiss.util
Class HashMap<KeyType,ValueType>

    java.lang.Object
      weiss.util.HashMap<KeyType,ValueType>

All Implemented Interfaces:
  java.io.Serializable, Map<KeyType,ValueType>

    public class HashMap<KeyType,ValueType>

extends java.lang.Object

Hash table implementation of the Map.

See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from interface weiss.util.Map
`Map.Entry<KeyType,ValueType>`

Constructor Summary
`HashMap()` Construct an empty HashMap.
`HashMap(Map<KeyType,ValueType> other)` Construct a HashMap with same key/value pairs as another map.

Method Summary
`void` | `clear()` Removes all key value pairs from the map.
`protected Set<Map.Entry<KeyType,ValueType>>` | `clonePairSet(Set<Map.Entry<KeyType,ValueType>> pairSet)`
`boolean` | `containsKey(KeyType key)` Tests if this map contains a given key.
`Set<Map.Entry<KeyType,ValueType>>` | `entrySet()` Return a set of Map.Entry objects corresponding to the key/value pairs in the map.
`ValueType` | `get(KeyType key)` Returns the value in the map associated with the key.
`protected Set<Map.Entry<KeyType,ValueType>>` | `getSet()` Return a reference to the underlying set.
`boolean` | `isEmpty()` Tests if this map is empty.
`Set<KeyType>` | `keySet()` Returns the keys in the map.
`protected Set<KeyType>` | `makeEmptyKeySet()`
`protected Map.Entry<KeyType,ValueType>` | `makePair(KeyType key, ValueType value)`
`ValueType` | `put(KeyType key, ValueType value)` Adds the key value pair to the map, overriding the original value if the key was already present.
`ValueType` | `remove(KeyType key)` Remove the key and its value from the map.
`int` | `size()` Returns the number of keys in this map.
`java.lang.String` | `toString()`
`Collection<ValueType>` | `values()` Returns the values in the map.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### HashMap

    public HashMap()

  Construct an empty HashMap.

### HashMap

    public HashMap(Map<KeyType,ValueType> other)

  Construct a HashMap with same key/value pairs as another map.

  Parameters:
    `other` - the other map.

Method Detail

### makePair

    protected Map.Entry<KeyType,ValueType> makePair(KeyType key,
                                                    ValueType value)

### makeEmptyKeySet

    protected Set<KeyType> makeEmptyKeySet()

### clonePairSet

    protected Set<Map.Entry<KeyType,ValueType>> clonePairSet(Set<Map.Entry<KeyType,ValueType>> pairSet)

### size

    public int size()

  Returns the number of keys in this map.

  Specified by:
    `size` in interface `Map<KeyType,ValueType>`
  Returns:
    the number of keys in this collection.

### isEmpty

    public boolean isEmpty()

  Tests if this map is empty.

  Specified by:
    `isEmpty` in interface `Map<KeyType,ValueType>`
  Returns:
    true if the size of this map is zero.

### containsKey

    public boolean containsKey(KeyType key)

  Tests if this map contains a given key.

  Specified by:
    `containsKey` in interface `Map<KeyType,ValueType>`
  Parameters:
    `key` - the key to search for.
  Returns:
    true if the map contains the key.

### get

    public ValueType get(KeyType key)

  Returns the value in the map associated with the key.

  Specified by:
    `get` in interface `Map<KeyType,ValueType>`
  Parameters:
    `key` - the key to search for.
  Returns:
    the value that matches the key or null if the key is not found. Since null values are allowed, checking if the return value is null may not be a safe way to ascertain if the key is present in the map.

### put

    public ValueType put(KeyType key,
                         ValueType value)

  Adds the key value pair to the map, overriding the original value if the key was already present.

  Specified by:
    `put` in interface `Map<KeyType,ValueType>`
  Parameters:
    `key` - the key to insert.
    `value` - the value to insert.
  Returns:
    the old value associated with the key, or null if the key was not present prior to this call.

### remove

    public ValueType remove(KeyType key)

  Remove the key and its value from the map.

  Specified by:
    `remove` in interface `Map<KeyType,ValueType>`
  Parameters:
    `key` - the key to remove.
  Returns:
    the previous value associated with the key, or null if the key was not present prior to this call.

### clear

    public void clear()

  Removes all key value pairs from the map.

  Specified by:
    `clear` in interface `Map<KeyType,ValueType>`

### keySet

    public Set<KeyType> keySet()

  Returns the keys in the map. These semantics are different from those in java.util because in this class, changes made to the returned key set do not cause changes to be reflected in the map.

  Specified by:
    `keySet` in interface `Map<KeyType,ValueType>`
  Returns:
    the keys in the map.

### values

    public Collection<ValueType> values()

  Returns the values in the map. There may be duplicates. These semantics are different from those in java.util because in this class, changes made to the returned value collection do not cause changes to be reflected in the map.

  Specified by:
    `values` in interface `Map<KeyType,ValueType>`
  Returns:
    the values in the map.

### entrySet

    public Set<Map.Entry<KeyType,ValueType>> entrySet()

  Return a set of Map.Entry objects corresponding to the key/value pairs in the map.

  Specified by:
    `entrySet` in interface `Map<KeyType,ValueType>`
  Returns:
    the key/value pairs in the map.

### getSet

    protected Set<Map.Entry<KeyType,ValueType>> getSet()

  Return a reference to the underlying set.

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD