Class SparseBitSet.AbstractStrategy

java.lang.Object
com.zaxxer.sparsebits.SparseBitSet.AbstractStrategy
Direct Known Subclasses:
SparseBitSet.AndNotStrategy, SparseBitSet.AndStrategy, SparseBitSet.ClearStrategy, SparseBitSet.CopyStrategy, SparseBitSet.EqualsStrategy, SparseBitSet.FlipStrategy, SparseBitSet.IntersectsStrategy, SparseBitSet.OrStrategy, SparseBitSet.SetStrategy, SparseBitSet.UpdateStrategy, SparseBitSet.XorStrategy
Enclosing class:
SparseBitSet

protected abstract static class SparseBitSet.AbstractStrategy extends Object
This strategy class is used by the setScanner to carry out the a variety of operations on this set, and usually a second set. The setScanner() method of the main SparseBitSet class essentially finds matching level3 blocks, and then calls the strategy to do the appropriate operation on each of the elements of the block.

The symbolic constants control optimisation paths in the setScanner() method of the main SparseBitSet class.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final int
    If the operation requires that when matching level2 areas or level3 blocks are null, that no action is required, then this property is required.
    (package private) static final int
    If when level2 areas or level3 areas from the this set are null will require that area or block to remain null, irrespective of the value of the matching structure from the other set, then this property is required.
    (package private) static final int
    If when level2 areas or level3 areas from the other set are null will require the matching area or block in this set to be set to null, irrespective of the current values in the matching structure from the this, then this property is required.
    (package private) static final int
    If when a level3 area from the other set is null will require the matching area or block in this set to be left as it is, then this property is required.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract boolean
    block(int base, int u3, int v3, long[] a3, long[] b3)
    Deals with a part of a block that consists of whole words, starting with the given first index, and ending with the word before the last index.
    protected void
    finish(int a2Count, int a3Count)
    This is called to finish the processing started by the strategy (if there needs to be anything done at all).
    protected final boolean
    isZeroBlock(long[] a3)
    Check whether a level3 block is all zero.
    protected abstract int
    Properties of this strategy.
    protected abstract boolean
    Instances of this class are to be serially reusable.
    protected abstract boolean
    word(int base, int u3, long[] a3, long[] b3, long mask)
    Deal with a scan that include a partial word within a level3 block.

    Methods inherited from class java.lang.Object

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

    • F_OP_F_EQ_F

      static final int F_OP_F_EQ_F
      If the operation requires that when matching level2 areas or level3 blocks are null, that no action is required, then this property is required. Corresponds to the top-left entry in the logic diagram for the operation being 0. For all the defined actual logic operations ('and', 'andNot', 'or', and 'xor', this will be true, because for all these, "false" op "false" = "false".
      See Also:
    • F_OP_X_EQ_F

      static final int F_OP_X_EQ_F
      If when level2 areas or level3 areas from the this set are null will require that area or block to remain null, irrespective of the value of the matching structure from the other set, then this property is required. Corresponds to the first row in the logic diagram being all zeros. For example, this is true for 'and' as well as 'andNot', and for 'clear', since false" invalid input: '&' "x" = "false", and "false" invalid input: '&'! "x" = "false".
      See Also:
    • X_OP_F_EQ_F

      static final int X_OP_F_EQ_F
      If when level2 areas or level3 areas from the other set are null will require the matching area or block in this set to be set to null, irrespective of the current values in the matching structure from the this, then this property is required. Corresponds to the first column in the logic diagram being all zero. For example, this is true for 'and', since "x" invalid input: '&' "false" = "false", as well as for 'clear'.
      See Also:
    • X_OP_F_EQ_X

      static final int X_OP_F_EQ_X
      If when a level3 area from the other set is null will require the matching area or block in this set to be left as it is, then this property is required. Corresponds to the first column of the logic diagram being equal to the left hand operand column. For example, this is true for 'or', 'xor', and 'andNot', since for all of these "x" op "false" = "x".
      See Also:
  • Constructor Details

    • AbstractStrategy

      protected AbstractStrategy()
  • Method Details

    • properties

      protected abstract int properties()
      Properties of this strategy.
      Returns:
      the int containing the bits representing the properties of this strategy
      Since:
      1.6
    • start

      protected abstract boolean start(SparseBitSet b)
      Instances of this class are to be serially reusable. To start a particular use, an instance is (re-)started by calling this method. It is passed the reference to the other bit set (usually to allow a check on whether it is null or not, so as to simplify the implementation of the block() method.
      Parameters:
      b - the "other" set, for whatever checking is needed.
      Returns:
      true -> if the cache should be set to zero
      Since:
      1.6
    • word

      protected abstract boolean word(int base, int u3, long[] a3, long[] b3, long mask)
      Deal with a scan that include a partial word within a level3 block. All that is required is that the result be stored (if needed) into the given a set block at the correct position, and that the operation only affect those bits selected by 1 bits in the mask.
      Parameters:
      base - the base index of the block (to be used if needed)
      u3 - the index of the word within block
      a3 - the level3 block from the a set.
      b3 - the (nominal) level3 block from the b set (not null).
      mask - for the (partial) word
      Returns:
      true if the resulting word is zero
      Since:
      1.6
    • block

      protected abstract boolean block(int base, int u3, int v3, long[] a3, long[] b3)
      Deals with a part of a block that consists of whole words, starting with the given first index, and ending with the word before the last index. For the words processed, the return value should indicate whether all those resulting words were zero, or not.
      Parameters:
      base - the base index of the block (to be used if needed)
      u3 - the index of the first word within block to process
      v3 - the index of the last word, which may be within block
      a3 - the level3 block from the a set.
      b3 - the (nominal) level3 block from the b set (not null).
      Returns:
      true if the words scanned within the level3 block were all zero
      Since:
      1.6
    • finish

      protected void finish(int a2Count, int a3Count)
      This is called to finish the processing started by the strategy (if there needs to be anything done at all).
      Parameters:
      a2Count - possible count of level2 areas in use
      a3Count - possible count of level3 blocks in use
      Since:
      1.6
    • isZeroBlock

      protected final boolean isZeroBlock(long[] a3)
      Check whether a level3 block is all zero.
      Parameters:
      a3 - the block from the a set
      Returns:
      true if the values of the level3 block are all zero
      Since:
      1.6