Skip navigation links

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

## com.tangosol.util
Class LiteMap

`java.lang.Object
java.util.AbstractMap
com.tangosol.util.LiteMap`

All Implemented Interfaces:
  ExternalizableLite, Externalizable, Serializable, Cloneable, Map

      public class LiteMap

extends AbstractMap
implements Cloneable, Externalizable, ExternalizableLite

An implementation of java.util.Map that is optimal (in terms of both size and speed) for very small sets of data but still works excellently with large sets of data. This implementation is not thread-safe.

The LiteMap implementation switches at runtime between several different sub-implementations for storing the Map of objects, described here:

1. "empty map" - a map that contains no data;
2. "single entry" - a reference directly to a single map entry
3. "Object[]" - a reference to an array of entries; the item limit for this implementation is determined by the THRESHOLD constant;
4. "delegation" - for more than THRESHOLD items, a map is created to delegate the map management to; sub-classes can override the default delegation class (java.util.HashMap) by overriding the factory method instantiateMap.

The LiteMap implementation supports the null key value.

Author:
  cp 06/29/99

Nested Class Summary
`static class` | `LiteMap.EntryIterator` A simple Iterator for LiteMap Entry objects.
`protected class` | `LiteMap.EntrySet` A Set of entries backed by this Map.

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

Constructor Summary
`LiteMap()` Construct a LiteMap.
`LiteMap(Map map)` Construct a LiteMap with the same mappings as the given map.

Method Summary
`protected void` | `checkShrinkFromOther()` After a mutation operation has reduced the size of an underlying Map, check if the delegation model should be replaced with a more size- efficient storage approach, and switch accordingly.
`void` | `clear()` Clear all key/value mappings.
`Object` | `clone()` Create a clone of the ImmutableArrayList.
`boolean` | `containsKey(Object oKey)` Returns `true` if this map contains a mapping for the specified key.
`Set` | `entrySet()` Returns a set view of the mappings contained in this map.
`Object` | `get(Object oKey)` Returns the value to which this map maps the specified key.
`protected Map.Entry` | `instantiateEntry(Object key, Object value)` (Factory pattern) Instantiate a Map Entry.
`protected Set` | `instantiateEntrySet()` (Factory pattern) Instantiate an Entry Set.
`protected Map` | `instantiateMap()` (Factory pattern) Instantiate a Map object to store entries in once the "lite" threshold has been exceeded.
`boolean` | `isEmpty()` Returns `true` if this map contains no key-value mappings.
`Object` | `put(Object oKey, Object oValue)` Associates the specified value with the specified key in this map.
`void` | `readExternal(DataInput in)` Restore the contents of this object by loading the object's state from the passed DataInput object.
`void` | `readExternal(ObjectInput in)` Initialize this object from the data in the passed ObjectInput stream.
`Object` | `remove(Object oKey)` Removes the mapping for this key from this map if present.
`int` | `size()` Returns the number of key-value mappings in this map.
`void` | `writeExternal(DataOutput out)` Save the contents of this object by storing the object's state into the passed DataOutput object.
`void` | `writeExternal(ObjectOutput out)` Write this object's data to the passed ObjectOutput stream.

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

Constructor Detail

### LiteMap

    public LiteMap()

  Construct a LiteMap.

### LiteMap

    public LiteMap(Map map)

  Construct a LiteMap with the same mappings as the given map.
  Parameters:
    `map` - the map whose mappings are to be placed in this map.

Method Detail

### isEmpty

    public boolean isEmpty()

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

### size

    public int size()

  Returns the number of key-value mappings in this map.
  Specified by:
    `size` in interface `Map`
  Overrides:
    `size` in class `AbstractMap`
  Returns:
    the number of key-value mappings in this map

