Class CritBit64COW<V>

  • Type Parameters:
    V - value type
    All Implemented Interfaces:
    Iterable<V>

    public class CritBit64COW<V>
    extends CritBit64<V>
    implements Iterable<V>
    A concurrency enabled version of the CritBit64 tree. The implementation uses copy-on-write concurrency, therefore locking occurs only during updates, read-access is never locked. Currently write/update access is limited to one thread at a time. Read access guarantees full snapshot consistency for all read access including iterators. Version 1.3.4 - CB64COW is now a sub-class of CB64 Version 1.3.3 - Fixed 64COW iterators returning empty Entry for queries that shouldn't return anything. Version 1.3.2 - Improved mask checking in QueryWithMask Version 1.3.1 - Fixed issue #3 where iterators won't work with 'null' as values. Version 1.0: initial implementation
    Author:
    bvancea
    • Method Detail

      • create

        public static <V> CritBit64COW<V> create()
        Create a 1D crit-bit tree with 64 bit key length.
        Type Parameters:
        V - value type
        Returns:
        a 1D crit-bit tree
      • put

        public V put​(long key,
                     V val)
        Add a key value pair to the tree or replace the value if the key already exists.
        Overrides:
        put in class CritBit64<V>
        Parameters:
        key - key
        val - value
        Returns:
        The previous value or null if there was no previous value
      • size

        public int size()
        Get the size of the tree.
        Overrides:
        size in class CritBit64<V>
        Returns:
        the number of keys in the tree
      • contains

        public boolean contains​(long key)
        Check whether a given key exists in the tree.
        Overrides:
        contains in class CritBit64<V>
        Parameters:
        key - key
        Returns:
        true if the key exists otherwise false
      • get

        public V get​(long key)
        Get the value for a given key.
        Overrides:
        get in class CritBit64<V>
        Parameters:
        key - key
        Returns:
        the values associated with key or null if the key does not exist.
      • remove

        public V remove​(long key)
        Remove a key and its value
        Overrides:
        remove in class CritBit64<V>
        Parameters:
        key - key
        Returns:
        The value of the key of null if the value was not found.