Class BitUtil
A variety of high efficiency bit twiddling routines.
Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Assembly: Lucene.Net.dll
Syntax
public static class BitUtil
Methods
BitCount(byte)
Return the number of bits sets in b
.
Declaration
public static int BitCount(byte b)
Parameters
Type |
Name |
Description |
byte |
b |
|
Returns
BitList(byte)
Return the list of bits which are set in b
encoded as followed:
(i >>> (4 * n)) & 0x0F
is the offset of the n-th set bit of
the given byte plus one, or 0 if there are n or less bits set in the given
byte. For example
bitList(12)
returns 0x43:
-
0x43 & 0x0F
is 3, meaning the the first bit set is at offset 3-1 = 2, -
(0x43 >>> 4) & 0x0F
is 4, meaning there is a second bit set at offset 4-1=3, -
(0x43 >>> 8) & 0x0F
is 0, meaning there is no more bit set in this byte.
Declaration
public static int BitList(byte b)
Parameters
Type |
Name |
Description |
byte |
b |
|
Returns
NextHighestPowerOfTwo(int)
Returns the next highest power of two, or the current value if it's already a power of two or zero
Declaration
public static int NextHighestPowerOfTwo(int v)
Parameters
Type |
Name |
Description |
int |
v |
|
Returns
NextHighestPowerOfTwo(long)
Returns the next highest power of two, or the current value if it's already a power of two or zero
Declaration
public static long NextHighestPowerOfTwo(long v)
Parameters
Type |
Name |
Description |
long |
v |
|
Returns
Pop_AndNot(long[], long[], int, int)
Returns the popcount or cardinality of A & ~B.
Neither array is modified.
Declaration
public static long Pop_AndNot(long[] arr1, long[] arr2, int wordOffset, int numWords)
Parameters
Type |
Name |
Description |
long[] |
arr1 |
|
long[] |
arr2 |
|
int |
wordOffset |
|
int |
numWords |
|
Returns
Pop_Array(long[], int, int)
Returns the number of set bits in an array of longs.
Declaration
public static long Pop_Array(long[] arr, int wordOffset, int numWords)
Parameters
Type |
Name |
Description |
long[] |
arr |
|
int |
wordOffset |
|
int |
numWords |
|
Returns
Pop_Intersect(long[], long[], int, int)
Returns the popcount or cardinality of the two sets after an intersection.
Neither array is modified.
Declaration
public static long Pop_Intersect(long[] arr1, long[] arr2, int wordOffset, int numWords)
Parameters
Type |
Name |
Description |
long[] |
arr1 |
|
long[] |
arr2 |
|
int |
wordOffset |
|
int |
numWords |
|
Returns
Pop_Union(long[], long[], int, int)
Returns the popcount or cardinality of the union of two sets.
Neither array is modified.
Declaration
public static long Pop_Union(long[] arr1, long[] arr2, int wordOffset, int numWords)
Parameters
Type |
Name |
Description |
long[] |
arr1 |
|
long[] |
arr2 |
|
int |
wordOffset |
|
int |
numWords |
|
Returns
Pop_Xor(long[], long[], int, int)
Returns the popcount or cardinality of A ^ B
Neither array is modified.
Declaration
public static long Pop_Xor(long[] arr1, long[] arr2, int wordOffset, int numWords)
Parameters
Type |
Name |
Description |
long[] |
arr1 |
|
long[] |
arr2 |
|
int |
wordOffset |
|
int |
numWords |
|
Returns