com.romix.scala.collection.concurrent

## Class TrieMap<K,V>

- java.lang.Object
- - java.util.AbstractMap<K,V>
  - - com.romix.scala.collection.concurrent.TrieMap<K,V>

Type Parameters:
  `K` -
  `V` -

All Implemented Interfaces:
  ConcurrentMap<K,V>, Map<K,V>

    public class TrieMap<K,V>
    extends AbstractMap<K,V>
    implements ConcurrentMap<K,V>

This is a port of Scala's TrieMap class from the Scala Collections library.

### Nested Class Summary

### Nested classes/interfaces inherited from class java.util.AbstractMap

`AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>`

### Nested classes/interfaces inherited from interface java.util.Map

`Map.Entry<K,V>`

### Constructor Summary

Constructors
Constructor and Description
`TrieMap()`
`TrieMap(com.romix.scala.collection.concurrent.TrieMap.Hashing<K> hashf, com.romix.scala.collection.concurrent.TrieMap.Equiv<K> ef)`

### Method Summary

Methods
`TrieMap<K,V>` `add(K k, V v)`
`void` `clear()`
`boolean` `containsKey(Object key)`
`static <K,V> TrieMap<K,V>` `empty()`
`Set<Map.Entry<K,V>>` `entrySet()`
`V` `get(Object k)`
`Iterator<Map.Entry<K,V>>` `iterator()` Return an iterator over a TrieMap.
`V` `put(Object key, Object value)`
`V` `putIfAbsent(Object k, Object v)`
`Option<V>` `putIfAbsentOpt(K k, V v)`
`Option<V>` `putOpt(Object key, Object value)`
`Iterator<Map.Entry<K,V>>` `readOnlyIterator()` Return an iterator over a TrieMap.
`TrieMap<K,V>` `readOnlySnapshot()` Returns a read-only snapshot of this TrieMap.
`V` `remove(Object k)`
`boolean` `remove(Object k, Object v)`
`boolean` `replace(K k, V oldvalue, V newvalue)`
`V` `replace(Object k, Object v)`
`Option<V>` `replaceOpt(K k, V v)`
`int` `size()`
`TrieMap<K,V>` `snapshot()` Returns a snapshot of this TrieMap.
`String` `string()`
`void` `update(K k, V v)`

### Methods inherited from class java.util.AbstractMap

`clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, toString, values`

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface java.util.Map

`containsValue, equals, hashCode, isEmpty, keySet, putAll, values`

### Constructor Detail

#### TrieMap

    public TrieMap(com.romix.scala.collection.concurrent.TrieMap.Hashing<K> hashf,
           com.romix.scala.collection.concurrent.TrieMap.Equiv<K> ef)

#### TrieMap

    public TrieMap()

### Method Detail

#### empty

    public static <K,V> TrieMap<K,V> empty()

#### string

    public String string()

#### snapshot

    public final TrieMap<K,V> snapshot()

Returns a snapshot of this TrieMap. This operation is lock-free and linearizable.

The snapshot is lazily updated - the first time some branch in the snapshot or this TrieMap are accessed, they are rewritten. This means that the work of rebuilding both the snapshot and this TrieMap is distributed across all the threads doing updates or accesses subsequent to the snapshot creation.

#### readOnlySnapshot

    public final TrieMap<K,V> readOnlySnapshot()

Returns a read-only snapshot of this TrieMap. This operation is lock-free and linearizable.

The snapshot is lazily updated - the first time some branch of this TrieMap are accessed, it is rewritten. The work of creating the snapshot is thus distributed across subsequent updates and accesses on this TrieMap by all threads. Note that the snapshot itself is never rewritten unlike when calling the `snapshot` method, but the obtained snapshot cannot be modified.

This method is used by other methods such as `size` and `iterator`.

#### clear

    public final void clear()

Specified by:
  `clear` in interface `Map<K,V>`
Overrides:
  `clear` in class `AbstractMap<K,V>`

#### get

    public final V get(Object k)

Specified by:
  `get` in interface `Map<K,V>`
Overrides:
  `get` in class `AbstractMap<K,V>`

#### putOpt

    public final Option<V> putOpt(Object key,
                   Object value)

#### put

    public final V put(Object key,
        Object value)

Specified by:
  `put` in interface `Map<K,V>`
Overrides:
  `put` in class `AbstractMap<K,V>`

#### update

    public final void update(K k,
              V v)

#### add

    public final TrieMap<K,V> add(K k,
                   V v)

#### remove

    public final V remove(Object k)

Specified by:
  `remove` in interface `Map<K,V>`
Overrides:
  `remove` in class `AbstractMap<K,V>`

#### putIfAbsentOpt

    public final Option<V> putIfAbsentOpt(K k,
                           V v)

#### putIfAbsent

    public final V putIfAbsent(Object k,
                Object v)

Specified by:
  `putIfAbsent` in interface `ConcurrentMap<K,V>`

#### remove

    public boolean remove(Object k,
                 Object v)

Specified by:
  `remove` in interface `ConcurrentMap<K,V>`

#### replace

    public boolean replace(K k,
                  V oldvalue,
                  V newvalue)

Specified by:
  `replace` in interface `ConcurrentMap<K,V>`

#### replaceOpt

    public Option<V> replaceOpt(K k,
                       V v)

#### replace

    public V replace(Object k,
            Object v)

Specified by:
  `replace` in interface `ConcurrentMap<K,V>`

#### iterator

    public Iterator<Map.Entry<K,V>> iterator()

Return an iterator over a TrieMap.

If this is a read-only snapshot, it would return a read-only iterator.

If it is the original TrieMap or a non-readonly snapshot, it would return an iterator that would allow for updates.

Returns:

#### readOnlyIterator

    public Iterator<Map.Entry<K,V>> readOnlyIterator()

Return an iterator over a TrieMap. This is a read-only iterator.

Returns:

#### size

    public int size()

Specified by:
  `size` in interface `Map<K,V>`
Overrides:
  `size` in class `AbstractMap<K,V>`

#### containsKey

    public boolean containsKey(Object key)

Specified by:
  `containsKey` in interface `Map<K,V>`
Overrides:
  `containsKey` in class `AbstractMap<K,V>`

#### entrySet

    public Set<Map.Entry<K,V>> entrySet()

Specified by:
  `entrySet` in interface `Map<K,V>`
Specified by:
  `entrySet` in class `AbstractMap<K,V>`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC3
Release Date | : March 24 2015