it.unimi.dsi.sux4j.bits
Class AbstractRank

java.lang.Object
  extended by it.unimi.dsi.sux4j.bits.AbstractRank
All Implemented Interfaces:
Rank, java.io.Serializable
Direct Known Subclasses:
Rank16, Rank9, SparseRank

public abstract class AbstractRank
extends java.lang.Object
implements Rank

An abstract implementation of Rank providing a few obvious derived methods.

See Also:
Serialized Form

Constructor Summary
AbstractRank()
           
 
Method Summary
 long 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface it.unimi.dsi.sux4j.bits.Rank
bitVector, numBits, rank
 

Constructor Detail

AbstractRank

public AbstractRank()
Method Detail

count

public long count()
Description copied from interface: Rank
Returns the number of ones in the bit vector indexed by this class.

Specified by:
count in interface Rank
Returns:
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 interface Rank
Parameters:
from - a position in the bit vector.
to - a position in the bit vector.
Returns:
the number of ones between from (inclusive) and to (exclusive); if to is smaller than from, 0 is returned.

rankZero

public long rankZero(long pos)
Description copied from interface: Rank
Returns the number of zeroes preceding the specified position.

Specified by:
rankZero in interface Rank
Parameters:
pos - a position in the bit vector.
Returns:
the number of zeroes preceding pos.

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 interface Rank
Parameters:
from - a position in the bit vector.
to - a position in the bit vector.
Returns:
the number of zeroes between from (inclusive) and to (exclusive); if to is smaller than from, 0 is returned.