-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathILexicon.java
66 lines (58 loc) · 2.02 KB
/
ILexicon.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* Specification for a Lexicon as used in the Boggle
* assignment. Lexicons can be loaded from a scanner or an
* ArrayList, searched for a string to see if the string is a WORD, the
* PREFIX of a word, or is NOT_WORD (see LexStatus).
* <P>
* Words can be queried by using either a StringBuilder or a String.
* Implementations may convert one to another so that there's no
* guarantee that the <code>wordStatus</code> method doesn't create
* a new object in performing a lexicon query.
* <P>
*
* @author Owen Astrachan
*
*/
import java.util.*;
public interface ILexicon extends Iterable<String>{
/**
* Clear a lexicon and store all values read
* from the scanner for subsequent querying.
* @param s is the source of words for the lexicon
*/
public void load(Scanner s);
/**
* Clear a lexicon and store all values read
* from the list for subsequent querying.
* @param list is the source of words for the lexicon
*/
public void load(ArrayList<String> list);
/**
* Returns value specifying whether is is in the
* lexicon: WORD, is the prefix of a word in
* the lexicon: PREFIX, or is not a prefix and
* not a word: NOT_WORD. See LexStatus
* @param s represents the word/sequence queried
* @return status of s as to how it appears in lexicon
*/
public LexStatus wordStatus(StringBuilder s);
/**
* Similar to <code>wordStatus</code> that takes a
* StringBuilder parameter, but works with a String.
* @param s is the string queried
* @return status of s as to how it appears in lexicon
*/
public LexStatus wordStatus(String s);
/**
* Return an iterator over all words stored
* in the lexicon.
* @return an iterator over the words in the lexicon
*/
public Iterator<String> iterator();
/**
* Returns number of words stored in the lexicon
* (as from last call to load, for example).
* @return number of words in the lexicon
*/
public int size();
}