Class MultiBitSetBag

java.lang.Object
uk.ac.starlink.ttools.moc.MultiBitSetBag
All Implemented Interfaces:
IndexBag

public class MultiBitSetBag extends Object implements IndexBag
IndexBag implementation based on a dynamically managed collection of BitSets. Regions into which values are never stored take up no storage. It can hold non-negative numbers up to a given limit.
Since:
28 Jan 2025
Author:
Mark Taylor
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Default size for a single BitSet.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MultiBitSetBag(long size)
    Constructs a bag with a default bank size.
    MultiBitSetBag(long size, int bankSize)
    Constructs a bag with a specified bank size.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addIndex(long lindex)
    Adds an index to this bag.
    long
    Returns the number of distinct indices in this bag.
    boolean
    hasIndex(long lindex)
    Indicates whether the given index has previously been added to this bag.
    Returns an iterator over all the integers added to this bag, supplied in ascending order.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DFLT_BANKSIZE

      public static final int DFLT_BANKSIZE
      Default size for a single BitSet.
      See Also:
  • Constructor Details

    • MultiBitSetBag

      public MultiBitSetBag(long size)
      Constructs a bag with a default bank size. Non-negative integers smaller than the given size value can be held.
      Parameters:
      size - one greater than the largest permitted value
    • MultiBitSetBag

      public MultiBitSetBag(long size, int bankSize)
      Constructs a bag with a specified bank size. Non-negative integers smaller than the given size value can be held.
      Parameters:
      size - one greater than the largest permitted value
      bankSize - size of sub-buffers into which the storage is divided
  • Method Details

    • addIndex

      public void addIndex(long lindex)
      Description copied from interface: IndexBag
      Adds an index to this bag. If the index is already present, there is no effect.

      If the index is outside of the range permitted by this bag, behaviour is undefined.

      Specified by:
      addIndex in interface IndexBag
      Parameters:
      lindex - integer to add
    • hasIndex

      public boolean hasIndex(long lindex)
      Description copied from interface: IndexBag
      Indicates whether the given index has previously been added to this bag.

      If the index is outside of the range permitted by this bag, behaviour is undefined.

      Specified by:
      hasIndex in interface IndexBag
      Parameters:
      lindex - integer to check
      Returns:
      true iff the given index has previously been added
    • getCount

      public long getCount()
      Description copied from interface: IndexBag
      Returns the number of distinct indices in this bag.
      Specified by:
      getCount in interface IndexBag
      Returns:
      count of added integers
    • sortedLongIterator

      public PrimitiveIterator.OfLong sortedLongIterator()
      Description copied from interface: IndexBag
      Returns an iterator over all the integers added to this bag, supplied in ascending order.
      Specified by:
      sortedLongIterator in interface IndexBag
      Returns:
      sorted iterator over indices