Class BitSetBooleanData

  • All Implemented Interfaces:
    it.unimi.dsi.fastutil.bytes.ByteIterable, Iterable<Byte>, BooleanData

    public class BitSetBooleanData
    extends Object
    implements BooleanData
    An implementation of BooleanData where the underlying representation uses the Java BitSet class
    • Constructor Summary

      Constructors 
      Constructor Description
      BitSetBooleanData()  
      BitSetBooleanData​(it.unimi.dsi.fastutil.bytes.ByteArrayList values)
      Constructs a BitSetBoolean data from the given ByteArrayList
      BitSetBooleanData​(BitSet trueValues, BitSet falseValues, BitSet missingValues)
      Constructs a BitSetBoolean data from three BitSets, one for each possible value
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(byte b)
      Adds a boolean value represented as a byte, where 0=false, 1=true, and -1=missing
      Selection asSelection()
      Returns a selection matching all the true values in the data
      void clear()
      Removes all data values
      boolean contains​(byte b)
      Returns true if the value at b is true.
      BooleanData copy()
      Returns a copy of this BooleanData object
      int countFalse()
      Returns the number of false values in the data *
      int countMissing()
      Returns the number of missing values in the data *
      int countTrue()
      Returns the number of true values in the data *
      int countUnique()
      Returns the number of unique values in the data.
      byte[] falseBytes()
      Returns a byte representation of the true values, encoded in the format specified in BitSet.toByteArray()
      byte getByte​(int i)
      Returns the value at i as a byte, where -1 represents missing values
      boolean isEmpty()
      Returns true if the data is empty, and false otherwise.
      Selection isFalse()
      Returns a selection matching all the false values in the data
      Selection isMissing()
      Returns a selection matching all the missing values in the data
      Selection isTrue()
      Returns a selection matching all the true values in the data
      it.unimi.dsi.fastutil.bytes.ByteIterator iterator()
      byte[] missingBytes()
      Returns a byte representation of the missing values, encoded in the format specified in BitSet.toByteArray()
      void set​(int i, byte b)
      Sets the value at position i to byte b
      void setFalseBytes​(byte[] bytes)
      Sets the false values in the data from a byte[] encoding
      void setMissingBytes​(byte[] bytes)
      Sets the missing values in the data from a byte[] encoding
      void setTrueBytes​(byte[] bytes)
      Sets the true values in the data from a byte[] encoding
      int size()
      Returns the number of values in the data, including missing values
      void sortAscending()
      Sorts the data in-place in ascending order, with missing values first
      void sortDescending()
      Sorts the data in-place in descending order, with missing values last
      byte[] toByteArray()
      Returns the data as a byte[] containing 0 and 1, with any missing values encoded as -128
      it.unimi.dsi.fastutil.bytes.ByteArrayList toByteArrayList()
      Returns the data as a ByteArrayList containing 0 and 1, with any missing values encoded as -128
      String toString()  
      byte[] trueBytes()
      Returns a byte representation of the false values, encoded in the format specified in BitSet.toByteArray()
      • Methods inherited from interface it.unimi.dsi.fastutil.bytes.ByteIterable

        forEach, forEach, forEach, intIterator, intSpliterator, spliterator
    • Constructor Detail

      • BitSetBooleanData

        public BitSetBooleanData​(BitSet trueValues,
                                 BitSet falseValues,
                                 BitSet missingValues)
        Constructs a BitSetBoolean data from three BitSets, one for each possible value
      • BitSetBooleanData

        public BitSetBooleanData​(it.unimi.dsi.fastutil.bytes.ByteArrayList values)
        Constructs a BitSetBoolean data from the given ByteArrayList
        Parameters:
        values - The values must be encoded as 0, 1, or -128 (for missing)
      • BitSetBooleanData

        public BitSetBooleanData()
    • Method Detail

      • size

        public int size()
        Returns the number of values in the data, including missing values
        Specified by:
        size in interface BooleanData
      • add

        public void add​(byte b)
        Adds a boolean value represented as a byte, where 0=false, 1=true, and -1=missing
        Specified by:
        add in interface BooleanData
      • clear

        public void clear()
        Removes all data values
        Specified by:
        clear in interface BooleanData
      • sortAscending

        public void sortAscending()
        Sorts the data in-place in ascending order, with missing values first
        Specified by:
        sortAscending in interface BooleanData
      • sortDescending

        public void sortDescending()
        Sorts the data in-place in descending order, with missing values last
        Specified by:
        sortDescending in interface BooleanData
      • getByte

        public byte getByte​(int i)
        Returns the value at i as a byte, where -1 represents missing values
        Specified by:
        getByte in interface BooleanData
      • countFalse

        public int countFalse()
        Returns the number of false values in the data *
        Specified by:
        countFalse in interface BooleanData
      • countTrue

        public int countTrue()
        Returns the number of true values in the data *
        Specified by:
        countTrue in interface BooleanData
      • countMissing

        public int countMissing()
        Returns the number of missing values in the data *
        Specified by:
        countMissing in interface BooleanData
      • countUnique

        public int countUnique()
        Returns the number of unique values in the data. There can only be 3 (true, false, and missing) *
        Specified by:
        countUnique in interface BooleanData
      • toByteArray

        public byte[] toByteArray()
        Returns the data as a byte[] containing 0 and 1, with any missing values encoded as -128
        Specified by:
        toByteArray in interface BooleanData
      • toByteArrayList

        public it.unimi.dsi.fastutil.bytes.ByteArrayList toByteArrayList()
        Description copied from interface: BooleanData
        Returns the data as a ByteArrayList containing 0 and 1, with any missing values encoded as -128
        Specified by:
        toByteArrayList in interface BooleanData
      • set

        public void set​(int i,
                        byte b)
        Sets the value at position i to byte b
        Specified by:
        set in interface BooleanData
        Parameters:
        i - the 0-based index of the element in the data
        b - the value to set, should be 0, 1, or -128 only
      • isEmpty

        public boolean isEmpty()
        Returns true if the data is empty, and false otherwise. Empty here means only missing values
        Specified by:
        isEmpty in interface BooleanData
      • contains

        public boolean contains​(byte b)
        Returns true if the value at b is true.
        Specified by:
        contains in interface BooleanData
      • asSelection

        public Selection asSelection()
        Returns a selection matching all the true values in the data
        Specified by:
        asSelection in interface BooleanData
      • isFalse

        public Selection isFalse()
        Returns a selection matching all the false values in the data
        Specified by:
        isFalse in interface BooleanData
      • isTrue

        public Selection isTrue()
        Returns a selection matching all the true values in the data
        Specified by:
        isTrue in interface BooleanData
      • isMissing

        public Selection isMissing()
        Returns a selection matching all the missing values in the data
        Specified by:
        isMissing in interface BooleanData
      • setTrueBytes

        public void setTrueBytes​(byte[] bytes)
        Sets the true values in the data from a byte[] encoding
        Specified by:
        setTrueBytes in interface BooleanData
        Parameters:
        bytes - The true values encoded in the format specified in BitSet
      • setFalseBytes

        public void setFalseBytes​(byte[] bytes)
        Sets the false values in the data from a byte[] encoding
        Specified by:
        setFalseBytes in interface BooleanData
        Parameters:
        bytes - The false values encoded in the format specified in BitSet
      • setMissingBytes

        public void setMissingBytes​(byte[] bytes)
        Sets the missing values in the data from a byte[] encoding
        Specified by:
        setMissingBytes in interface BooleanData
        Parameters:
        bytes - The missing values encoded in the format specified in BitSet
      • iterator

        public it.unimi.dsi.fastutil.bytes.ByteIterator iterator()
        Specified by:
        iterator in interface it.unimi.dsi.fastutil.bytes.ByteIterable
        Specified by:
        iterator in interface Iterable<Byte>