: Class TreeMap

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

## weiss.util
Class TreeMap

    java.lang.Object
      |
      +--weiss.util.MapImpl
            |
            +--weiss.util.TreeMap

All Implemented Interfaces:
  Map, java.io.Serializable

public class TreeMap
extends weiss.util.MapImpl

Balanced search tree implementation of the Map.

See Also:
  Serialized Form

Inner classes inherited from class weiss.util.Map
`Map.Entry`

Constructor Summary
`TreeMap()` Construct an empty TreeMap with default comparator.
`TreeMap(Comparator comparator)` Construct a TreeMap using comparator.
`TreeMap(Map other)` Construct a TreeMap with same key/value pairs and comparator as another map..

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

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

Constructor Detail

### TreeMap

    public TreeMap()

  Construct an empty TreeMap with default comparator.

### TreeMap

    public TreeMap(Comparator comparator)

  Construct a TreeMap using comparator.
  Parameters:
    `cmp` - the comparator.

### TreeMap

    public TreeMap(Map other)

  Construct a TreeMap with same key/value pairs and comparator as another map..
  Parameters:
    `other` - the other map.

Method Detail

### comparator

    public Comparator comparator()

  Gets the comparator; returns null if default.
  Returns:
    the comparator or if null if default is used.

### makePair

    protected Map.Entry makePair(java.lang.Object key,
                                 java.lang.Object value)

  Overrides:
    `makePair` in class `weiss.util.MapImpl`

### makeEmptyKeySet

    protected Set makeEmptyKeySet()

  Overrides:
    `makeEmptyKeySet` in class `weiss.util.MapImpl`

### clonePairSet

    protected Set clonePairSet(Set pairSet)

  Overrides:
    `clonePairSet` in class `weiss.util.MapImpl`

### size

    public int size()

  Returns the number of keys in this map.
  Specified by:
    `size` in interface `Map`
  Returns:
    the number of keys in this collection.

### isEmpty

    public boolean isEmpty()

  Tests if this map is empty.
  Specified by:
    `isEmpty` in interface `Map`
  Returns:
    true if the size of this map is zero.

### containsKey

    public boolean containsKey(java.lang.Object key)

  Tests if this map contains a given key.
  Specified by:
    `containsKey` in interface `Map`
  Parameters:
    `key` - the key to search for.
  Returns:
    true if the map contains the key.

### get

    public java.lang.Object get(java.lang.Object key)

  Returns the value in the map associated with the key.
  Specified by:
    `get` in interface `Map`
  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 java.lang.Object put(java.lang.Object key,
                                java.lang.Object 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`
  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 java.lang.Object remove(java.lang.Object key)

  Remove the key and its value from the map.
  Specified by:
    `remove` in interface `Map`
  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`

### keySet

    public Set 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`

### values

    public Collection 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`

### entrySet

    public Set entrySet()

  Return a set of Map.Entry objects corresponding to the key/value pairs in the map. These semantics are different from those in java.util because in this class, changes made to the returned key/value set do not cause changes to be reflected in the map.
  Specified by:
    `entrySet` in interface `Map`

### getSet

    protected Set getSet()

  Return a reference to the underlying set.

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