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

## rice.p2p.util
Class ImmutableSortedMap

    java.lang.Object
      rice.p2p.util.ImmutableSortedMap

All Implemented Interfaces:
  java.io.Serializable, java.util.Map, java.util.SortedMap

    public class ImmutableSortedMap

extends java.lang.Object
implements java.util.SortedMap, java.io.Serializable

Version:
  $Id: ImmutableSortedMap.java 4654 2009-01-08 16:33:07Z jeffh $
Author:
  Alan Mislove
See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from interface java.util.Map
`java.util.Map.Entry<K,V>`

Field Summary
`protected java.util.SortedMap` | `map`

Constructor Summary
`ImmutableSortedMap(java.util.SortedMap map)` Constructor which takes an existing map

Method Summary
`void` | `clear()` Removes all mappings from this map (optional operation).
`java.util.Comparator` | `comparator()` Returns the comparator associated with this sorted map, or `null` if it uses its keys' natural ordering.
`boolean` | `containsKey(java.lang.Object key)` Returns `true` if this map contains a mapping for the specified key.
`boolean` | `containsValue(java.lang.Object value)` Returns `true` if this map maps one or more keys to the specified value.
`java.util.Set` | `entrySet()` Returns a set view of the mappings contained in this map.
`java.lang.Object` | `firstKey()` Returns the first (lowest) key currently in this sorted map.
`java.lang.Object` | `get(java.lang.Object key)` Returns the value to which this map maps the specified key.
`java.util.SortedMap` | `headMap(java.lang.Object toKey)` Returns a view of the portion of this sorted map whose keys are strictly less than toKey.
`boolean` | `isEmpty()` Returns `true` if this map contains no key-value mappings.
`java.util.Set` | `keySet()` Returns a set view of the keys contained in this map.
`java.lang.Object` | `lastKey()` Returns the last (highest) key currently in this sorted map.
`java.lang.Object` | `put(java.lang.Object key, java.lang.Object value)` Associates the specified value with the specified key in this map (optional operation).
`void` | `putAll(java.util.Map t)` Copies all of the mappings from the specified map to this map (optional operation).
`java.lang.Object` | `remove(java.lang.Object key)` Removes the mapping for this key from this map if it is present (optional operation).
`int` | `size()` Returns the number of key-value mappings in this map.
`java.util.SortedMap` | `subMap(java.lang.Object fromKey, java.lang.Object toKey)` Returns a view of the portion of this sorted map whose keys range from `fromKey`, inclusive, to `toKey`, exclusive.
`java.util.SortedMap` | `tailMap(java.lang.Object fromKey)` Returns a view of the portion of this sorted map whose keys are greater than or equal to `fromKey`.
`java.util.Collection` | `values()` Returns a collection view of the values contained in this map.

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

Methods inherited from interface java.util.Map
`equals, hashCode`

Field Detail

### map

    protected java.util.SortedMap map

Constructor Detail

### ImmutableSortedMap

    public ImmutableSortedMap(java.util.SortedMap map)

  Constructor which takes an existing map

  Parameters:
    `map` - the existing map

Method Detail

### comparator

    public java.util.Comparator comparator()

  Returns the comparator associated with this sorted map, or `null` if it uses its keys' natural ordering.

  Specified by:
    `comparator` in interface `java.util.SortedMap`
  Returns:
    the comparator associated with this sorted map, or `null` if it uses its keys' natural ordering.

### subMap

    public java.util.SortedMap subMap(java.lang.Object fromKey,
                                      java.lang.Object toKey)

  Returns a view of the portion of this sorted map whose keys range from `fromKey`, inclusive, to `toKey`, exclusive.

  Specified by:
    `subMap` in interface `java.util.SortedMap`
  Parameters:
    `fromKey` - low endpoint (inclusive) of the subMap.
    `toKey` - high endpoint (exclusive) of the subMap.
  Returns:
    a view of the specified range within this sorted map.

### headMap

    public java.util.SortedMap headMap(java.lang.Object toKey)

  Returns a view of the portion of this sorted map whose keys are strictly less than toKey.

  Specified by:
    `headMap` in interface `java.util.SortedMap`
  Parameters:
    `toKey` - high endpoint (exclusive) of the subMap.
  Returns:
    a view of the specified initial range of this sorted map.

### tailMap

    public java.util.SortedMap tailMap(java.lang.Object fromKey)

  Returns a view of the portion of this sorted map whose keys are greater than or equal to `fromKey`.

  Specified by:
    `tailMap` in interface `java.util.SortedMap`
  Parameters:
    `fromKey` - low endpoint (inclusive) of the tailMap.
  Returns:
    a view of the specified final range of this sorted map.

