Constructor and Description |
---|
BitArray()
Constructs a new bit array.
|
BitArray(int capacity,
boolean set)
Constructs a new bit array and an initial value.
|
BitArray(long[] array,
int nr)
Constructs a new bit array with the specified backing array.
|
Modifier and Type | Method and Description |
---|---|
int |
cardinality()
Returns the number of bits set to
true . |
void |
clear(int i)
Sets the ith bit to 0.
|
boolean |
get(int i)
Gets the value of the ith bit.
|
int |
nextFree()
Gets the index of the first clear bit.
|
int |
nextSet(int i)
Gets the next bit set to 1, starting from the ith bit.
|
void |
set(int i)
Sets the ith bit to 1.
|
long[] |
toArray()
The word array used to store the bits.
|
String |
toString() |
public BitArray(long[] array, int nr)
array
- array with bitsnr
- number of used bitspublic BitArray()
public BitArray(int capacity, boolean set)
capacity
- initial number of bitsset
- sets or clears all valuespublic long[] toArray()
public int cardinality()
true
.true
public boolean get(int i)
i
- index of the bittrue
if the ith bit is setpublic void set(int i)
i
- index of the bitpublic void clear(int i)
i
- index of the bitpublic int nextFree()
public int nextSet(int i)
i
- index from which to start the search (inclusive)Copyright © 2005–2023 BaseX Team. All rights reserved.