AccessOrderLinkedHashMap

class AccessOrderLinkedHashMap<K, V>(initialCapacity: Int = 16, loadFactor: Float = 0.75f) : MutableMap<K, V>

A MutableMap implementation that maintains access-order iteration. The least-recently-used (LRU) entry is at the front of the iteration order.

This is achieved by removing and re-inserting entries on access (get/put).

Parameters

K

the type of keys maintained by this map

V

the type of mapped values

initialCapacity

the initial capacity of the map (default is 16)

loadFactor

the load factor of the map (default is 0.75f)

Constructors

Link copied to clipboard
constructor(initialCapacity: Int = 16, loadFactor: Float = 0.75f)

Properties

Link copied to clipboard

Returns a MutableSet view of the mappings contained in this map.

Link copied to clipboard
open override val keys: MutableSet<K>

Returns a MutableSet view of the keys contained in this map.

Link copied to clipboard
open override val size: Int

Returns the number of key-value pairs in the map.

Link copied to clipboard
open override val values: MutableCollection<V>

Returns a MutableCollection view of the values contained in this map.

Functions

Link copied to clipboard
open override fun clear()

Removes all mappings from the map.

Link copied to clipboard
open override fun containsKey(key: K): Boolean

Checks if the map contains the specified key.

Link copied to clipboard
open override fun containsValue(value: V): Boolean

Checks if the map contains the specified value.

Link copied to clipboard
open operator override fun get(key: K): V?

Retrieves the value associated with the specified key. Moves the accessed entry to the end of the iteration order.

Link copied to clipboard
open override fun isEmpty(): Boolean

Checks if the map is empty.

Link copied to clipboard
open override fun put(key: K, value: V): V?

Associates the specified value with the specified key in the map. If the key already exists, it is moved to the end of the iteration order.

Link copied to clipboard
open override fun putAll(from: Map<out K, V>)

Copies all of the mappings from the specified map to this map. Existing keys are updated and moved to the end of the iteration order.

Link copied to clipboard
open override fun remove(key: K): V?

Removes the mapping for the specified key from the map.