Documentation of 'org.statcato.utils.CategoryCounter' Java class
CategoryCounter
org.statcato.utils

Class CategoryCounter



  • public class CategoryCounter
    extends java.lang.Object
    Keeps track of a previously unspecified number of categories and the frequency of each category. Maps each category to a unique number.
    Since:
    1.0
    • Constructor Summary

      Constructors 
      Constructor and Description
      CategoryCounter()
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addCategory(java.lang.String cat)
      Adds the given category to the counter.
      java.util.Vector<java.lang.String> getCategories() 
      java.lang.String getCategory(int i)
      Returns the category at the given index.
      int getEqualFrequency()
      Checks if all the frequencies are the same.
      int getFrequency(java.lang.String cat)
      Returns the frequency of the given category.
      int getIndex(java.lang.String cat)
      Returns the index corresponding to the given category, or returns -1 if the category is not found.
      int getSize()
      Returns the number of categories found by this counter.
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CategoryCounter

        public CategoryCounter()
        Constructor.
    • Method Detail

      • addCategory

        public void addCategory(java.lang.String cat)
        Adds the given category to the counter.
        Parameters:
        cat - category string
      • getCategory

        public java.lang.String getCategory(int i)
        Returns the category at the given index.
        Parameters:
        i - index
        Returns:
        category at the given index
      • getCategories

        public java.util.Vector<java.lang.String> getCategories()
      • getIndex

        public int getIndex(java.lang.String cat)
        Returns the index corresponding to the given category, or returns -1 if the category is not found.
        Parameters:
        cat - category
        Returns:
        index of the category, or -1 if it does not exist
      • getSize

        public int getSize()
        Returns the number of categories found by this counter.
        Returns:
        number of categories
      • getEqualFrequency

        public int getEqualFrequency()
        Checks if all the frequencies are the same. If so, return it; otherwise, return -1.
        Returns:
        the frequency that all the categories have, or -1 if not all frequencies are equal
      • getFrequency

        public int getFrequency(java.lang.String cat)
        Returns the frequency of the given category.
        Parameters:
        cat - category
        Returns:
        frequency of the given category
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.