Class DefaultAtomicCounterMap<K>

    • Method Summary

      All Methods Instance Methods Concrete 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.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultAtomicCounterMap

        public DefaultAtomicCounterMap​(AsyncAtomicCounterMap<K> asyncCounterMap,
                                       long operationTimeoutMillis)
    • Method Detail

      • incrementAndGet

        public long incrementAndGet​(K key)
        Description copied from interface: AtomicCounterMap
        Increments by one the value currently associated with key, and returns the new value.
        Specified by:
        incrementAndGet in interface AtomicCounterMap<K>
        Parameters:
        key - key with which the specified value is to be associated
        Returns:
        incremented value
      • decrementAndGet

        public long decrementAndGet​(K key)
        Description copied from interface: AtomicCounterMap
        Decrements by one the value currently associated with key, and returns the new value.
        Specified by:
        decrementAndGet in interface AtomicCounterMap<K>
        Parameters:
        key - key with which the specified value is to be associated
        Returns:
        updated value
      • getAndIncrement

        public long getAndIncrement​(K key)
        Description copied from interface: AtomicCounterMap
        Increments by one the value currently associated with key, and returns the old value.
        Specified by:
        getAndIncrement in interface AtomicCounterMap<K>
        Parameters:
        key - key with which the specified value is to be associated
        Returns:
        previous value
      • getAndDecrement

        public long getAndDecrement​(K key)
        Description copied from interface: AtomicCounterMap
        Decrements by one the value currently associated with key, and returns the old value.
        Specified by:
        getAndDecrement in interface AtomicCounterMap<K>
        Parameters:
        key - key with which the specified value is to be associated
        Returns:
        previous value
      • addAndGet

        public long addAndGet​(K key,
                              long delta)
        Description copied from interface: AtomicCounterMap
        Adds delta to the value currently associated with key, and returns the new value.
        Specified by:
        addAndGet in interface AtomicCounterMap<K>
        Parameters:
        key - key with which the specified value is to be associated
        delta - the value to add
        Returns:
        updated value
      • getAndAdd

        public long getAndAdd​(K key,
                              long delta)
        Description copied from interface: AtomicCounterMap
        Adds delta to the value currently associated with key, and returns the old value.
        Specified by:
        getAndAdd in interface AtomicCounterMap<K>
        Parameters:
        key - key with which the specified value is to be associated
        delta - the value to add
        Returns:
        previous value
      • get

        public long get​(K key)
        Description copied from interface: AtomicCounterMap
        Returns the value associated with key, or zero if there is no value associated with key.
        Specified by:
        get in interface AtomicCounterMap<K>
        Parameters:
        key - key with which the specified value is to be associated
        Returns:
        current value
      • put

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

        public long putIfAbsent​(K key,
                                long newValue)
        Description copied from interface: AtomicCounterMap
        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.
        Specified by:
        putIfAbsent in interface AtomicCounterMap<K>
        Parameters:
        key - key with which the specified value is to be associated
        newValue - the value to put
        Returns:
        previous value or zero
      • replace

        public boolean replace​(K key,
                               long expectedOldValue,
                               long newValue)
        Description copied from interface: AtomicCounterMap
        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.
        Specified by:
        replace in interface AtomicCounterMap<K>
        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

        public long remove​(K key)
        Description copied from interface: AtomicCounterMap
        Removes and returns the value associated with key. If key is not in the map, this method has no effect and returns zero.
        Specified by:
        remove in interface AtomicCounterMap<K>
        Parameters:
        key - key with which the specified value is to be associated
        Returns:
        the previous value associated with the specified key or null
      • remove

        public boolean remove​(K key,
                              long value)
        Description copied from interface: AtomicCounterMap
        If (key, value) is currently in the map, this method removes it and returns true; otherwise, this method returns false.
        Specified by:
        remove in interface AtomicCounterMap<K>
        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

        public int size()
        Description copied from interface: AtomicCounterMap
        Returns the number of entries in the map.
        Specified by:
        size in interface AtomicCounterMap<K>
        Returns:
        the number of entries in the map, including 0 values
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: AtomicCounterMap
        If the map is empty, returns true, otherwise false.
        Specified by:
        isEmpty in interface AtomicCounterMap<K>
        Returns:
        true if the map is empty.