Interface AtomicCounterMap<K>

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      long addAndGet​(K key, long delta)
      Adds delta to the value currently associated with key, and returns the new value.
      void clear()
      Clears all entries from the map.
      long decrementAndGet​(K key)
      Decrements by one the value currently associated with key, and returns the new value.
      long get​(K key)
      Returns the value associated with key, or zero if there is no value associated with key.
      long getAndAdd​(K key, long delta)
      Adds delta to the value currently associated with key, and returns the old value.
      long getAndDecrement​(K key)
      Decrements by one the value currently associated with key, and returns the old value.
      long getAndIncrement​(K key)
      Increments by one the value currently associated with key, and returns the old value.
      long incrementAndGet​(K key)
      Increments by one the value currently associated with key, and returns the new value.
      boolean isEmpty()
      If the map is empty, returns true, otherwise false.
      default DistributedPrimitive.Type primitiveType()
      Returns the type of primitive.
      long put​(K key, long newValue)
      Associates ewValue with key in this map, and returns the value previously associated with key, or zero if there was no such value.
      long putIfAbsent​(K key, long newValue)
      If key is not already associated with a value or if key is associated with zero, associate it with newValue.
      long remove​(K key)
      Removes and returns the value associated with key.
      boolean remove​(K key, long value)
      If (key, value) is currently in the map, this method removes it and returns true; otherwise, this method returns false.
      boolean replace​(K key, long expectedOldValue, long newValue)
      If (key, expectedOldValue) is currently in the map, this method replaces expectedOldValue with newValue and returns true; otherwise, this method return false.
      int size()
      Returns the number of entries in the map.
    • Method Detail

      • incrementAndGet

        long incrementAndGet​(K key)
        Increments by one the value currently associated with key, and returns the new value.
        Parameters:
        key - key with which the specified value is to be associated
        Returns:
        incremented value
      • decrementAndGet

        long decrementAndGet​(K key)
        Decrements by one the value currently associated with key, and returns the new value.
        Parameters:
        key - key with which the specified value is to be associated
        Returns:
        updated value
      • getAndIncrement

        long getAndIncrement​(K key)
        Increments by one the value currently associated with key, and returns the old value.
        Parameters:
        key - key with which the specified value is to be associated
        Returns:
        previous value
      • getAndDecrement

        long getAndDecrement​(K key)
        Decrements by one the value currently associated with key, and returns the old value.
        Parameters:
        key - key with which the specified value is to be associated
        Returns:
        previous value
      • addAndGet

        long addAndGet​(K key,
                       long delta)
        Adds delta to the value currently associated with key, and returns the new value.
        Parameters:
        key - key with which the specified value is to be associated
        delta - the value to add
        Returns:
        updated value
      • getAndAdd

        long getAndAdd​(K key,
                       long delta)
        Adds delta to the value currently associated with key, and returns the old value.
        Parameters:
        key - key with which the specified value is to be associated
        delta - the value to add
        Returns:
        previous value
      • get

        long get​(K key)
        Returns the value associated with key, or zero if there is no value associated with key.
        Parameters:
        key - key with which the specified value is to be associated
        Returns:
        current value
      • put

        long put​(K key,
                 long newValue)
        Associates ewValue with key in this map, and returns the value previously associated with key, or zero if there was no such value.
        Parameters:
        key - key with which the specified value is to be associated
        newValue - the value to put
        Returns:
        previous value or zero
      • putIfAbsent

        long putIfAbsent​(K key,
                         long newValue)
        If key is not already associated with a value or if key is associated with zero, associate it with newValue. Returns the previous value associated with key, or zero if there was no mapping for key.
        Parameters:
        key - key with which the specified value is to be associated
        newValue - the value to put
        Returns:
        previous value or zero
      • replace

        boolean replace​(K key,
                        long expectedOldValue,
                        long newValue)
        If (key, expectedOldValue) is currently in the map, this method replaces expectedOldValue with newValue and returns true; otherwise, this method return false. If expectedOldValue is zero, this method will succeed if (key, zero) is currently in the map, or if key is not in the map at all.
        Parameters:
        key - key with which the specified value is to be associated
        expectedOldValue - the expected value
        newValue - the value to replace
        Returns:
        true if the value was replaced, false otherwise
      • remove

        long remove​(K key)
        Removes and returns the value associated with key. If key is not in the map, this method has no effect and returns zero.
        Parameters:
        key - key with which the specified value is to be associated
        Returns:
        the previous value associated with the specified key or null
      • remove

        boolean remove​(K key,
                       long value)
        If (key, value) is currently in the map, this method removes it and returns true; otherwise, this method returns false.
        Parameters:
        key - key with which the specified value is to be associated
        value - the value to remove
        Returns:
        true if the value was removed, false otherwise
      • size

        int size()
        Returns the number of entries in the map.
        Returns:
        the number of entries in the map, including 0 values
      • isEmpty

        boolean isEmpty()
        If the map is empty, returns true, otherwise false.
        Returns:
        true if the map is empty.
      • clear

        void clear()
        Clears all entries from the map.