-
- All Known Implementing Classes:
OneWordS32BitSet
,OneWordS64BitSet
,S64BitSet
public interface IStateBitSet
Created by IntelliJ IDEA. User: julien Date: 12 juil. 2007 Time: 10:16:08
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
cardinality()
Number of bits on.void
clear()
Remove all bits;void
clear(int bitIndex)
Puts the specified bit off.void
clear(int fromIndex, int toIndex)
boolean
get(int bitIndex)
boolean
isEmpty()
int
nextClearBit(int fromIndex)
Returns the index of the first bit that is set tofalse
that occurs on or after the specified starting index.int
nextSetBit(int fromIndex)
Returns the index of the first bit that is set totrue
that occurs on or after the specified starting index.int
prevClearBit(int fromIndex)
Returns the index of the first bit that is set tofalse
that occurs on or before the specified starting index.int
prevSetBit(int fromIndex)
Returns the index of the first bit that is set totrue
that occurs on or before the specified starting index.void
set(int bitIndex)
Puts the specified bit on.void
set(int index, boolean value)
void
set(int fromIdex, int toIndex)
int
size()
Size of the bitset
-
-
-
Method Detail
-
cardinality
int cardinality()
Number of bits on. Sums the number of on bits in each integer.- Returns:
- the total number of bits on
-
size
int size()
Size of the bitset- Returns:
- size of the bitset
-
set
void set(int bitIndex)
Puts the specified bit on.- Parameters:
bitIndex
- the bit to put on
-
clear
void clear(int bitIndex)
Puts the specified bit off.- Parameters:
bitIndex
- the bit to put off
-
clear
void clear()
Remove all bits;
-
clear
void clear(int fromIndex, int toIndex)
-
set
void set(int index, boolean value)
-
set
void set(int fromIdex, int toIndex)
-
get
boolean get(int bitIndex)
-
nextSetBit
int nextSetBit(int fromIndex)
Returns the index of the first bit that is set totrue
that occurs on or after the specified starting index. If no such bit exists then -1 is returned. To iterate over thetrue
bits in aBitSet
, use the following loop: for(int i=bs.nextSetBit(0); i>=0; i=bs.nextSetBit(i+1)) { // operate on index i here }- Parameters:
fromIndex
- the index to start checking from (inclusive).- Returns:
- the index of the next set bit.
- Throws:
IndexOutOfBoundsException
- if the specified index is negative.- Since:
- 1.4
-
nextClearBit
int nextClearBit(int fromIndex)
Returns the index of the first bit that is set tofalse
that occurs on or after the specified starting index.- Parameters:
fromIndex
- the index to start checking from (inclusive).- Returns:
- the index of the next clear bit.
- Throws:
IndexOutOfBoundsException
- if the specified index is negative.- Since:
- 1.4
-
prevSetBit
int prevSetBit(int fromIndex)
Returns the index of the first bit that is set totrue
that occurs on or before the specified starting index. If no such bit exists then -1 is returned.- Parameters:
fromIndex
- the index to start checking from (inclusive).- Returns:
- the index of the previous set bit.
- Throws:
IndexOutOfBoundsException
- if the specified index is negative or too large
-
prevClearBit
int prevClearBit(int fromIndex)
Returns the index of the first bit that is set tofalse
that occurs on or before the specified starting index. If no such bit exists then -1 is returned.- Parameters:
fromIndex
- the index to start checking from (inclusive).- Returns:
- the index of the previous set bit.
- Throws:
IndexOutOfBoundsException
- if the specified index is negative or too large
-
isEmpty
boolean isEmpty()
-
-