Package co.elastic.apm.agent.util
Class NoRandomAccessMap<K,V>
- java.lang.Object
-
- co.elastic.apm.agent.util.NoRandomAccessMap<K,V>
-
- Type Parameters:
K- Key typeV- Value type
- All Implemented Interfaces:
Recyclable,java.lang.Iterable<NoRandomAccessMap.Entry<K,V>>
public class NoRandomAccessMap<K,V> extends java.lang.Object implements Recyclable, java.lang.Iterable<NoRandomAccessMap.Entry<K,V>>
A map (not implementing the java.util.Map interface) that only supports key-value pair additions and iterations. The map doesn't allocate during addition or iteration. This map does not support any form of concurrency. It can be either be in a write mode (through itsadd(K, V)method) or read mode (through theiterator()API) at a given time. NOTE: this map does not guarantee visibility, therefore ensuring visibility when switching from read to write mode (or the other way around) is under the responsibility of the map's user.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceNoRandomAccessMap.Entry<K,V>
-
Constructor Summary
Constructors Constructor Description NoRandomAccessMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(K key, V value)voidcopyFrom(NoRandomAccessMap<K,V> other)booleanisEmpty()java.util.Iterator<NoRandomAccessMap.Entry<K,V>>iterator()voidresetState()resets pooled object state so it can be reusedintsize()
-
-
-
Method Detail
-
add
public void add(K key, @Nullable V value) throws java.lang.NullPointerException
- Parameters:
key- can't be nullvalue- can be null- Throws:
java.lang.NullPointerException- if provided key is null
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
resetState
public void resetState()
Description copied from interface:Recyclableresets pooled object state so it can be reused- Specified by:
resetStatein interfaceRecyclable
-
iterator
public java.util.Iterator<NoRandomAccessMap.Entry<K,V>> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<K>
-
copyFrom
public void copyFrom(NoRandomAccessMap<K,V> other)
-
-