Class Counter<T>

    • Constructor Detail

      • Counter

        public Counter()
    • Method Detail

      • getCount

        public double getCount​(T element)
      • incrementCount

        public void incrementCount​(T element,
                                   double inc)
      • incrementAll

        public void incrementAll​(Collection<T> elements,
                                 double inc)
        This method will increment all elements in collection
        Parameters:
        elements -
        inc -
      • incrementAll

        public <T2 extends T> void incrementAll​(Counter<T2> other)
        This method will increment counts of this counter by counts from other counter
        Parameters:
        other -
      • getProbability

        public double getProbability​(T element)
        This method returns probability of given element
        Parameters:
        element -
        Returns:
      • setCount

        public double setCount​(T element,
                               double count)
        This method sets new counter value for given element
        Parameters:
        element - element to be updated
        count - new counter value
        Returns:
        previous value
      • keySet

        public Set<T> keySet()
        This method returns Set of elements used in this counter
        Returns:
      • isEmpty

        public boolean isEmpty()
        This method returns TRUE if counter has no elements, FALSE otherwise
        Returns:
      • keySetSorted

        public List<T> keySetSorted()
        This method returns List of elements, sorted by their counts
        Returns:
      • normalize

        public void normalize()
        This method will apply normalization to counter values and totals.
      • rebuildTotals

        protected void rebuildTotals()
      • totalCount

        public double totalCount()
        This method returns total sum of counter values
        Returns:
      • removeKey

        public double removeKey​(T element)
        This method removes given key from counter
        Parameters:
        element -
        Returns:
        counter value
      • argMax

        public T argMax()
        This method returns element with highest counter value
        Returns:
      • dropElementsBelowThreshold

        public void dropElementsBelowThreshold​(double threshold)
        This method will remove all elements with counts below given threshold from counter
        Parameters:
        threshold -
      • containsElement

        public boolean containsElement​(T element)
        This method checks, if element exist in this counter
        Parameters:
        element -
        Returns:
      • clear

        public void clear()
        This method effectively resets counter to empty state
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • size

        public int size()
        Returns total number of tracked elements
        Returns:
      • keepTopNElements

        public void keepTopNElements​(int N)
        This method removes all elements except of top N by counter values
        Parameters:
        N -