Package it.unimi.dsi.sux4j.bits
Interface Select
 All Superinterfaces:
Serializable
 All Known Implementing Classes:
HintedBsearchSelect
,RankSelect
,Select9
,SimpleBigSelect
,SimpleSelect
,SparseSelect
A data structure providing selection over a bit array.
Selection is a basic building blocks for most succinct data structures. Usually, instances of this class class provide quick (e.g., constanttime) selection.
This interface specifies a zerobased 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. There
are also default bulk methods select(long, long[], int, int)
and select(long)
whose implementation delegates to select(long)
but might be implemented more
efficiently.
A number of equations link rank()
and select()
:
rank(0)=0
;rank(length())
is the number of ones in the bit vector; if
r < rank(length())
, thenrank(select(r))==r
;  if
p ≤ length()
, thenp≤select(rank(p))
, and equality holds iff there is a one at positionp
.
 See Also:
 API Notes:
 From Sux4J 5.2.0, the
select(long)
method is no longer required to return −1 when no bit with the given rank exists. If you relied on such behavior, please test the argument before callingselect(long)
. Implementations might provide assertions to check the argument for correctness.

Method Summary
Modifier and TypeMethodDescriptionReturns 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.default long[]
select
(long rank, long[] dest) Performs a bulk select of consecutive ranks into a given array.default long[]
select
(long rank, long[] dest, int offset, int length) Performs a bulk select of consecutive ranks into a given array fragment.

Method Details

select
long select(long rank) Returns the position of the bit of given rank. Equivalently, returns the greatest position that is preceded by the specified number of ones. Parameters:
rank
 a rank. Returns:
 the position of the bit of given rank; if no such bit exists, behavior is undefined .
 API Notes:
 From Sux4J 5.2.0, this method is no longer required to return −1 when no bit with the given rank exists. If you relied on such behavior, please test the argument before calling this method. Implementations might provide assertions to check the argument for correctness.

select
default long[] select(long rank, long[] dest, int offset, int length) Performs a bulk select of consecutive ranks into a given array fragment. Parameters:
rank
 the first rank to select.dest
 the destination array; it will be filled withlength
positions of consecutive bits starting at positionoffset
; must be of length greater thanoffset
.offset
 the first bit position written indest
.length
 the number of bit positions indest
starting atoffset
. Returns:
dest
 See Also:
 API Notes:
 Implementations are allowed to require that
dest
be of length greater thanoffset
even iflength
is zero.  Implementation Specification:
 This implementation just makes multiple calls to
select(long)
.

select
default long[] select(long rank, long[] dest) Performs a bulk select of consecutive ranks into a given array. Parameters:
rank
 the first rank to select.dest
 the destination array; it will be filled with position of consecutive bits. Returns:
dest
 See Also:
 API Notes:
 Implementations are allowed to require that
dest
be of length greater than zero.  Implementation Specification:
 This implementation just delegates to
select(long, long[], int, int)
.

bitVector
BitVector bitVector()Returns the bit vector indexed by this structure.Note that you are not supposed to modify the returned vector.
 Returns:
 the bit vector indexed by this structure.

numBits
long numBits()Returns the overall number of bits allocated by this structure. Returns:
 the overall number of bits allocated by this structure (not including the bits of the indexed vector).
