java.lang.Object
com.biglybt.core.peermanager.piecepicker.util.BitFlags
All Implemented Interfaces:
Cloneable

public class BitFlags extends Object implements Cloneable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
    Index of last set bit
    final boolean[]
    The array of bit flags
    int
    how many bits are set
    int
    Index of first set bit
  • Constructor Summary

    Constructors
    Constructor
    Description
    BitFlags(boolean[] _flags)
     
    BitFlags(int count)
     
    clone constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    and(BitFlags other)
    Experimental.
    void
     
     
    boolean
     
    int
     
    void
    set(int i)
    for setting a flag that is not known to be the first or last, or not
    void
     
    void
    setEnd(int i)
    this is for setting a flag that is already known to be the last true flag
    void
    setOnly(int i)
    clears the array then sets the given flag
    void
    setStart(int i)
    for setting a flag that is already known to be the first true flag
    int
    You can read flags.length instead (but please don't modify it)
    void
    unset(int i)
    for setting a flag that is not known to be the first or last, or not

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • start

      public int start
      Index of first set bit
    • end

      public int end
      Index of last set bit
    • nbSet

      public int nbSet
      how many bits are set
    • flags

      public final boolean[] flags
      The array of bit flags
  • Constructor Details

    • BitFlags

      public BitFlags(int count)
    • BitFlags

      public BitFlags(boolean[] _flags)
    • BitFlags

      public BitFlags(BitFlags other)
      clone constructor
  • Method Details

    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • size

      public int size()
      You can read flags.length instead (but please don't modify it)
      Returns:
      the number of elements in this array
    • clear

      public void clear()
    • setStart

      public void setStart(int i)
      for setting a flag that is already known to be the first true flag
    • set

      public void set(int i)
      for setting a flag that is not known to be the first or last, or not
    • unset

      public void unset(int i)
      for setting a flag that is not known to be the first or last, or not
    • setEnd

      public void setEnd(int i)
      this is for setting a flag that is already known to be the last true flag
    • setOnly

      public void setOnly(int i)
      clears the array then sets the given flag
    • setAll

      public void setAll()
    • and

      public BitFlags and(BitFlags other)
      Experimental. Returns a new BitFlags with flags set as the logical AND of both BitFlags. The length of both must be the same.
      Parameters:
      other - BitFlags to be ANDed with this BitFlags. Must not be null.
      Returns:
      new BitFlags representing the logical AND of the two