Package org.apache.lucene.util
Class BitUtil
- java.lang.Object
 - 
- org.apache.lucene.util.BitUtil
 
 
- 
public final class BitUtil extends java.lang.ObjectA variety of high efficiency bit twiddling routines. 
- 
- 
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intbitCount(byte b)Return the number of bits sets in b.static intbitList(byte b)Return the list of bits which are set in b encoded as followed:(i >>> (4 * n)) & 0x0Fis 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.static intnextHighestPowerOfTwo(int v)returns the next highest power of two, or the current value if it's already a power of two or zerostatic longnextHighestPowerOfTwo(long v)returns the next highest power of two, or the current value if it's already a power of two or zerostatic longpop_andnot(long[] arr1, long[] arr2, int wordOffset, int numWords)Returns the popcount or cardinality of A & ~B.static longpop_array(long[] arr, int wordOffset, int numWords)Returns the number of set bits in an array of longs.static longpop_intersect(long[] arr1, long[] arr2, int wordOffset, int numWords)Returns the popcount or cardinality of the two sets after an intersection.static longpop_union(long[] arr1, long[] arr2, int wordOffset, int numWords)Returns the popcount or cardinality of the union of two sets.static longpop_xor(long[] arr1, long[] arr2, int wordOffset, int numWords)Returns the popcount or cardinality of A ^ B Neither array is modified. 
 - 
 
- 
- 
Method Detail
- 
bitCount
public static int bitCount(byte b)
Return the number of bits sets in b. 
- 
bitList
public static int bitList(byte b)
Return the list of bits which are set in b encoded as followed:(i >>> (4 * n)) & 0x0Fis 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 examplebitList(12)returns 0x43:0x43 & 0x0Fis 3, meaning the the first bit set is at offset 3-1 = 2,(0x43 >>> 4) & 0x0Fis 4, meaning there is a second bit set at offset 4-1=3,(0x43 >>> 8) & 0x0Fis 0, meaning there is no more bit set in this byte.
 
- 
pop_array
public static long pop_array(long[] arr, int wordOffset, int numWords)Returns the number of set bits in an array of longs. 
- 
pop_intersect
public static long pop_intersect(long[] arr1, long[] arr2, int wordOffset, int numWords)Returns the popcount or cardinality of the two sets after an intersection. Neither array is modified. 
- 
pop_union
public static long pop_union(long[] arr1, long[] arr2, int wordOffset, int numWords)Returns the popcount or cardinality of the union of two sets. Neither array is modified. 
- 
pop_andnot
public static long pop_andnot(long[] arr1, long[] arr2, int wordOffset, int numWords)Returns the popcount or cardinality of A & ~B. Neither array is modified. 
- 
pop_xor
public static long pop_xor(long[] arr1, long[] arr2, int wordOffset, int numWords)Returns the popcount or cardinality of A ^ B Neither array is modified. 
- 
nextHighestPowerOfTwo
public static int nextHighestPowerOfTwo(int v)
returns the next highest power of two, or the current value if it's already a power of two or zero 
- 
nextHighestPowerOfTwo
public static long nextHighestPowerOfTwo(long v)
returns the next highest power of two, or the current value if it's already a power of two or zero 
 - 
 
 -