public class FreqList
extends java.lang.Object
This class represents a list of frequencies of Strings
Modifier and Type | Field and Description |
---|---|
protected java.util.Vector |
freqs
Frequencies vector of strings.
|
protected int |
index
Iterator index.
|
protected int |
totalElements
Total elements in the list.
|
Constructor and Description |
---|
FreqList()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
AddElement(java.lang.String newElem)
Adds an item to the list, increasing it frequency by one.
|
ValueFreq |
elementAt(int i)
The element at position indicated (i.e. the not-stored element inserted in position i)
|
ValueFreq |
getCurrent()
Obtains the element pointed currently by the iterator
|
boolean |
iterate()
Iterates to the next element in the list
|
ValueFreq |
mostCommon()
Extract the most commmon element, i.e. the element with highest frequency
|
int |
numElems()
The number of different elements stored
|
boolean |
outOfBounds()
Test if the iterator is out of the bounds of the list
|
void |
reset()
Reset the iterator to the beginning of the list.
|
int |
totalElems()
The total number of elements stored, i.e. the sum of all the frequencies
|
protected java.util.Vector freqs
protected int index
protected int totalElements
public FreqList()
Default constructor. Initializes all to zero and allocates memory.
public void AddElement(java.lang.String newElem)
Adds an item to the list, increasing it frequency by one.
newElem
- The elemento to be addedpublic ValueFreq mostCommon()
Extract the most commmon element, i.e. the element with highest frequency
public int numElems()
The number of different elements stored
public ValueFreq elementAt(int i)
The element at position indicated (i.e. the not-stored element inserted in position i)
i
- The index of the element to be retrievedpublic void reset()
Reset the iterator to the beginning of the list.
public boolean iterate()
Iterates to the next element in the list
public ValueFreq getCurrent()
Obtains the element pointed currently by the iterator
public boolean outOfBounds()
Test if the iterator is out of the bounds of the list
public int totalElems()
The total number of elements stored, i.e. the sum of all the frequencies