blob: 3c0b615f0b202d0f384d22b64f12c866fc1b5ab2 (
plain)
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
|
package org.grammaticalframework.pgf;
import java.util.Iterator;
class Lexicon implements Iterable<FullFormEntry> {
private Concr concr;
private String prefix;
private FullFormIterator iter;
public Lexicon(Concr concr, String prefix) {
this.concr = concr;
this.prefix = prefix;
this.iter = lookupWordPrefix(concr, prefix);
}
public Iterator<FullFormEntry> iterator() {
if (iter == null) {
// If someone has asked for a second iterator over
// the same parse results then we have to parse again.
return lookupWordPrefix(concr, prefix);
} else {
FullFormIterator tmp_iter = iter;
iter = null;
return tmp_iter;
}
}
static private native FullFormIterator lookupWordPrefix(Concr concr, String prefix);
}
|