|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSortedWordList
public class SortedWordList
This class maintains a sorted list of WordCount objects.
Field Summary | |
---|---|
private java.util.ArrayList<WordCount> |
words
|
Constructor Summary | |
---|---|
SortedWordList()
Constructor initializes the ArrayList data member. |
Method Summary | |
---|---|
void |
addAndIncrement(java.lang.String word)
This method takes as input a word and uses the cleanWord method to remove special characters. |
void |
addOnly(java.lang.String word)
This method takes as input a word, uses the cleanWord method to remove special characters, and inserts a new WordCount object with count of 0 only if the word does not yet appear in the list. The list must be maintained in sorted order by word. |
private java.lang.String |
cleanWord(java.lang.String word)
A helper method that takes as input a word and removes all characters that are not numbers or digits. |
void |
display()
Display all elements in the list. |
WordCount |
get(int i)
Return the ith WordCount object in the list. |
int |
size()
Return the size of the list. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.util.ArrayList<WordCount> words
Constructor Detail |
---|
public SortedWordList()
Method Detail |
---|
private java.lang.String cleanWord(java.lang.String word)
word
-
public void addOnly(java.lang.String word)
word
- public void addAndIncrement(java.lang.String word)
word
- public WordCount get(int i)
i
-
public int size()
public void display()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |