20 namespace Lucene.Net.Util
39 internal static readonly uint[] bitlist =
new uint[]
41 0x0, 0x1, 0x2, 0x21, 0x3, 0x31, 0x32, 0x321, 0x4, 0x41,
42 0x42, 0x421, 0x43, 0x431, 0x432, 0x4321, 0x5, 0x51,
43 0x52, 0x521, 0x53, 0x531, 0x532, 0x5321, 0x54, 0x541,
44 0x542, 0x5421, 0x543, 0x5431, 0x5432, 0x54321, 0x6,
45 0x61, 0x62, 0x621, 0x63, 0x631, 0x632, 0x6321, 0x64,
46 0x641, 0x642, 0x6421, 0x643, 0x6431, 0x6432, 0x64321,
47 0x65, 0x651, 0x652, 0x6521, 0x653, 0x6531, 0x6532,
48 0x65321, 0x654, 0x6541, 0x6542, 0x65421, 0x6543,
49 0x65431, 0x65432, 0x654321, 0x7, 0x71, 0x72, 0x721,
50 0x73, 0x731, 0x732, 0x7321, 0x74, 0x741, 0x742, 0x7421,
51 0x743, 0x7431, 0x7432, 0x74321, 0x75, 0x751, 0x752,
52 0x7521, 0x753, 0x7531, 0x7532, 0x75321, 0x754, 0x7541,
53 0x7542, 0x75421, 0x7543, 0x75431, 0x75432, 0x754321,
54 0x76, 0x761, 0x762, 0x7621, 0x763, 0x7631, 0x7632,
55 0x76321, 0x764, 0x7641, 0x7642, 0x76421, 0x7643,
56 0x76431, 0x76432, 0x764321, 0x765, 0x7651, 0x7652,
57 0x76521, 0x7653, 0x76531, 0x76532, 0x765321, 0x7654,
58 0x76541, 0x76542, 0x765421, 0x76543, 0x765431, 0x765432
59 , 0x7654321, 0x8, 0x81, 0x82, 0x821, 0x83, 0x831, 0x832
60 , 0x8321, 0x84, 0x841, 0x842, 0x8421, 0x843, 0x8431,
61 0x8432, 0x84321, 0x85, 0x851, 0x852, 0x8521, 0x853,
62 0x8531, 0x8532, 0x85321, 0x854, 0x8541, 0x8542, 0x85421
63 , 0x8543, 0x85431, 0x85432, 0x854321, 0x86, 0x861,
64 0x862, 0x8621, 0x863, 0x8631, 0x8632, 0x86321, 0x864,
65 0x8641, 0x8642, 0x86421, 0x8643, 0x86431, 0x86432,
66 0x864321, 0x865, 0x8651, 0x8652, 0x86521, 0x8653,
67 0x86531, 0x86532, 0x865321, 0x8654, 0x86541, 0x86542,
68 0x865421, 0x86543, 0x865431, 0x865432, 0x8654321, 0x87,
69 0x871, 0x872, 0x8721, 0x873, 0x8731, 0x8732, 0x87321,
70 0x874, 0x8741, 0x8742, 0x87421, 0x8743, 0x87431,
71 0x87432, 0x874321, 0x875, 0x8751, 0x8752, 0x87521,
72 0x8753, 0x87531, 0x87532, 0x875321, 0x8754, 0x87541,
73 0x87542, 0x875421, 0x87543, 0x875431, 0x875432,
74 0x8754321, 0x876, 0x8761, 0x8762, 0x87621, 0x8763,
75 0x87631, 0x87632, 0x876321, 0x8764, 0x87641, 0x87642,
76 0x876421, 0x87643, 0x876431, 0x876432, 0x8764321,
77 0x8765, 0x87651, 0x87652, 0x876521, 0x87653, 0x876531,
78 0x876532, 0x8765321, 0x87654,
79 0x876541, 0x876542, 0x8765421, 0x876543, 0x8765431,
101 private readonly
long[] arr;
102 private readonly
int words;
105 private int wordShift;
106 private int indexArray;
107 private int curDocId = - 1;
124 wordShift += 32; word = (long) ((ulong) word >> 32);
126 if ((word & 0x0000FFFF) == 0)
128 wordShift += 16; word = (long) ((ulong) word >> 16);
130 if ((word & 0x000000FF) == 0)
132 wordShift += 8; word = (long) ((ulong) word >> 8);
134 indexArray = (int) bitlist[word & 0xff];
159 public override int NextDoc()
165 word = (long) ((ulong) word >> 8);
173 return curDocId = NO_MORE_DOCS;
176 wordShift = - 1; // loop invariant code motion should move this
179 // after the first time, should I go with a linear search, or
180 // stick with the binary search in shift?
184 int bitIndex = (indexArray & 0x0f) + wordShift;
185 indexArray = (int) ((uint) indexArray >> 4);
186 // should i<<6 be cached as a separate variable?
187 // it would only save one cycle in the best circumstances.
188 return curDocId = (i << 6) + bitIndex;
191 public override int Advance(int target)
197 word = 0; // setup so next() will also return -1
198 return curDocId = NO_MORE_DOCS;
200 wordShift = target & 0x3f;
201 word = (long) ((ulong) arr[i] >> wordShift);
204 wordShift--; // compensate for 1 based arrIndex
212 return curDocId = NO_MORE_DOCS;
221 int bitIndex = (indexArray & 0x0f) + wordShift;
222 indexArray = (int) ((uint) indexArray >> 4);
223 // should i<<6 be cached as a separate variable?
224 // it would only save one cycle in the best circumstances.
225 return curDocId = (i << 6) + bitIndex;
228 public override int DocID()