Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
Bits.cs
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 namespace Lucene.Net.Spatial.Util
19 {
20  /// <summary>
21  /// Interface for Bitset-like structures.
22  /// </summary>
23  public interface IBits
24  {
25  bool Get(int index);
26  int Length();
27  }
28 
29  /// <summary>
30  /// Empty implementation, basically just so we can provide EMPTY_ARRAY
31  /// </summary>
32  public abstract class Bits : IBits
33  {
34  public static readonly Bits[] EMPTY_ARRAY = new Bits[0];
35 
36  public virtual bool Get(int index)
37  {
38  throw new System.NotImplementedException();
39  }
40 
41  public virtual int Length()
42  {
43  throw new System.NotImplementedException();
44  }
45  }
46 
47  /// <summary>
48  /// Bits impl of the specified length with all bits set.
49  /// </summary>
50  public class MatchAllBits : Bits
51  {
52  private readonly int len;
53 
54  public MatchAllBits(int len)
55  {
56  this.len = len;
57  }
58 
59  public override bool Get(int index)
60  {
61  return true;
62  }
63 
64  public override int Length()
65  {
66  return len;
67  }
68  }
69 
70  /// <summary>
71  /// Bits impl of the specified length with no bits set.
72  /// </summary>
73  public class MatchNoBits : Bits
74  {
75  private readonly int len;
76 
77  public MatchNoBits(int len)
78  {
79  this.len = len;
80  }
81 
82  public override bool Get(int index)
83  {
84  return false;
85  }
86 
87  public override int Length()
88  {
89  return len;
90  }
91  }
92 }