Class SingletonContainer


public final class SingletonContainer extends ImmutableContainer
  • Constructor Details

    • SingletonContainer

      public SingletonContainer(short value)
  • Method Details

    • intValue

      public int intValue()
    • add

      public Container add(int begin, int end)
      Description copied from class: Container
      Return a new container with all shorts in [begin,end) added using an unsigned interpretation.
      Specified by:
      add in class Container
      Parameters:
      begin - start of range (inclusive)
      end - end of range (exclusive)
      Returns:
      the new container
    • set

      public Container set(short x)
      Description copied from class: Container
      Return a new container with the short given as parameter added.
      Specified by:
      set in class Container
      Parameters:
      x - a short to be added
      Returns:
      a new container with x added
    • and

      public Container and(ArrayContainer x)
      Description copied from class: Container
      Computes the bitwise AND of this container with another (intersection). This container as well as the provided container are left unaffected.
      Specified by:
      and in class Container
      Parameters:
      x - Another container
      Returns:
      aggregated container
    • and

      public Container and(BitmapContainer x)
      Description copied from class: Container
      Computes the bitwise AND of this container with another (intersection). This container as well as the provided container are left unaffected.
      Specified by:
      and in class Container
      Parameters:
      x - Another container
      Returns:
      aggregated container
    • and

      public Container and(RunContainer x)
      Description copied from class: Container
      Computes the bitwise AND of this container with another (intersection). This container as well as the provided container are left unaffected.
      Specified by:
      and in class Container
      Parameters:
      x - Another container
      Returns:
      aggregated container
    • andRange

      public Container andRange(int start, int end)
      Description copied from class: Container
      Calculate the intersection of this container and a range, in a new container. The existing container is not modified.
      Specified by:
      andRange in class Container
      Parameters:
      start - start of range
      end - end of range, exclusive.
      Returns:
      a new Container containing the intersction of this container and the given range.
    • andNot

      public Container andNot(ArrayContainer x)
      Description copied from class: Container
      Computes the bitwise ANDNOT of this container with another (difference). This container as well as the provided container are left unaffected.
      Specified by:
      andNot in class Container
      Parameters:
      x - Another container
      Returns:
      aggregated container
    • andNot

      public Container andNot(BitmapContainer x)
      Description copied from class: Container
      Computes the bitwise ANDNOT of this container with another (difference). This container as well as the provided container are left unaffected.
      Specified by:
      andNot in class Container
      Parameters:
      x - Another container
      Returns:
      aggregated container
    • andNot

      public Container andNot(RunContainer x)
      Description copied from class: Container
      Computes the bitwise ANDNOT of this container with another (difference). This container as well as the provided container are left unaffected.
      Specified by:
      andNot in class Container
      Parameters:
      x - Another container
      Returns:
      aggregated container
    • isEmpty

      public boolean isEmpty()
      Description copied from class: Container
      Checks whether the container is empty or not.
      Specified by:
      isEmpty in class Container
      Returns:
      true if the container is empty.
    • isAllOnes

      public boolean isAllOnes()
      Description copied from class: Container
      Checks whether the container spans the full 2^16 range (ie, contains every short value) This is an O(1) operation in all container types (some do not cache cardinality).
      Specified by:
      isAllOnes in class Container
      Returns:
      true if the container does not miss any single short value.
    • contains

      public boolean contains(short x)
      Description copied from class: Container
      Checks whether the contain contains the provided value
      Specified by:
      contains in class Container
      Parameters:
      x - value to check
      Returns:
      whether the value is in the container
    • contains

      public boolean contains(int rangeStart, int rangeEnd)
      Description copied from class: Container
      Checks whether the container contains the entire range
      Specified by:
      contains in class Container
      Parameters:
      rangeStart - the inclusive lower bound of the range
      rangeEnd - the exclusive upper bound of the range
      Returns:
      true if the container contains the range
    • contains

      protected boolean contains(RunContainer runContainer)
      Specified by:
      contains in class Container
    • contains

      protected boolean contains(ArrayContainer arrayContainer)
      Specified by:
      contains in class Container
    • contains

      protected boolean contains(BitmapContainer bitmapContainer)
      Specified by:
      contains in class Container
    • iflip

      public Container iflip(short x)
      Description copied from class: Container
      Add a short to the container if it is not present, otherwise remove it. May generate a new container.
      Specified by:
      iflip in class Container
      Parameters:
      x - short to be added
      Returns:
      the new container
    • getCardinality

      public int getCardinality()
      Description copied from class: Container
      Computes the distinct number of short values in the container. Can be expected to run in constant time.
      Specified by:
      getCardinality in class Container
      Returns:
      the cardinality
    • forEach

      public boolean forEach(ShortConsumer sc)
      Description copied from class: Container
      Iterate through the values of this container in order and pass them along to the ShortConsumer.
      Specified by:
      forEach in class Container
      Parameters:
      sc - a shortConsumer
      Returns:
      false if the consumer returned false at some point, true otherwise.
    • forEach

      public boolean forEach(int rankOffset, ShortConsumer sc)
      Description copied from class: Container
      Like forEach, but skipping the first rankOffset elements.
      Specified by:
      forEach in class Container
      Parameters:
      rankOffset - the position (rank) offset of the element where to start
      sc - a ShortConsumer
      Returns:
      false if the consumer returned false at some point, true otherwise.
    • forEachRange

      public boolean forEachRange(int rankOffset, ShortRangeConsumer sc)
      Specified by:
      forEachRange in class Container
    • getReverseShortIterator

      public ShortAdvanceIterator getReverseShortIterator()
      Description copied from class: Container
      Iterator to visit the short values in the container in descending order.
      Specified by:
      getReverseShortIterator in class Container
      Returns:
      iterator
    • getShortIterator

      public ShortIterator getShortIterator()
      Description copied from class: Container
      Iterator to visit the short values in the container in ascending order.
      Specified by:
      getShortIterator in class Container
      Returns:
      iterator
    • getShortBatchIterator

      public ContainerShortBatchIterator getShortBatchIterator(int skipFromStartCount)
      Description copied from class: Container
      Gets an iterator to visit the contents of the container in batches of short values
      Specified by:
      getShortBatchIterator in class Container
      Parameters:
      skipFromStartCount - number of elements to skip from the start of the container.
      Returns:
      iterator
    • getShortRangeIterator

      public SearchRangeIterator getShortRangeIterator(int skipFromStartCount)
      Description copied from class: Container
      Iterator to visit the short values in container in [start, end) ranges, in increasing order of start values.
      Specified by:
      getShortRangeIterator in class Container
      Returns:
      iterator
    • not

      public Container not(int rangeStart, int rangeEnd)
      Description copied from class: Container
      Computes the bitwise NOT of this container (complement). Only those bits within the range are affected. This is equivalent to an xor with a range of ones for the given range. The current container is left unaffected.
      Specified by:
      not in class Container
      Parameters:
      rangeStart - beginning of range (inclusive); 0 is beginning of this container.
      rangeEnd - ending of range (exclusive)
      Returns:
      (partially) complemented container
    • or

      public Container or(ArrayContainer x)
      Description copied from class: Container
      Computes the bitwise OR of this container with another (union). This container as well as the provided container are left unaffected.
      Specified by:
      or in class Container
      Parameters:
      x - Another container
      Returns:
      aggregated container
    • or

      public Container or(BitmapContainer x)
      Description copied from class: Container
      Computes the bitwise OR of this container with another (union). This container as well as the provided container are left unaffected.
      Specified by:
      or in class Container
      Parameters:
      x - Another container
      Returns:
      aggregated container
    • or

      public Container or(RunContainer x)
      Description copied from class: Container
      Computes the bitwise OR of this container with another (union). This container as well as the provided container are left unaffected.
      Specified by:
      or in class Container
      Parameters:
      x - Another container
      Returns:
      aggregated container
    • rank

      public int rank(short lowbits)
      Description copied from class: Container
      Rank returns the number of integers that are smaller or equal to x (Rank(infinity) would be GetCardinality()).
      Specified by:
      rank in class Container
      Parameters:
      lowbits - upper limit
      Returns:
      the rank
    • remove

      public Container remove(int begin, int end)
      Description copied from class: Container
      Return a new container with all shorts in [begin,end) remove using an unsigned interpretation.
      Specified by:
      remove in class Container
      Parameters:
      begin - start of range (inclusive)
      end - end of range (exclusive)
      Returns:
      the new container
    • unset

      public Container unset(short x)
      Description copied from class: Container
      Remove the short from this container. May create a new container.
      Specified by:
      unset in class Container
      Parameters:
      x - to be removed
      Returns:
      resulting container.
    • unset

      public Container unset(short x, PositionHint positionHint)
    • runOptimize

      public Container runOptimize()
      Description copied from class: Container
      Convert to RunContainers, when the result is smaller. Overridden by RunContainer to possibility switch from RunContainer to a smaller alternative. Overridden by BitmapContainer with a more efficient approach.
      Specified by:
      runOptimize in class Container
      Returns:
      the new container
    • select

      public short select(int j)
      Description copied from class: Container
      Return the jth value
      Specified by:
      select in class Container
      Parameters:
      j - index of the value
      Returns:
      the value
    • select

      public Container select(int startRank, int endRank)
      Description copied from class: Container
      Returns a new container with all values between ranks startPos and endPos.
      Specified by:
      select in class Container
      Parameters:
      startRank - rank for the start of the range
      endRank - rank for the end of the range, exclusive
      Returns:
      a new Container with all the values between ranks [startPos, endPos)
    • find

      public int find(short x)
      Description copied from class: Container
      Searches for the specified short value
      Specified by:
      find in class Container
      Parameters:
      x - value to search for
      Returns:
      Relative position of the value in the sorted set of elements in this container, in the range [0 .. cardinality - 1]. If not present, (-(insertion point) - 1) similar to Array.binarySearch.

      For values of x that Container.contains(short) returns true, this method returns the same value as Container.rank(short).

    • selectRanges

      public void selectRanges(RangeConsumer outValues, RangeIterator inPositions)
      Description copied from class: Container
      As select but for all the positions in a range.
      Specified by:
      selectRanges in class Container
      Parameters:
      outValues - accept is called in this consumer for each resulting range.
      inPositions - input iterator that provides the position ranges.
    • findRanges

      public boolean findRanges(RangeConsumer outPositions, RangeIterator inValues, int maxPos)
      Description copied from class: Container
      As find but for all the values in a range.
      Specified by:
      findRanges in class Container
      Parameters:
      outPositions - accept is called in this consumer for each resulting position range.
      inValues - input iterator that provides the key ranges; these must each exist in the container.
      maxPos - maximum position to add to outPositions; values of position > maxPos are not added.
      Returns:
      true if maxPos was reached, false otherwise.
    • trim

      public void trim()
      Description copied from class: Container
      If possible, recover wasted memory.
      Specified by:
      trim in class Container
    • xor

      public Container xor(ArrayContainer x)
      Description copied from class: Container
      Computes the bitwise XOR of this container with another (symmetric difference). This container as well as the provided container are left unaffected.
      Specified by:
      xor in class Container
      Parameters:
      x - Another container
      Returns:
      aggregated container
    • xor

      public Container xor(BitmapContainer x)
      Description copied from class: Container
      Computes the bitwise XOR of this container with another (symmetric difference). This container as well as the provided container are left unaffected.
      Specified by:
      xor in class Container
      Parameters:
      x - Another container
      Returns:
      aggregated container
    • xor

      public Container xor(RunContainer x)
      Description copied from class: Container
      Computes the bitwise XOR of this container with another (symmetric difference). This container as well as the provided container are left unaffected.
      Specified by:
      xor in class Container
      Parameters:
      x - Another container
      Returns:
      aggregated container
    • toBitmapContainer

      public BitmapContainer toBitmapContainer()
      Description copied from class: Container
      Convert the current container to a BitmapContainer, if a conversion is needed. If the container is already a bitmap, the container is returned unchanged.

      When multiple container "merge" operations are done it might be more efficient to convert to bitmap first, and then at the end convert to the efficient container type, to avoid multiple container type conversions, since bitmap can always stay a bitmap.

      Specified by:
      toBitmapContainer in class Container
      Returns:
      a bitmap container
    • nextValue

      public int nextValue(short fromValue)
      Description copied from class: Container
      Gets the first value greater than or equal to the lower bound, or -1 if no such value exists.
      Specified by:
      nextValue in class Container
      Parameters:
      fromValue - the lower bound (inclusive)
      Returns:
      the next value
    • first

      public int first()
      Description copied from class: Container
      Get the first integer held in the container
      Specified by:
      first in class Container
      Returns:
      the first integer in the container
    • last

      public int last()
      Description copied from class: Container
      Get the last integer held in the container
      Specified by:
      last in class Container
      Returns:
      the last integer in the container
    • subsetOf

      public boolean subsetOf(ArrayContainer x)
      Specified by:
      subsetOf in class Container
      Parameters:
      x - Another container
      Returns:
      true if every key in this container is also a key in x.
    • subsetOf

      public boolean subsetOf(BitmapContainer x)
      Specified by:
      subsetOf in class Container
      Parameters:
      x - Another container
      Returns:
      true if every key in this container is also a key in x.
    • subsetOf

      public boolean subsetOf(RunContainer x)
      Specified by:
      subsetOf in class Container
      Parameters:
      x - Another container
      Returns:
      true if every key in this container is also a key in x.
    • overlaps

      public boolean overlaps(ArrayContainer x)
      Specified by:
      overlaps in class Container
      Parameters:
      x - Another container
      Returns:
      true if at least one key in this container is also a key in x.
    • overlaps

      public boolean overlaps(BitmapContainer x)
      Specified by:
      overlaps in class Container
      Parameters:
      x - Another container
      Returns:
      true if at least one key in this container is also a key in x.
    • overlaps

      public boolean overlaps(RunContainer x)
      Specified by:
      overlaps in class Container
      Parameters:
      x - Another container
      Returns:
      true if at least one key in this container is also a key in x.
    • overlapsRange

      public boolean overlapsRange(int start, int end)
      Specified by:
      overlapsRange in class Container
      Parameters:
      start - the beginning of the range, as an int.
      end - the end of the range (exclusive), as an int.
      Returns:
      true if there is any element in this container in the range provided.
    • setCopyOnWrite

      public void setCopyOnWrite()
      Specified by:
      setCopyOnWrite in class Container
    • bytesAllocated

      public int bytesAllocated()
      Specified by:
      bytesAllocated in class Container
      Returns:
      The allocated size in bytes of the underlying array backing store used by this container.
    • bytesUsed

      public int bytesUsed()
      Specified by:
      bytesUsed in class Container
      Returns:
      The size in bytes of the used portion out of the total allocated bytes for the underlying array backing store used by this container.
    • toString

      public String toString()
      Overrides:
      toString in class Container
    • toLargeContainer

      public Container toLargeContainer()
    • validate

      public void validate()
      Specified by:
      validate in class Container