Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.statcato.utils
Class CategoryCounter

    java.lang.Object
      org.statcato.utils.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
Version:
  %I%, %G%
Author:
  Margaret Yau

Constructor Summary
`CategoryCounter()` Constructor.

Method Summary
`void` | `addCategory(java.lang.String cat)` Adds the given category to the counter.
`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
`clone, equals, finalize, 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

### 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`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD