Package it.unimi.dsi.sux4j.bits
Class AbstractRank
java.lang.Object
it.unimi.dsi.sux4j.bits.AbstractRank
- All Implemented Interfaces:
Rank
,Serializable
- Direct Known Subclasses:
Rank11
,Rank16
,Rank9
,SparseRank
An abstract implementation of
Rank
providing a few obvious derived methods.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
count()
Returns the number of ones in the bit vector indexed by this class.long
rank
(long from, long to) Returns the number of ones in the specified interval.long
rankZero
(long pos) Returns the number of zeroes preceding the specified position.long
rankZero
(long from, long to) Returns the number of zeroes in the specified interval.
-
Constructor Details
-
AbstractRank
public AbstractRank()
-
-
Method Details
-
count
public long count()Description copied from interface:Rank
Returns the number of ones in the bit vector indexed by this class. -
rank
public long rank(long from, long to) Description copied from interface:Rank
Returns the number of ones in the specified interval.- Specified by:
rank
in interfaceRank
- Parameters:
from
- a position in the bit vector between 0 (inclusive) and the length of the bit vector (inclusive).to
- a position in the bit vector between 0 (inclusive) and the length of the bit vector (inclusive); must be greater than or equal tofrom
.- Returns:
- the number of ones between
from
(inclusive) andto
(exclusive); if the parameters are out of bounds, behavior is undefined.
-
rankZero
public long rankZero(long pos) Description copied from interface:Rank
Returns the number of zeroes preceding the specified position. -
rankZero
public long rankZero(long from, long to) Description copied from interface:Rank
Returns the number of zeroes in the specified interval.- Specified by:
rankZero
in interfaceRank
- Parameters:
from
- a position in the bit vector between 0 (inclusive) and the length of the bit vector (inclusive).to
- a position in the bit vector between 0 (inclusive) and the length of the bit vector (inclusive); must be greater than or equal tofrom
.- Returns:
- the number of zeros between
from
(inclusive) andto
(exclusive); if the parameters are out of bounds, behavior is undefined (might throw an exception).
-