org.apache.ignite.internal.util

## Class GridBoundedConcurrentOrderedMap<K,V>

- java.lang.Object
- - java.util.AbstractMap<K,V>
  - - java.util.concurrent.ConcurrentSkipListMap<K,V>
    - - org.apache.ignite.internal.util.GridBoundedConcurrentOrderedMap<K,V>

All Implemented Interfaces:
  Serializable, Cloneable, ConcurrentMap<K,V>, ConcurrentNavigableMap<K,V>, Map<K,V>, NavigableMap<K,V>, SortedMap<K,V>

    public class GridBoundedConcurrentOrderedMap<K,V>
    extends ConcurrentSkipListMap<K,V>

Concurrent ordered map that automatically manages its maximum size. Once it exceeds its maximum, it will start removing smallest elements until the maximum is reached again. If optional listener is set via `evictionListener(org.apache.ignite.lang.IgniteBiInClosure)` method, then listener will be notified for every eviction.

Note that due to concurrent nature of this map, it may grow slightly larger than its maximum allowed size, but in this case it will quickly readjust back to allowed size.

Note that `remove(Object)` and `remove(Object, Object)` methods are not supported for this kind of map.

See Also:
  Serialized Form

### 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
`GridBoundedConcurrentOrderedMap(int max)` Constructs a new, empty map that orders its elements according to their natural ordering.
`GridBoundedConcurrentOrderedMap(int max, Comparator<? super K> comparator)` Constructs a new, empty set that orders its elements according to the specified comparator.
`GridBoundedConcurrentOrderedMap(int max, Map<? extends K,? extends V> map)` Constructs a new map containing the elements in the specified map, that orders its elements according to their natural ordering.
`GridBoundedConcurrentOrderedMap(int max, SortedMap<K,V> map)` Constructs a new map containing the same elements and using the same ordering as the specified sorted map.

### Method Summary

Methods
`void` `clear()`
`GridBoundedConcurrentOrderedMap<K,V>` `clone()`
`IgniteBiInClosure<K,V>` `evictionListener()` Gets closure listener to be called for every eviction event.
`void` `evictionListener(IgniteBiInClosure<K,V> lsnr)` Sets closure listener to be called for every eviction event.
`V` `put(K k, V v)`
`V` `putIfAbsent(K k, V v)`
`V` `remove(Object o)` This method is not supported and always throws `UnsupportedOperationException`.
`boolean` `remove(Object key, Object val)` This method is not supported and always throws `UnsupportedOperationException`.
`int` `size()` Approximate size at this point of time.

### Methods inherited from class java.util.concurrent.ConcurrentSkipListMap

`ceilingEntry, ceilingKey, comparator, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, equals, firstEntry, firstKey, floorEntry, floorKey, get, headMap, headMap, higherEntry, higherKey, isEmpty, keySet, lastEntry, lastKey, lowerEntry, lowerKey, navigableKeySet, pollFirstEntry, pollLastEntry, replace, replace, subMap, subMap, tailMap, tailMap, values`

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

`hashCode, putAll, toString`

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

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

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

`hashCode, putAll`

### Constructor Detail

#### GridBoundedConcurrentOrderedMap

    public GridBoundedConcurrentOrderedMap(int max)

Constructs a new, empty map that orders its elements according to their natural ordering.

Parameters:
  `max` - Upper bound of this map.

#### GridBoundedConcurrentOrderedMap

    public GridBoundedConcurrentOrderedMap(int max,
                                   Comparator<? super K> comparator)

Constructs a new, empty set that orders its elements according to the specified comparator.

Parameters:
  `max` - Upper bound of this map.
  `comparator` - The comparator that will be used to order this map. If `null`, the natural ordering of the elements will be used.

#### GridBoundedConcurrentOrderedMap

    public GridBoundedConcurrentOrderedMap(int max,
                                   Map<? extends K,? extends V> map)

Constructs a new map containing the elements in the specified map, that orders its elements according to their natural ordering.

Parameters:
  `max` - Upper bound of this map.
  `map` - The elements that will comprise the new map.
Throws:
  `ClassCastException` - if the elements in `map` are not `Comparable`, or are not mutually comparable.
  `NullPointerException` - if the specified map or any of its elements are `null`.

#### GridBoundedConcurrentOrderedMap

    public GridBoundedConcurrentOrderedMap(int max,
                                   SortedMap<K,V> map)

Constructs a new map containing the same elements and using the same ordering as the specified sorted map.

Parameters:
  `max` - Upper bound of this map.
  `map` - Sorted map whose elements will comprise the new map.
Throws:
  `NullPointerException` - if the specified sorted map or any of its elements are `null`.

### Method Detail

#### evictionListener

    public void evictionListener(IgniteBiInClosure<K,V> lsnr)

Sets closure listener to be called for every eviction event.

Parameters:
  `lsnr` - Closure to be called for every eviction event.

#### evictionListener

    public IgniteBiInClosure<K,V> evictionListener()

Gets closure listener to be called for every eviction event.

Returns:
  Closure to be called for every eviction event.

#### put

    @Nullable
    public V put(K k,
                 V v)

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

#### putIfAbsent

    @Nullable
    public V putIfAbsent(K k,
                         V v)

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

#### size

    public int size()

Approximate size at this point of time. Note, that unlike `size` methods on other `concurrent` collections, this method executes in constant time without traversal of the elements.

Specified by:
  `size` in interface `Map<K,V>`
Overrides:
  `size` in class `ConcurrentSkipListMap<K,V>`
Returns:
  Approximate set size at this point of time.

#### clone

    public GridBoundedConcurrentOrderedMap<K,V> clone()

Overrides:
  `clone` in class `ConcurrentSkipListMap<K,V>`

#### remove

    public V remove(Object o)

This method is not supported and always throws `UnsupportedOperationException`.

Specified by:
  `remove` in interface `Map<K,V>`
Overrides:
  `remove` in class `ConcurrentSkipListMap<K,V>`
Parameters:
  `o` -
Returns:

#### remove

    public boolean remove(Object key,
                 Object val)

This method is not supported and always throws `UnsupportedOperationException`.

Specified by:
  `remove` in interface `ConcurrentMap<K,V>`
Overrides:
  `remove` in class `ConcurrentSkipListMap<K,V>`
Parameters:
  `key` -
  `val` -
Returns:

#### clear

    public void clear()

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

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.1.0
Release Date | : July 20 2017