cvsimport
[beagle.git] / beagled / Lucene.Net / Index / TermEnum.cs
blobd190602f6acc439f60886acd43500acd11f9e68d
1 /*
2 * Copyright 2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using System;
19 namespace Lucene.Net.Index
22 /// <summary>Abstract class for enumerating terms.
23 /// <p>Term enumerations are always ordered by Term.compareTo(). Each term in
24 /// the enumeration is greater than all that precede it.
25 /// </summary>
27 public abstract class TermEnum
29 /// <summary>Increments the enumeration to the next element. True if one exists.</summary>
30 public abstract bool Next();
32 /// <summary>Returns the current Term in the enumeration.</summary>
33 public abstract Term Term();
35 /// <summary>Returns the docFreq of the current Term in the enumeration.</summary>
36 public abstract int DocFreq();
38 /// <summary>Closes the enumeration to further activity, freeing resources. </summary>
39 public abstract void Close();
41 // Term Vector support
43 /// <summary>Skips terms to the first beyond the current whose value is
44 /// greater or equal to <i>target</i>. <p>Returns true iff there is such
45 /// an entry. <p>Behaves as if written: <pre>
46 /// public boolean skipTo(Term target) {
47 /// do {
48 /// if (!next())
49 /// return false;
50 /// } while (target > term());
51 /// return true;
52 /// }
53 /// </pre>
54 /// Some implementations are considerably more efficient than that.
55 /// </summary>
56 public virtual bool SkipTo(Term target)
58 do
60 if (!Next())
61 return false;
63 while (target.CompareTo(Term()) > 0);
64 return true;