Class CountMap<T>


  • public class CountMap<T>
    extends java.lang.Object
    Keeps track of the number of times an item of type T has been added.
    Since:
    3 Jun 2011
    Author:
    Mark Taylor
    • Constructor Summary

      Constructors 
      Constructor Description
      CountMap()
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int addItem​(T item)
      Counts an item.
      void clear()
      Sets all the item counts to zero.
      int getCount​(T key)
      Returns the number of times a given item has been added.
      java.util.Set<T> keySet()
      Returns a set of all the items with a count of at least one.
      • Methods inherited from class java.lang.Object

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

      • CountMap

        public CountMap()
        Constructor.
    • Method Detail

      • addItem

        public int addItem​(T item)
        Counts an item.
        Parameters:
        item - item to count
      • getCount

        public int getCount​(T key)
        Returns the number of times a given item has been added.
        Parameters:
        key - item to count
      • keySet

        public java.util.Set<T> keySet()
        Returns a set of all the items with a count of at least one.
        Returns:
        key set
      • clear

        public void clear()
        Sets all the item counts to zero.