Interface Select

All Superinterfaces:
Serializable
All Known Implementing Classes:
HintedBsearchSelect, RankSelect, Select9, SimpleSelect, SparseSelect

public interface Select
extends Serializable
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., constant-time) selection.

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;
  • if r < rank(length()), then rank(select(r))==r;
  • if p ≤ length(), then p≤select(rank(p)), and equality holds iff there is a one at position p.

Warning: 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 calling select(long). Implementations might provide assertions to check the argument for correctness.

  • Method Summary

    Modifier and Type Method 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.
  • 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.

      Warning: 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.

      Parameters:
      rank - a rank.
      Returns:
      the position of the bit of given rank; if no such bit exists, behavior is undefined .
    • 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).