org.apache.ignite.internal.util

## Class GridLeanMap<K,V>

- java.lang.Object
- - java.util.AbstractMap<K,V>
  - - org.apache.ignite.internal.util.GridSerializableMap<K,V>
    - - org.apache.ignite.internal.util.GridLeanMap<K,V>

All Implemented Interfaces:
  Serializable, Cloneable, Map<K,V>

    public class GridLeanMap<K,V>
    extends GridSerializableMap<K,V>
    implements Cloneable

Lean map implementation that keeps up to five entries in its fields. `Null`-keys are not supported.

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
`GridLeanMap()` Constructs lean map with initial size of `3`.
`GridLeanMap(int size)` Constructs lean map with initial size.
`GridLeanMap(Map<K,V> m)` Constructs lean map.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `clear()`
`protected Object` `clone()`
`boolean` `containsKey(Object key)`
`boolean` `containsValue(Object val)`
`Set<Map.Entry<K,V>>` `entrySet()`
`V` `get(Object key)`
`V` `put(K key, V val)`
`V` `remove(Object key)`
`int` `size()`

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

`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

`compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll`

### Constructor Detail

#### GridLeanMap

    public GridLeanMap()

Constructs lean map with initial size of `3`.

#### GridLeanMap

    public GridLeanMap(int size)

Constructs lean map with initial size.

If given size is greater than zero then map activates batch mode for `put()` operations. In this mode map allows to put up to `size` number of key-value pairs without internal size optimization, i.e. each next `put()` in batch doesn't switch backing implementation so that initial implementation is used as long as its capacity allows.

Note that any removal operation either through iterator or map itself turns batch mode off and map starts optimizing size after any modification.

Parameters:
  `size` - Initial size.

#### GridLeanMap

    public GridLeanMap(Map<K,V> m)

Constructs lean map.

Parameters:
  `m` - Map to copy entries from.

### Method Detail

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

#### containsValue

    public boolean containsValue(Object val)

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

#### get

    @Nullable
    public V get(Object key)

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

#### put

    @Nullable
    public V put(K key,
                           V val)
                    throws NullPointerException

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

#### remove

    @Nullable
    public V remove(Object key)

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

#### clear

    public void clear()

Specified by:
  `clear` in interface `Map<K,V>`
Overrides:
  `clear` 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>`

#### clone

    protected Object clone()

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

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.11.0
Release Date | : September 11 2021