org.apache.ignite.internal.processors.cache

## Class GridCacheConcurrentMapImpl

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCacheConcurrentMapImpl

All Implemented Interfaces:
  GridCacheConcurrentMap

    public class GridCacheConcurrentMapImpl
    extends Object
    implements GridCacheConcurrentMap

Implementation of concurrent cache map.

### Constructor Summary

Constructors
Constructor and Description
`GridCacheConcurrentMapImpl(GridCacheContext ctx, GridCacheMapEntryFactory factory, int initialCapacity)` Creates a new, empty map with the specified initial capacity.
`GridCacheConcurrentMapImpl(GridCacheContext ctx, GridCacheMapEntryFactory factory, int initialCapacity, float loadFactor, int concurrencyLevel)` Creates a new, empty map with the specified initial capacity, load factor and concurrency level.

### Method Summary

Methods
`Collection<GridCacheMapEntry>` `allEntries(CacheEntryPredicate... filter)`
`void` `decrementPublicSize(GridCacheEntryEx e)` Decrements public size.
`Collection<GridCacheMapEntry>` `entries(CacheEntryPredicate... filter)`
`Set<GridCacheMapEntry>` `entrySet(CacheEntryPredicate... filter)`
`GridCacheMapEntry` `getEntry(KeyCacheObject key)` Returns the entry associated with the specified key in the HashMap.
`void` `incrementPublicSize(GridCacheEntryEx e)` Increments public size.
`Set<KeyCacheObject>` `keySet(CacheEntryPredicate... filter)`
`int` `publicSize()` Returns the number of publicly available key-value mappings in this map.
`GridCacheMapEntry` `putEntryIfObsoleteOrAbsent(AffinityTopologyVersion topVer, KeyCacheObject key, CacheObject val, boolean create, boolean touch)`
`GridCacheMapEntry` `randomEntry()` Deprecated.
`boolean` `removeEntry(GridCacheEntryEx entry)` Removes passed in entry if it presents in the map.
`int` `size()` Returns the number of key-value mappings in this map.

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### GridCacheConcurrentMapImpl

    public GridCacheConcurrentMapImpl(GridCacheContext ctx,
                              GridCacheMapEntryFactory factory,
                              int initialCapacity)

Creates a new, empty map with the specified initial capacity.

Parameters:
  `ctx` - Cache context.
  `factory` - Entry factory.
  `initialCapacity` - the initial capacity. The implementation performs internal sizing to accommodate this many elements.
Throws:
  `IllegalArgumentException` - if the initial capacity is negative.

#### GridCacheConcurrentMapImpl

    public GridCacheConcurrentMapImpl(GridCacheContext ctx,
                              GridCacheMapEntryFactory factory,
                              int initialCapacity,
                              float loadFactor,
                              int concurrencyLevel)

Creates a new, empty map with the specified initial capacity, load factor and concurrency level.

Parameters:
  `ctx` - Cache context.
  `factory` - Entry factory.
  `initialCapacity` - the initial capacity. The implementation performs internal sizing to accommodate this many elements.
  `loadFactor` - the load factor threshold, used to control resizing. Resizing may be performed when the average number of elements per bin exceeds this threshold.
  `concurrencyLevel` - the estimated number of concurrently updating threads. The implementation performs internal sizing to try to accommodate this many threads.
Throws:
  `IllegalArgumentException` - if the initial capacity is negative or the load factor or concurrencyLevel are non-positive.

### Method Detail

#### getEntry

    @Nullable
    public GridCacheMapEntry getEntry(KeyCacheObject key)

Returns the entry associated with the specified key in the HashMap. Returns null if the HashMap contains no mapping for this key.

Specified by:
  `getEntry` in interface `GridCacheConcurrentMap`
Parameters:
  `key` - Key.
Returns:
  Entry.

#### putEntryIfObsoleteOrAbsent

    @Nullable
    public GridCacheMapEntry putEntryIfObsoleteOrAbsent(AffinityTopologyVersion topVer,
                                                        KeyCacheObject key,
                                                        @Nullable
                                                        CacheObject val,
                                                        boolean create,
                                                        boolean touch)

Specified by:
  `putEntryIfObsoleteOrAbsent` in interface `GridCacheConcurrentMap`
Parameters:
  `topVer` - Topology version.
  `key` - Key.
  `val` - Value.
  `create` - Create flag.
Returns:
  Triple where the first element is current entry associated with the key, the second is created entry and the third is doomed (all may be null).

#### removeEntry

    public boolean removeEntry(GridCacheEntryEx entry)

Removes passed in entry if it presents in the map.

Specified by:
  `removeEntry` in interface `GridCacheConcurrentMap`
Parameters:
  `entry` - Entry to remove.
Returns:
  `True` if remove happened.

#### size

    public int size()

Returns the number of key-value mappings in this map.

Specified by:
  `size` in interface `GridCacheConcurrentMap`
Returns:
  the number of key-value mappings in this map.

#### publicSize

    public int publicSize()

Returns the number of publicly available key-value mappings in this map. It excludes entries that are marked as deleted.

Specified by:
  `publicSize` in interface `GridCacheConcurrentMap`
Returns:
  the number of publicly available key-value mappings in this map.

#### incrementPublicSize

    public void incrementPublicSize(GridCacheEntryEx e)

Increments public size.

Specified by:
  `incrementPublicSize` in interface `GridCacheConcurrentMap`
Parameters:
  `e` - Entry that caused public size change.

#### decrementPublicSize

    public void decrementPublicSize(GridCacheEntryEx e)

Decrements public size.

Specified by:
  `decrementPublicSize` in interface `GridCacheConcurrentMap`
Parameters:
  `e` - Entry that caused public size change.

#### keySet

    public Set<KeyCacheObject> keySet(CacheEntryPredicate... filter)

Specified by:
  `keySet` in interface `GridCacheConcurrentMap`
Returns:
  Random entry out of hash map.

#### entries

    public Collection<GridCacheMapEntry> entries(CacheEntryPredicate... filter)

Specified by:
  `entries` in interface `GridCacheConcurrentMap`
Parameters:
  `filter` - Filter.
Returns:
  Iterable of the mappings contained in this map, excluding entries in unvisitable state.

#### allEntries

    public Collection<GridCacheMapEntry> allEntries(CacheEntryPredicate... filter)

Specified by:
  `allEntries` in interface `GridCacheConcurrentMap`
Parameters:
  `filter` - Filter.
Returns:
  Iterable of the mappings contained in this map, including entries in unvisitable state.

#### randomEntry

    @Deprecated
    @Nullable
    public GridCacheMapEntry randomEntry()

Deprecated.

Specified by:
  `randomEntry` in interface `GridCacheConcurrentMap`

#### entrySet

    public Set<GridCacheMapEntry> entrySet(CacheEntryPredicate... filter)

Specified by:
  `entrySet` in interface `GridCacheConcurrentMap`
Parameters:
  `filter` - Filter.
Returns:
  Set of the mappings contained in this map.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.7.0
Release Date | : August 1 2016