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

## edu.stanford.nlp.util
Class ArrayCoreMap

    java.lang.Object
      edu.stanford.nlp.util.ArrayCoreMap

All Implemented Interfaces:
  CoreMap, TypesafeMap<CoreMap>, Serializable

Direct Known Subclasses:
  CoreLabel, HashableCoreMap

    public class ArrayCoreMap

extends Object
implements CoreMap, Serializable

Base implementation of `CoreMap` backed by Java Arrays.

Reasonable care has been put into ensuring that this class is both fast and has a light memory footprint.

Note that like the base classes in the Collections API, this implementation is not thread-safe. For speed reasons, these methods are not synchronized. A synchronized wrapper could be developed by anyone so inclined.

Equality is defined over the complete set of keys and values currently stored in the map. Because this class is mutable, it should not be used as a key in a HashMap.

Author:
  dramage, rafferty
See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from interface edu.stanford.nlp.util.TypesafeMap
`TypesafeMap.Key<BASE,VALUE>`

Constructor Summary
`ArrayCoreMap()` Default constructor - initializes with default initial annotation capacity of 4.
`ArrayCoreMap(ArrayCoreMap other)` Copy constructor.
`ArrayCoreMap(CoreMap other)` Copy constructor.
`ArrayCoreMap(int capacity)` Initializes this MapNLPObject, pre-allocating arrays to hold up to capacity key,value pairs.

Method Summary
`void` | `compact()` Reduces memory consumption to the minimum for representing the values currently stored stored in this object.
`
`<VALUE,KEY extends TypesafeMap.Key<CoreMap,VALUE>> boolean`
` | `containsKey(Class<KEY> key)` Returns true if contains the given key.
`boolean` | `equals(Object obj)` Two CoreMaps are equal iff all keys and values are .equal.
`
`<VALUE,KEY extends TypesafeMap.Key<CoreMap,VALUE>> VALUE`
` | `get(Class<KEY> key)` Returns the value associated with the given key or null if none is provided.
`
`<VALUE,KEY extends TypesafeMap.Key<CoreMap,VALUE>> boolean`
` | `has(Class<KEY> key)` Returns true if the map contains the given key.
`int` | `hashCode()` Returns a composite hashcode over all the keys and values currently stored in the map.
`Set<Class<?>>` | `keySet()` Collection of keys currently held in this map.
`
`<VALUE,KEY extends TypesafeMap.Key<CoreMap,VALUE>> VALUE`
` | `remove(Class<KEY> key)` Removes the given key from the map, returning the value removed.
`
`<VALUEBASE,VALUE extends VALUEBASE,KEY extends TypesafeMap.Key<CoreMap,VALUEBASE>> VALUE`
` | `set(Class<KEY> key, VALUE value)` Associates the given value with the given type for future calls to get.
`int` | `size()` Returns the number of elements in this map.
`String` | `toShorterString(String... what)`
`String` | `toString()`

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

Constructor Detail

### ArrayCoreMap

    public ArrayCoreMap()

  Default constructor - initializes with default initial annotation capacity of 4.

### ArrayCoreMap

    public ArrayCoreMap(int capacity)

  Initializes this MapNLPObject, pre-allocating arrays to hold up to capacity key,value pairs. This array will grow if necessary.

  Parameters:
    `capacity` - Initial capacity of object in key,value pairs

### ArrayCoreMap

    public ArrayCoreMap(ArrayCoreMap other)

  Copy constructor.

  Parameters:
    `other` - The ArrayCoreMap to copy

### ArrayCoreMap

    public ArrayCoreMap(CoreMap other)

  Copy constructor.

  Parameters:
    `other` - The ArrayCoreMap to copy

Method Detail

### get

    public <VALUE,KEY extends TypesafeMap.Key<CoreMap,VALUE>> VALUE get(Class<KEY> key)

  Returns the value associated with the given key or null if none is provided.

  Specified by:
    `get` in interface `TypesafeMap<CoreMap>`

### has

    public <VALUE,KEY extends TypesafeMap.Key<CoreMap,VALUE>> boolean has(Class<KEY> key)

  Returns true if the map contains the given key.

  Specified by:
    `has` in interface `TypesafeMap<CoreMap>`

### set

    public <VALUEBASE,VALUE extends VALUEBASE,KEY extends TypesafeMap.Key<CoreMap,VALUEBASE>> VALUE set(Class<KEY> key,
                                                                                                        VALUE value)

  Associates the given value with the given type for future calls to get. Returns the value removed or null if no value was present.

  Specified by:
    `set` in interface `TypesafeMap<CoreMap>`

### keySet

    public Set<Class<?>> keySet()

  Collection of keys currently held in this map. Some implementations may have the returned set be immutable. As of Java 1.6 Java's generics type inference is broken enough that the proper signature for this method - Set<Class<? extends Key<BASE,?>>> - cannot be implemented by subclasses, so the return signature is not typed as strongly as it could be.

  Specified by:
    `keySet` in interface `TypesafeMap<CoreMap>`

### remove

    public <VALUE,KEY extends TypesafeMap.Key<CoreMap,VALUE>> VALUE remove(Class<KEY> key)

  Removes the given key from the map, returning the value removed.

  Specified by:
    `remove` in interface `TypesafeMap<CoreMap>`

### containsKey

    public <VALUE,KEY extends TypesafeMap.Key<CoreMap,VALUE>> boolean containsKey(Class<KEY> key)

  Returns true if contains the given key.

  Specified by:
    `containsKey` in interface `TypesafeMap<CoreMap>`

### compact

    public void compact()

  Reduces memory consumption to the minimum for representing the values currently stored stored in this object.

### size

    public int size()

  Returns the number of elements in this map.

  Specified by:
    `size` in interface `TypesafeMap<CoreMap>`
  Returns:
    The number of elements in this map.

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### toShorterString

    public String toShorterString(String... what)

### equals

    public boolean equals(Object obj)

  Two CoreMaps are equal iff all keys and values are .equal.

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Returns a composite hashcode over all the keys and values currently stored in the map. Because they may change over time, this class is not appropriate for use as map keys.

  Overrides:
    `hashCode` in class `Object`

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

Stanford NLP Group