Package emissary.util

Class CounterSet

    • Field Detail

      • flexentry

        protected boolean flexentry
    • Constructor Detail

      • CounterSet

        public CounterSet()
        Create a new set of counters
      • CounterSet

        public CounterSet​(boolean flexentry)
        Create a new set of counters
        Parameters:
        flexentry - whether to allow non initialized keys to be incremented
      • CounterSet

        public CounterSet​(int initialCapacity)
        Create a new set of counters
        Parameters:
        initialCapacity - hash map initial capacity
      • CounterSet

        public CounterSet​(int initialCapacity,
                          float loadFactor)
        Create a new set of counters
        Parameters:
        initialCapacity - hash map initial capacity
        loadFactor - hash map load factor
    • Method Detail

      • setFlexEntry

        public void setFlexEntry​(boolean val)
        Change the flexentry setting
        Parameters:
        val - the new value
      • isFlexEntry

        public boolean isFlexEntry()
        Determine flex entry status
        Returns:
        true if unknown keys are allowed in add/increment
      • getKeys

        public Set<String> getKeys()
        Get the names of the current counters
      • addKey

        public void addKey​(String key)
        Add a counter
        Parameters:
        key - the name of the new Counter
      • addKeys

        public void addKeys​(Collection<String> keys)
        Add a collection of counters
        Parameters:
        keys - the names of the new counters
      • add

        public int add​(String key,
                       int val)
        Add value to a counter
        Parameters:
        key - the name of the counter
        val - how much to add
        Returns:
        the value of the counter, or -1 if it is not allowed
      • increment

        public int increment​(String key)
        Increment the named Counter
        Parameters:
        key - the name of the Counter
        Returns:
        the value of the counter, or -1 if it is not allowed
      • decrement

        public int decrement​(String key)
        Decrement the named Counter
        Parameters:
        key - the name of the Counter
        Returns:
        the value of the counter, or -1 if it is not allowed