### firstKey

    public java.lang.Object firstKey()

  Returns the first (lowest) key currently in this sorted map.

  Specified by:
    `firstKey` in interface `java.util.SortedMap`
  Returns:
    the first (lowest) key currently in this sorted map.
  Throws:
    `java.util.NoSuchElementException` - if this map is empty.

### lastKey

    public java.lang.Object lastKey()

  Returns the last (highest) key currently in this sorted map.

  Specified by:
    `lastKey` in interface `java.util.SortedMap`
  Returns:
    the last (highest) key currently in this sorted map.
  Throws:
    `java.util.NoSuchElementException` - if this map is empty.

### size

    public int size()

  Returns the number of key-value mappings in this map. If the map contains more than `Integer.MAX_VALUE` elements, returns `Integer.MAX_VALUE`.

  Specified by:
    `size` in interface `java.util.Map`
  Returns:
    the number of key-value mappings in this map.

### isEmpty

    public boolean isEmpty()

  Returns `true` if this map contains no key-value mappings.

  Specified by:
    `isEmpty` in interface `java.util.Map`
  Returns:
    `true` if this map contains no key-value mappings.

### containsKey

    public boolean containsKey(java.lang.Object key)

  Returns `true` if this map contains a mapping for the specified key.

  Specified by:
    `containsKey` in interface `java.util.Map`
  Parameters:
    `key` - key whose presence in this map is to be tested.
  Returns:
    `true` if this map contains a mapping for the specified

### containsValue

    public boolean containsValue(java.lang.Object value)

  Returns `true` if this map maps one or more keys to the specified value.

  Specified by:
    `containsValue` in interface `java.util.Map`
  Parameters:
    `value` - value whose presence in this map is to be tested.
  Returns:
    `true` if this map maps one or more keys to the specified value.

### get

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

  Returns the value to which this map maps the specified key. Returns `null` if the map contains no mapping for this key.

  Specified by:
    `get` in interface `java.util.Map`
  Parameters:
    `key` - key whose associated value is to be returned.
  Returns:
    the value to which this map maps the specified key, or `null` if the map contains no mapping for this key.

### put

    public java.lang.Object put(java.lang.Object key,
                                java.lang.Object value)

  Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for this key, the old value is replaced by the specified value.

  Specified by:
    `put` in interface `java.util.Map`
  Parameters:
    `key` - key with which the specified value is to be associated.
    `value` - value to be associated with the specified key.
  Returns:
    previous value associated with specified key, or `null` if there was no mapping for key. A `null` return can also indicate that the map previously associated `null` with the specified key, if the implementation supports `null` values.
  Throws:
    `java.lang.UnsupportedOperationException` - if the `put` operation is not supported by this map.

### remove

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

  Removes the mapping for this key from this map if it is present (optional operation). More formally, if this map contains a mapping from key `k` to value `v` such that `(key==null ? k==null : key.equals(k))`, that mapping is removed.

  Specified by:
    `remove` in interface `java.util.Map`
  Parameters:
    `key` - key whose mapping is to be removed from the map.
  Returns:
    previous value associated with specified key, or `null` if there was no mapping for key.

### putAll

    public void putAll(java.util.Map t)

  Copies all of the mappings from the specified map to this map (optional operation).

  Specified by:
    `putAll` in interface `java.util.Map`
  Parameters:
    `t` - Mappings to be stored in this map.

### clear

    public void clear()

  Removes all mappings from this map (optional operation).

  Specified by:
    `clear` in interface `java.util.Map`
  Throws:
    `java.lang.UnsupportedOperationException` - clear is not supported by this map.

### keySet

    public java.util.Set keySet()

  Returns a set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the `Iterator.remove`, `Set.remove`, `removeAll` `retainAll`, and `clear` operations. It does not support the add or `addAll` operations.

  Specified by:
    `keySet` in interface `java.util.Map`
  Specified by:
    `keySet` in interface `java.util.SortedMap`
  Returns:
    a set view of the keys contained in this map.

### values

    public java.util.Collection values()

  Returns a collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress, the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the `Iterator.remove`, `Collection.remove`, `removeAll`, `retainAll` and `clear` operations. It does not support the add or `addAll` operations.

  Specified by:
    `values` in interface `java.util.Map`
  Specified by:
    `values` in interface `java.util.SortedMap`
  Returns:
    a collection view of the values contained in this map.

### entrySet

    public java.util.Set entrySet()

  Returns a set view of the mappings contained in this map. Each element in the returned set is a `Map.Entry`. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the `Iterator.remove`, `Set.remove`, `removeAll`, `retainAll` and `clear` operations. It does not support the `add` or `addAll` operations.

  Specified by:
    `entrySet` in interface `java.util.Map`
  Specified by:
    `entrySet` in interface `java.util.SortedMap`
  Returns:
    a set view of the mappings contained in this map.

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

Copyright © 2001-2005 - Rice Pastry.