C# Class Lucene.Net.Util.BitUtil

A variety of high efficiencly bit twiddling routines.
Exibir arquivo Open project: synhershko/lucene.net Class Usage Examples

Public Properties

Property Type Description
ntzTable byte[]

Public Methods

Method Description
IsPowerOfTwo ( int v ) : bool

returns true if v is a power of two or zero

IsPowerOfTwo ( long v ) : bool

returns true if v is a power of two or zero

NextHighestPowerOfTwo ( int v ) : int

returns the next highest power of two, or the current value if it's already a power of two or zero

NextHighestPowerOfTwo ( long v ) : long

returns the next highest power of two, or the current value if it's already a power of two or zero

Ntz ( int val ) : int

Returns number of trailing zeros in a 32 bit int value.

Ntz ( long val ) : int

Returns number of trailing zeros in a 64 bit long value.

Ntz2 ( long x ) : int

returns 0 based index of first set bit (only works for x!=0)
This is an alternate implementation of ntz()

Ntz3 ( long x ) : int

returns 0 based index of first set bit
This is an alternate implementation of ntz()

Pop ( long x ) : int

Returns the number of bits set in the long

Pop_andnot ( long A, long B, int wordOffset, int numWords ) : long

Returns the popcount or cardinality of A & ~B Neither array is modified.

Pop_array ( long A, int wordOffset, int numWords ) : long

Returns the number of set bits in an array of longs.

Pop_intersect ( long A, long B, int wordOffset, int numWords ) : long

Returns the popcount or cardinality of the two sets after an intersection. Neither array is modified.

Pop_union ( long A, long B, int wordOffset, int numWords ) : long

Returns the popcount or cardinality of the union of two sets. Neither array is modified.

Pop_xor ( long A, long B, int wordOffset, int numWords ) : long

Method Details

IsPowerOfTwo() public static method

returns true if v is a power of two or zero
public static IsPowerOfTwo ( int v ) : bool
v int
return bool

IsPowerOfTwo() public static method

returns true if v is a power of two or zero
public static IsPowerOfTwo ( long v ) : bool
v long
return bool

NextHighestPowerOfTwo() public static method

returns the next highest power of two, or the current value if it's already a power of two or zero
public static NextHighestPowerOfTwo ( int v ) : int
v int
return int

NextHighestPowerOfTwo() public static method

returns the next highest power of two, or the current value if it's already a power of two or zero
public static NextHighestPowerOfTwo ( long v ) : long
v long
return long

Ntz() public static method

Returns number of trailing zeros in a 32 bit int value.
public static Ntz ( int val ) : int
val int
return int

Ntz() public static method

Returns number of trailing zeros in a 64 bit long value.
public static Ntz ( long val ) : int
val long
return int

Ntz2() public static method

returns 0 based index of first set bit (only works for x!=0)
This is an alternate implementation of ntz()
public static Ntz2 ( long x ) : int
x long
return int

Ntz3() public static method

returns 0 based index of first set bit
This is an alternate implementation of ntz()
public static Ntz3 ( long x ) : int
x long
return int

Pop() public static method

Returns the number of bits set in the long
public static Pop ( long x ) : int
x long
return int

Pop_andnot() public static method

Returns the popcount or cardinality of A & ~B Neither array is modified.
public static Pop_andnot ( long A, long B, int wordOffset, int numWords ) : long
A long
B long
wordOffset int
numWords int
return long

Pop_array() public static method

Returns the number of set bits in an array of longs.
public static Pop_array ( long A, int wordOffset, int numWords ) : long
A long
wordOffset int
numWords int
return long

Pop_intersect() public static method

Returns the popcount or cardinality of the two sets after an intersection. Neither array is modified.
public static Pop_intersect ( long A, long B, int wordOffset, int numWords ) : long
A long
B long
wordOffset int
numWords int
return long

Pop_union() public static method

Returns the popcount or cardinality of the union of two sets. Neither array is modified.
public static Pop_union ( long A, long B, int wordOffset, int numWords ) : long
A long
B long
wordOffset int
numWords int
return long

Pop_xor() public static method

public static Pop_xor ( long A, long B, int wordOffset, int numWords ) : long
A long
B long
wordOffset int
numWords int
return long

Property Details

ntzTable public_oe static_oe property

table of number of trailing zeros in a byte
public static byte[] ntzTable
return byte[]