Skip navigation links

Overview | Package | Class | Tree | Index | Help
| Oracle® Coherence Java API Reference Release 3.6.1.0 E18814-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.tangosol.util
Class SafeSortedMap.ViewMap

`java.lang.Object
java.util.AbstractMap
com.tangosol.util.SafeSortedMap.ViewMap`

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

Enclosing class:
  SafeSortedMap

      protected class SafeSortedMap.ViewMap

extends java.util.AbstractMap
implements java.util.SortedMap

ViewMap provides a SortedMap view over a subset of the SafeSortedMap. A ViewMap may have an inclusive lower and/or an exclusive upper bound.

For example, a ViewMap defined on an SafeSortedMap of Integer keys with lower bound 3 and upper bound 7 would contain any keys in the underlying SafeSortedMap in the range [3, 7).

Nested Class Summary
`protected class` | `SafeSortedMap.ViewMap.EntryIterator` An Iterator over the Entries backed by this ViewMap.
`protected class` | `SafeSortedMap.ViewMap.EntrySet` A Set of Entries backed by this ViewMap.

Nested classes/interfaces inherited from interface java.util.Map
`java.util.Map.Entry`

Field Summary
`protected java.lang.Object` | `m_oKeyLower` The key that this ViewMap is (inclusively) lower-bounded by, or null for no lower-bound.
`protected java.lang.Object` | `m_oKeyUpper` The key that this ViewMap is (exclusively) upper-bounded by, or null for no upper-bound

Constructor Summary
`protected` | `SafeSortedMap.ViewMap(java.lang.Object oKeyLower, java.lang.Object oKeyUpper)` Create a new ViewMap over the SafeSortedMap bounded by the specified keys, or null for no-bound.

Method Summary
`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 oKey)` Returns `true` if this map contains a mapping for the specified key.
`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.
`protected SafeSortedMap.EntryNode` | `firstNode()` Return the first Node in this ViewMap, or null if there are none.
`java.lang.Object` | `get(java.lang.Object oKey)` Returns the value to which this map maps the specified key.
`protected java.lang.Object` | `getLowerBound()` Return the lower bound of this ViewMap.
`protected java.lang.Object` | `getUpperBound()` Return the upper bound of this ViewMap.
`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.
`protected boolean` | `inRange(java.lang.Object oKey)` Is the specified key in the range represented by this ViewMap?
`java.lang.Object` | `lastKey()` Returns the last (highest) key currently in this sorted map.
`protected SafeSortedMap.EntryNode` | `lastNode()` Return the last SkipNode in this ViewMap, or null if there are none.
`java.lang.Object` | `put(java.lang.Object oKey, java.lang.Object oValue)` Associates the specified value with the specified key in this map (optional operation).
`java.lang.Object` | `remove(java.lang.Object oKey)` Removes the mapping for this key from this map if present (optional operation).
`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`.

Methods inherited from class java.util.AbstractMap
`clear, clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, size, toString, values`

Methods inherited from interface java.util.Map
`clear, containsValue, equals, hashCode, isEmpty, keySet, putAll, size, values`

Field Detail

### m_oKeyLower

    protected final java.lang.Object m_oKeyLower

  The key that this ViewMap is (inclusively) lower-bounded by, or null for no lower-bound.

### m_oKeyUpper

    protected final java.lang.Object m_oKeyUpper

  The key that this ViewMap is (exclusively) upper-bounded by, or null for no upper-bound

Constructor Detail

### SafeSortedMap.ViewMap

    protected SafeSortedMap.ViewMap(java.lang.Object oKeyLower,
                                    java.lang.Object oKeyUpper)

  Create a new ViewMap over the SafeSortedMap bounded by the specified keys, or null for no-bound.
  Parameters:
    `oKeyLower` - the (inclusive) lower-bound key, or null
    `oKeyUpper` - the (exclusive) upper-bound key, or null

Method Detail

### entrySet

    public java.util.Set entrySet()

  Returns a set view of the mappings contained in this map. Each element in this 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 entry 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 class `java.util.AbstractMap`
  Returns:
    a set view of the mappings contained in this map.

### put

    public java.lang.Object put(java.lang.Object oKey,
                                java.lang.Object oValue)

  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.

  This implementation always throws an `UnsupportedOperationException`.

  Specified by:
    `put` in interface `java.util.Map`
  Overrides:
    `put` in class `java.util.AbstractMap`
  Parameters:
    `oKey` - key with which the specified value is to be associated.
    `oValue` - 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.)

### get

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

  Returns the value to which this map maps the specified key. Returns `null` if the map contains no mapping for this key. A return value of `null` does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to `null`. The containsKey operation may be used to distinguish these two cases.

  This implementation iterates over `entrySet()` searching for an entry with the specified key. If such an entry is found, the entry's value is returned. If the iteration terminates without finding such an entry, `null` is returned. Note that this implementation requires linear time in the size of the map; many implementations will override this method.

  Specified by:
    `get` in interface `java.util.Map`
  Overrides:
    `get` in class `java.util.AbstractMap`
  Parameters:
    `oKey` - key whose associated value is to be returned.
  Returns:
    the value to which this map maps the specified key.
  See Also:
    `AbstractMap.containsKey(Object)`

