Class FrequencySet<T>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map<T,​java.lang.Integer>

    public class FrequencySet<T>
    extends java.util.HashMap<T,​java.lang.Integer>
    A Set that manages how many occurances of a value occurs in the set. TODO: Sort entries lexically for set of values with 0 occurences.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private class  FrequencySet.FrequencyComparator  
      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      FrequencySet()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void _add​(T value, int v)  
      void add​(T value)
      Add a value to the set.
      void add0​(T value)
      Add a value to the set with 0 occurences.
      java.util.List<T> createFrequencyBasedList()
      Create an ordered list of values in the order of decreasing frequency of occurence.
      java.util.Set<T> createFrequencyBasedSet()
      Create an ordered set of values in the order of decreasing frequency of occurence.
      • Methods inherited from class java.util.HashMap

        clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        equals, hashCode
    • Constructor Detail

      • FrequencySet

        public FrequencySet()
    • Method Detail

      • add

        public void add​(T value)
        Add a value to the set.
        Parameters:
        value - the value to put in the set.
      • add0

        public void add0​(T value)
        Add a value to the set with 0 occurences.
        Parameters:
        value - the value to put in the set.
      • _add

        private void _add​(T value,
                          int v)
      • createFrequencyBasedList

        public java.util.List<T> createFrequencyBasedList()
        Create an ordered list of values in the order of decreasing frequency of occurence.
        Returns:
        the list of values in the order of decreasing frequency of occurence.
      • createFrequencyBasedSet

        public java.util.Set<T> createFrequencyBasedSet()
        Create an ordered set of values in the order of decreasing frequency of occurence.
        Returns:
        the set of values in the order of decreasing frequency of occurence.