Class BitFlags

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class BitFlags
    extends java.lang.Object
    implements java.lang.Cloneable
    • Field Summary

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

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      BitFlags and​(BitFlags other)
      Experimental.
      void clear()  
      java.lang.Object clone()  
      boolean equals​(java.lang.Object o)  
      int hashCode()  
      void set​(int i)
      for setting a flag that is not known to be the first or last, or not
      void setAll()  
      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 size()
      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 Detail

      • 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 Detail

      • BitFlags

        public BitFlags​(int count)
      • BitFlags

        public BitFlags​(boolean[] _flags)
      • BitFlags

        public BitFlags​(BitFlags other)
        clone constructor
    • Method Detail

      • clone

        public java.lang.Object clone()
        Overrides:
        clone in class java.lang.Object
      • hashCode

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

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.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