1 package org.apache.lucene.search.suggest;
4 import java.util.ArrayList;
7 import org.apache.lucene.search.spell.TermFreqIterator;
10 * This wrapper buffers incoming elements.
12 public class BufferingTermFreqIteratorWrapper implements TermFreqIterator {
14 /** Entry in the buffer. */
15 public static final class Entry implements Comparable<Entry> {
19 public Entry(String word, float freq) {
24 public int compareTo(Entry o) {
25 return word.compareTo(o.word);
29 protected ArrayList<Entry> entries = new ArrayList<Entry>();
32 protected Entry curEntry;
34 public BufferingTermFreqIteratorWrapper(TermFreqIterator source) {
35 // read all source data into buffer
36 while (source.hasNext()) {
37 String w = source.next();
38 Entry e = new Entry(w, source.freq());
48 public boolean hasNext() {
49 return curPos < entries.size();
52 public String next() {
53 curEntry = entries.get(curPos);
58 public void remove() {
59 throw new UnsupportedOperationException("remove is not supported");
62 public List<Entry> entries() {