Class BmLongSegmentSyncMap<T>

  • All Implemented Interfaces:
    IBmLongMap<T>

    public class BmLongSegmentSyncMap<T>
    extends Object
    implements IBmLongMap<T>
    A Long map with segment synchronization. Implementation limited only for put/get/remove operations. Iterations are not supported.
    • Constructor Detail

      • BmLongSegmentSyncMap

        public BmLongSegmentSyncMap​(int segments)
        Constructs a new instance.
        Parameters:
        segments - The segment count, must be a power of two.
    • Method Detail

      • get

        public T get​(long key)
        Description copied from interface: IBmLongMap
        Returns the value of the mapping with the specified key.
        Specified by:
        get in interface IBmLongMap<T>
        Parameters:
        key - the key.
        Returns:
        the value of the mapping with the specified key, or null if no mapping for the specified key is found.
      • put

        public T put​(long key,
                     T value)
        Description copied from interface: IBmLongMap
        Maps the specified key to the specified value.
        Specified by:
        put in interface IBmLongMap<T>
        Parameters:
        key - the key.
        value - the value.
        Returns:
        the value of any previous mapping with the specified key or null if there was no such mapping.
      • putAll

        public void putAll​(Map<Long,​T> map)
        Copies all of the mappings from the specified map to this map.
        Parameters:
        map - the map to copy mappings from, may not be null.
      • remove

        public T remove​(long key)
        Description copied from interface: IBmLongMap
        Removes the mapping with the specified key from this map.
        Specified by:
        remove in interface IBmLongMap<T>
        Parameters:
        key - the key of the mapping to remove.
        Returns:
        the value of the removed mapping or null if no mapping for the specified key was found.
      • containsKey

        public boolean containsKey​(long key)
        Description copied from interface: IBmLongMap
        Checks if the map contains the specified key.
        Specified by:
        containsKey in interface IBmLongMap<T>
        Parameters:
        key - the key to check.
        Returns:
        true if the map contains the specified key, false otherwise.
      • keys

        public Collection<Long> keys()
        Description copied from interface: IBmLongMap
        Gets keys contained in this map.
        Specified by:
        keys in interface IBmLongMap<T>
        Returns:
        a collection of keys, never null.
      • values

        public Collection<T> values()
        Description copied from interface: IBmLongMap
        Gets values contained in this map.
        Specified by:
        values in interface IBmLongMap<T>
        Returns:
        a collection of values, never null.
      • copyKeys

        public List<Long> copyKeys()
        Copies keys.
        Returns:
        a list containing all the keys contained in this map, never null.
      • size

        public int size()
        Returns the number of elements in this map.
        Returns:
        the number of elements in this map.
      • asMap

        public BmLongHashMap<T> asMap()
        Creates a copy of this map.
        Returns:
        a BmLongHashMap containing all the mapping this map contains, never null.
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: IBmLongMap
        Returns whether this map is empty.
        Specified by:
        isEmpty in interface IBmLongMap<T>
        Returns:
        true if this map has no elements, false otherwise.
        See Also:
        #size()
      • getSegment

        protected final BmLongHashMap<T> getSegment​(int i)
        Gets segment by index.
        Parameters:
        i - The segment index.
        Returns:
        the segment.
      • createBmLongHashMap

        protected BmLongHashMap<T> createBmLongHashMap​(int i)
        Creates map for segment.
        Parameters:
        i - The segment index.
        Returns:
        the map for segment, never null.