com.h3c.util

## Class TallyMap<K>

- java.lang.Object
- - com.h3c.util.TallyMap<K>

- Type Parameters:
    `K` - the key type

      public class TallyMap<K>
      extends Object

  This class maintains a map of (integer) counts. Note that this class is not synchronized.
  See Also:
    `TallyMapLong`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TallyMap()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `dec(K key)` Decrement the count associated with the specified key by 1.
    `int` | `dec(K key, int amount)` Decrement the count associated with the specified key by the given amount.
    `int` | `get(K key)` Returns the count associated with the specified key.
    `K` | `getHighestKey()` Returns the key that is "highest" in the natural ordering of the K class, and is also present (has a non-zero count) in the map.
    `Set<K>` | `getKeys()` Returns the key set for the backing map.
    `int` | `getTotal()` Returns the sum of all values in the map; i.e. the Grand Total.
    `int` | `inc(K key)` Increment the count associated with the specified key by 1.
    `int` | `inc(K key, int amount)` Increment the count associated with the specified key by the given amount.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### TallyMap

          public TallyMap()

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### inc

          public int inc(K key)

      Increment the count associated with the specified key by 1. If key is null, 0 is returned.
      Parameters:
        `key` - the key
      Returns:
        the value of the count after we have incremented it

    - #### inc

          public int inc(K key,
                int amount)

      Increment the count associated with the specified key by the given amount. If key is null, 0 is returned.
      Parameters:
        `key` - the key
        `amount` - the amount to increment by
      Returns:
        the value of the count after we have incremented it

    - #### dec

          public int dec(K key)

      Decrement the count associated with the specified key by 1. If key is null, 0 is returned.
      Parameters:
        `key` - the key
      Returns:
        the value of the count after we have decremented it

    - #### dec

          public int dec(K key,
                int amount)

      Decrement the count associated with the specified key by the given amount. If key is null, 0 is returned.
      Parameters:
        `key` - the key
        `amount` - the amount to decrement by
      Returns:
        the value of the count after we have decremented it

    - #### get

          public int get(K key)

      Returns the count associated with the specified key. If key is null, 0 is returned.
      Parameters:
        `key` - the key
      Returns:
        the value of the count

    - #### getKeys

          public Set<K> getKeys()

      Returns the key set for the backing map. Take care, because changes to the map will change the contents of your set and vice versa!
      Returns:
        the backing map key set

    - #### getTotal

          public int getTotal()

      Returns the sum of all values in the map; i.e. the Grand Total.
      Returns:
        the grand total

    - #### getHighestKey

          public K getHighestKey()

      Returns the key that is "highest" in the natural ordering of the K class, and is also present (has a non-zero count) in the map.
      Returns:
        the highest key

Copyright © 2014. All Rights Reserved.