### containsKey

    public boolean containsKey(Object oKey)

  Returns `true` if this map contains a mapping for the specified key.
  Specified by:
    `containsKey` in interface `Map`
  Overrides:
    `containsKey` in class `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, `false` otherwise.

### get

    public Object get(Object oKey)

  Returns the value to which this map maps the specified key.
  Specified by:
    `get` in interface `Map`
  Overrides:
    `get` in class `AbstractMap`
  Parameters:
    `oKey` - the key object
  Returns:
    the value to which this map maps the specified key, or null if the map contains no mapping for this key
  See Also:
    `AbstractMap.containsKey(Object)`

### put

    public Object put(Object oKey,
                      Object oValue)

  Associates the specified value with the specified key in this map.
  Specified by:
    `put` in interface `Map`
  Overrides:
    `put` in class `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

### remove

    public Object remove(Object oKey)

  Removes the mapping for this key from this map if present. Expensive: updates both the underlying cache and the local cache.
  Specified by:
    `remove` in interface `Map`
  Overrides:
    `remove` in class `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 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.

### clear

    public void clear()

  Clear all key/value mappings.
  Specified by:
    `clear` in interface `Map`
  Overrides:
    `clear` in class `AbstractMap`

### clone

    public Object clone()

  Create a clone of the ImmutableArrayList.
  Overrides:
    `clone` in class `AbstractMap`
  Returns:
    a clone of this list

### entrySet

    public Set entrySet()

  Returns a set view of the mappings contained in this map. Each element in the returned set is an `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 (except by the iterator's own `remove` operation, or by the `setValue` operation on a map entry returned by the iterator) 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 is not expected to support the `add` or `addAll` operations.
  Specified by:
    `entrySet` in interface `Map`
  Specified by:
    `entrySet` in class `AbstractMap`
  Returns:
    a set view of the mappings contained in this map

### readExternal

    public void readExternal(ObjectInput in)
                      throws IOException,
                             ClassNotFoundException

  Initialize this object from the data in the passed ObjectInput stream.
  Specified by:
    `readExternal` in interface `Externalizable`
  Parameters:
    `in` - the stream to read data from in order to restore the object
  Throws:
    `IOException` - if an I/O exception occurs
    `ClassNotFoundException`

### writeExternal

    public void writeExternal(ObjectOutput out)
                       throws IOException

  Write this object's data to the passed ObjectOutput stream.
  Specified by:
    `writeExternal` in interface `Externalizable`
  Parameters:
    `out` - the stream to write the object to
  Throws:
    `IOException` - if an I/O exception occurs

### readExternal

    public void readExternal(DataInput in)
                      throws IOException

  Restore the contents of this object by loading the object's state from the passed DataInput object.
  Specified by:
    `readExternal` in interface `ExternalizableLite`
  Parameters:
    `in` - the DataInput stream to read data from in order to restore the state of this object
  Throws:
    `IOException` - if an I/O exception occurs
    `NotActiveException` - if the object is not in its initial state, and therefore cannot be deserialized into

### writeExternal

    public void writeExternal(DataOutput out)
                       throws IOException

  Save the contents of this object by storing the object's state into the passed DataOutput object.
  Specified by:
    `writeExternal` in interface `ExternalizableLite`
  Parameters:
    `out` - the DataOutput stream to write the state of this object to
  Throws:
    `IOException` - if an I/O exception occurs

### instantiateEntry

    protected Map.Entry instantiateEntry(Object key,
                                         Object value)

  (Factory pattern) Instantiate a Map Entry. This method permits inheriting classes to easily override the implementation of the Entry object.
  Returns:
    an instance of a Map Entry

### instantiateEntrySet

    protected Set instantiateEntrySet()

  (Factory pattern) Instantiate an Entry Set. This method permits inheriting classes to easily override the implementation of the EntrySet object.
  Returns:
    an instance of Entry Set

### instantiateMap

    protected Map instantiateMap()

  (Factory pattern) Instantiate a Map object to store entries in once the "lite" threshold has been exceeded. This method permits inheriting classes to easily override the choice of the Map object.
  Returns:
    an instance of Map

### checkShrinkFromOther

    protected void checkShrinkFromOther()

  After a mutation operation has reduced the size of an underlying Map, check if the delegation model should be replaced with a more size- efficient storage approach, and switch accordingly.

Skip navigation links

Overview | Package | Class | Tree | Index | Help
| Oracle® Coherence Java API Reference Release 3.6.0.0 E15725-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.