### containsKey

    public boolean containsKey(java.lang.Object oKey)

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

  This implementation iterates over `entrySet()` searching for an entry with the specified key. If such an entry is found, `true` is returned. If the iteration terminates without finding such an entry, `false` is returned. Note that this implementation requires linear time in the size of the map; many implementations will override this method.

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

### remove

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

  Removes the mapping for this key from this map if present (optional operation).

  This implementation iterates over `entrySet()` searching for an entry with the specified key. If such an entry is found, its value is obtained with its `getValue` operation, the entry is removed from the Collection (and the backing map) with the iterator's `remove` operation, and the saved value is returned. If the iteration terminates without finding such an entry, `null` is returned. Note that this implementation requires linear time in the size of the map; many implementations will override this method.

  Note that this implementation throws an `UnsupportedOperationException` if the `entrySet` iterator does not support the `remove` method and this map contains a mapping for the specified key.

  Specified by:
    `remove` in interface `java.util.Map`
  Overrides:
    `remove` in class `java.util.AbstractMap`
  Parameters:
    `oKey` - key whose mapping is to be removed from the map.
  Returns:
    previous value associated with specified key, or `null` if there was no entry for key. (A `null` return can also indicate that the map previously associated `null` with the specified key, if the implementation supports `null` values.)

### 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. (If `fromKey` and `toKey` are equal, the returned sorted map is empty.) The returned sorted map is backed by this sorted map, so changes in the returned sorted map are reflected in this sorted map, and vice-versa. The returned Map supports all optional map operations that this sorted map supports.

  The map returned by this method will throw an `IllegalArgumentException` if the user attempts to insert a key outside the specified range.

  Note: this method always returns a half-open range (which includes its low endpoint but not its high endpoint). If you need a closed range (which includes both endpoints), and the key type allows for calculation of the successor a given key, merely request the subrange from `lowEndpoint` to `successor(highEndpoint)`. For example, suppose that `m` is a map whose keys are strings. The following idiom obtains a view containing all of the key-value mappings in `m` whose keys are between `low` and `high`, inclusive:

          Map sub = m.subMap(low, high+"\0");

  A similarly technique can be used to generate an open range (which contains neither endpoint). The following idiom obtains a view containing all of the key-value mappings in `m` whose keys are between `low` and `high`, exclusive:

          Map sub = m.subMap(low+"\0", high);

  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. The returned sorted map is backed by this sorted map, so changes in the returned sorted map are reflected in this sorted map, and vice-versa. The returned map supports all optional map operations that this sorted map supports.

  The map returned by this method will throw an IllegalArgumentException if the user attempts to insert a key outside the specified range.

  Note: this method always returns a view that does not contain its (high) endpoint. If you need a view that does contain this endpoint, and the key type allows for calculation of the successor a given key, merely request a headMap bounded by successor(highEndpoint). For example, suppose that suppose that `m` is a map whose keys are strings. The following idiom obtains a view containing all of the key-value mappings in `m` whose keys are less than or equal to `high`:

          Map head = m.headMap(high+"\0");

  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`. The returned sorted map is backed by this sorted map, so changes in the returned sorted map are reflected in this sorted map, and vice-versa. The returned map supports all optional map operations that this sorted map supports.

  The map returned by this method will throw an `IllegalArgumentException` if the user attempts to insert a key outside the specified range.

  Note: this method always returns a view that contains its (low) endpoint. If you need a view that does not contain this endpoint, and the element type allows for calculation of the successor a given value, merely request a tailMap bounded by `successor(lowEndpoint)`. For example, suppose that suppose that `m` is a map whose keys are strings. The following idiom obtains a view containing all of the key-value mappings in `m` whose keys are strictly greater than `low`:

          Map tail = m.tailMap(low+"\0");

  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.

### 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.

### getLowerBound

    protected java.lang.Object getLowerBound()

  Return the lower bound of this ViewMap.
  Returns:
    the lower bound of this ViewMap

### getUpperBound

    protected java.lang.Object getUpperBound()

  Return the upper bound of this ViewMap.
  Returns:
    the upper bound of this ViewMap

### inRange

    protected boolean inRange(java.lang.Object oKey)

  Is the specified key in the range represented by this ViewMap?
  Parameters:
    `oKey` - the key to test for
  Returns:
    true iff the specified key is in the range represented by this ViewMap

### firstNode

    protected SafeSortedMap.EntryNode firstNode()

  Return the first Node in this ViewMap, or null if there are none.
  Returns:
    the first Node or null if empty, or null

### lastNode

    protected SafeSortedMap.EntryNode lastNode()

  Return the last SkipNode in this ViewMap, or null if there are none.
  Returns:
    the last SkipNode in this ViewMap, or null

Skip navigation links

Overview | Package | Class | Tree | Index | Help
| Oracle® Coherence Java API Reference Release 3.6.1.0 E18814-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.