Class NoRandomAccessMap<K,​V>

  • Type Parameters:
    K - Key type
    V - 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 its add(K, V) method) or read mode (through the iterator() 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.
    • Constructor Detail

      • NoRandomAccessMap

        public NoRandomAccessMap()
    • Method Detail

      • add

        public void add​(K key,
                        @Nullable
                        V value)
                 throws java.lang.NullPointerException
        Parameters:
        key - can't be null
        value - 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: Recyclable
        resets pooled object state so it can be reused
        Specified by:
        resetState in interface Recyclable
      • iterator

        public java.util.Iterator<NoRandomAccessMap.Entry<K,​V>> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<K>