public interface Select
extends Serializable
Selection is a basic building blocks for most succinct data structures. Usually, instances of this class class provide quick (e.g., constant time) selection.
There is some variance in the literature about the exact semantics of selection—in most cases, it is a matter of off-by-ones. This interface specifies a zero-based selection.
More precisely, select is applied to a bit vector in which bits positions are numbered
starting from zero. Then, select(r)
is the position of the
leftmost bit set to one and preceded by r
ones.
A number of equations link rank()
and select()
:
rank(0)=0
;
rank(length())
is the number of ones in the bit vector;
r < rank(length())
, then rank(select(r))==r
;
r ≥ rank(length())
, then select(r)=-1
;
p ≤ length()
, then p≤select(rank(p))
, and equality
holds iff there is a one at position p
.
Modifier and Type | Method and Description |
---|---|
BitVector |
bitVector()
Returns the bit vector indexed by this structure.
|
long |
numBits()
Returns the overall number of bits allocated by this structure.
|
long |
select(long rank)
Returns the position of the bit of given rank.
|
long select(long rank)
rank
- a rank.BitVector bitVector()
Note that you are not supposed to modify the returned vector.
long numBits()