Interface ReplicatedCounterMap<K>

    • Method Detail

      • get

        long get​(K key)
        Get the counter value for the given key.
        Parameters:
        key - the key to get the value for
        Returns:
        the current value of the counter at that key, or zero if no counter exists
      • increment

        ReplicatedCounterMap<K> increment​(K key,
                                          long amount)
        Increment the counter at the given key by the given amount.

        The counter will be created if it is not already in the map.

        Parameters:
        key - the key of the counter
        amount - the amount to increment by
        Returns:
        a new counter map with the incremented value
      • decrement

        ReplicatedCounterMap<K> decrement​(K key,
                                          long amount)
        Decrement the counter at the given key by the given amount.

        The counter will be created if it is not already in the map.

        Parameters:
        key - the key of the counter
        amount - the amount to decrement by
        Returns:
        a new counter map with the decremented value
      • remove

        ReplicatedCounterMap<K> remove​(K key)
        Remove the mapping for a key if it is present.
        Parameters:
        key - key whose mapping is to be removed from the map
        Returns:
        a new counter map with the removed mapping
      • clear

        ReplicatedCounterMap<K> clear()
        Remove all mappings from this counter map.
        Returns:
        a new empty counter map
      • size

        int size()
        Get the number of key-counter mappings in this counter map.
        Returns:
        the number of key-counter mappings in this counter map
      • isEmpty

        boolean isEmpty()
        Check whether this counter map is empty.
        Returns:
        true if this counter map contains no key-counter mappings
      • containsKey

        boolean containsKey​(K key)
        Check whether this counter map contains a mapping for the given key.
        Parameters:
        key - key whose presence in this map is to be tested
        Returns:
        true if this counter map contains a mapping for the given key
      • keySet

        java.util.Set<K> keySet()
        Get a Set view of the keys contained in this counter map.
        Returns:
        the keys contained in this counter map