Class BidirectionalObjectToIdMapDefault<V>
java.lang.Object
ch.qos.logback.core.kryo.BidirectionalObjectToIdMapDefault<V>
- All Implemented Interfaces:
BidirectionalObjectToIdMap<V>
public class BidirectionalObjectToIdMapDefault<V>
extends Object
implements BidirectionalObjectToIdMap<V>
Value↔id map with access-order LRU eviction at
capacity.
getIdByValue(V) and getValueById(int) count as uses, so entries that
keep being looked up stay; the least-recently-used mapping is dropped when a new
one would exceed capacity. Evicted ids are reused for later inserts. idToValue
is a plain HashMap; LRU order lives only in valueToId.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetIdByValue(V value) Returns the id for the given value or null if the value is not mapped.getValueById(int id) Returns the value mapped to the given id or null if there is no such mapping.insertNewEntryOnRead(int id, V value) Inserts a new entry mapping the given id to the given value.insertNewEntryOnWrite(V value) Inserts a new entry mapping an id to the given value.
-
Constructor Details
-
BidirectionalObjectToIdMapDefault
-
-
Method Details
-
getIdByValue
Description copied from interface:BidirectionalObjectToIdMapReturns the id for the given value or null if the value is not mapped.- Specified by:
getIdByValuein interfaceBidirectionalObjectToIdMap<V>
-
insertNewEntryOnWrite
Description copied from interface:BidirectionalObjectToIdMapInserts a new entry mapping an id to the given value. Reuses an id freed by LRU eviction when the map is at capacity; otherwise assigns the next unused id. Returns the assigned id.- Specified by:
insertNewEntryOnWritein interfaceBidirectionalObjectToIdMap<V>
-
insertNewEntryOnRead
Description copied from interface:BidirectionalObjectToIdMapInserts a new entry mapping the given id to the given value.Any existing entry with the same value if removed from the valueToId map.
Returns the existing value mapped to the given id or null if there was no existing mapping.- Specified by:
insertNewEntryOnReadin interfaceBidirectionalObjectToIdMap<V>
-
getValueById
Description copied from interface:BidirectionalObjectToIdMapReturns the value mapped to the given id or null if there is no such mapping.- Specified by:
getValueByIdin interfaceBidirectionalObjectToIdMap<V>
-