Class SynchronizedFrequencyCounter<T>

  • Type Parameters:
    T - the type of the object

    public class SynchronizedFrequencyCounter<T>
    extends Object
    SynchronizedFrequencyCounter is the class used to count the frequency of an object in a thread-safe way.
    • Field Detail

      • map

        private final Map<T,​Integer> map
        The map field is used to store the frequency of an object.
    • Constructor Detail

      • SynchronizedFrequencyCounter

        public SynchronizedFrequencyCounter()
    • Method Detail

      • add

        public void add​(T object)
        The add method is used to add an object to the map.
        Parameters:
        object - the object
      • getMapSortedByValueAndKey

        public Map<T,​Integer> getMapSortedByValueAndKey()
        The getMapSortedByValueAndKey method is used to sort the map by value and key.
        Returns:
        the sorted map