Class BooleanColumn

    • Method Detail

      • valueIsMissing

        public static boolean valueIsMissing​(byte b)
        Returns true if b is the missing value indicator for this column type
      • isMissing

        public boolean isMissing​(int rowNumber)
        Returns true if the value at rowNumber is missing
        Specified by:
        isMissing in interface Column<Boolean>
      • setMissing

        public BooleanColumn setMissing​(int i)
        Sets the value at index i to the missing-value indicator for this column type, and return this column
        Specified by:
        setMissing in interface Column<Boolean>
      • create

        public static BooleanColumn create​(String name,
                                           Selection hits,
                                           int columnSize)
        Returns a new Boolean column of the given size. Elements indexed by the selection are set to true
        Parameters:
        name - The column name
        hits - The true values
        columnSize - The column size
        Returns:
        A new BooleanColumn
      • create

        public static BooleanColumn create​(String name)
        Returns a new, empty Boolean column with the given name.
        Parameters:
        name - The column name
        Returns:
        A new BooleanColumn
      • create

        public static BooleanColumn create​(String name,
                                           int initialSize)
        Returns a new Boolean column of the given size.
        Parameters:
        name - The column name
        initialSize - The column size
        Returns:
        A new BooleanColumn
      • create

        public static BooleanColumn create​(String name,
                                           boolean... values)
        Returns a new Boolean column with the given name and values
      • create

        public static BooleanColumn create​(String name,
                                           Boolean[] values)
        Returns a new Boolean column with the given name and values
      • setPrintFormatter

        public void setPrintFormatter​(BooleanFormatter formatter)
        Sets the print formatter for this column
      • getPrintFormatter

        public BooleanFormatter getPrintFormatter()
        Returns the print formatter for this column
      • size

        public int size()
        Returns the number of elements in this column, including missing values
        Specified by:
        size in interface Column<Boolean>
      • summary

        public Table summary()
        Returns a table containing a ColumnType specific summary of the data in this column
        Specified by:
        summary in interface Column<Boolean>
      • countMissing

        public int countMissing()
        Returns the count of missing values in this column
        Specified by:
        countMissing in interface Column<Boolean>
        Returns:
        missing values as int
      • countUnique

        public int countUnique()
        Returns the count of unique values in this column.
        Specified by:
        countUnique in interface Column<Boolean>
        Returns:
        unique values as int
      • append

        public BooleanColumn append​(boolean b)
        Appends b to the end of this column and returns this column
      • append

        public BooleanColumn append​(byte b)
        Appends b to the end of this column and returns this column
      • valueHash

        public int valueHash​(int rowNumber)
        Returns an int suitable as a hash for the value in this column at the given index
        Specified by:
        valueHash in interface Column<Boolean>
      • equals

        public boolean equals​(int rowNumber1,
                              int rowNumber2)
        Returns true if the value in this column at rowNumber1 is equal to the value at rowNumber2
        Specified by:
        equals in interface Column<Boolean>
      • getString

        public String getString​(int row)
        Returns a string representation of the value at the given row.
        Specified by:
        getString in interface Column<Boolean>
        Parameters:
        row - The index of the row.
        Returns:
        value as String
      • getUnformattedString

        public String getUnformattedString​(int row)
        Returns a String representation of the value at index r, without any formatting applied
        Specified by:
        getUnformattedString in interface Column<Boolean>
      • emptyCopy

        public BooleanColumn emptyCopy​(int rowSize)
        Returns an empty copy of the receiver, with its internal storage initialized to the given row size.
        Specified by:
        emptyCopy in interface Column<Boolean>
        Parameters:
        rowSize - the initial row size
        Returns:
        a Column
      • clear

        public void clear()
        Removes all elements TODO: Make this return this column
        Specified by:
        clear in interface Column<Boolean>
      • sortAscending

        public void sortAscending()
        Sorts my values in ascending order
        Specified by:
        sortAscending in interface Column<Boolean>
      • sortDescending

        public void sortDescending()
        Sorts my values in descending order
        Specified by:
        sortDescending in interface Column<Boolean>
      • appendCell

        public BooleanColumn appendCell​(String object)
        Add one element to the bottom of this column and set its value to the parsed value of the given String. Parsing is type-specific
        Specified by:
        appendCell in interface Column<Boolean>
      • get

        public Boolean get​(int i)
        Returns the value in row i as a Boolean
        Specified by:
        get in interface Column<Boolean>
        Parameters:
        i - the row number
        Returns:
        A Boolean object (may be null)
      • getByte

        public byte getByte​(int i)
        Returns the value in row i as a byte (0, 1, or Byte.MIN_VALUE representing missing data)
        Parameters:
        i - the row number
      • isEmpty

        public boolean isEmpty()
        Returns true if the column has no data
        Specified by:
        isEmpty in interface Column<Boolean>
        Returns:
        true if empty, false if not
      • countTrue

        public int countTrue()
        Returns the number of true elements in this column
      • countFalse

        public int countFalse()
        Returns the number of false elements in this column
      • proportionTrue

        public double proportionTrue()
        Returns the proportion of non-missing row elements that contain true
      • proportionFalse

        public double proportionFalse()
        Returns the proportion of non-missing row elements that contain false
      • any

        public boolean any()
        Returns true if the column contains any true values, and false otherwise
      • all

        public boolean all()
        Returns true if the column contains only true values, and false otherwise. If there are any missing values it returns false.
      • none

        public boolean none()
        Returns true if the column contains no true values, and false otherwise
      • toByteArrayList

        public it.unimi.dsi.fastutil.bytes.ByteArrayList toByteArrayList()
        Returns a ByteArrayList containing 0 (false), 1 (true) or Byte.MIN_VALUE (missing)
      • set

        public BooleanColumn set​(int i,
                                 boolean b)
        Sets the value at i to b, and returns this column
      • set

        public BooleanColumn set​(int i,
                                 byte b)
        Sets the value at i to b, and returns this column
      • lead

        public BooleanColumn lead​(int n)
        Returns a column of the same type as the receiver, containing the receivers values offset -n For example if you lead a column containing 2, 3, 4 by 1, you get a column containing 3, 4, NA.
        Specified by:
        lead in interface Column<Boolean>
      • lag

        public BooleanColumn lag​(int n)
        Returns a column of the same type and size as the receiver, containing the receivers values offset by n.

        For example if you lag a column containing 2, 3, 4 by 1, you get a column containing NA, 2, 3

        Specified by:
        lag in interface Column<Boolean>
      • set

        public BooleanColumn set​(Selection rowSelection,
                                 boolean newValue)
        Conditionally update this column, replacing current values with newValue for all rows where the current value matches the selection criteria
      • set

        public BooleanColumn set​(Selection rowSelection,
                                 byte newValue)
        Conditionally update this column, replacing current values with newValue for all rows where the current value matches the selection criteria.
        Parameters:
        rowSelection - the rows to be updated
        newValue - a byte representation of boolean values. The only valid arguments are 0, 1, and BooleanColumnType.missingValueIndicator()
      • getDouble

        public double getDouble​(int row)
        Returns the value at row as a double, with true values encoded as 1.0 and false values as 0.0
      • asDoubleArray

        public double[] asDoubleArray()
        Returns all the values in this column as an array of doubles, with true values encoded as 1.0 and false values as 0.0
      • rowComparator

        public it.unimi.dsi.fastutil.ints.IntComparator rowComparator()
        Returns an IntComparator for sorting my rows
        Specified by:
        rowComparator in interface Column<Boolean>
      • append

        public Column<Boolean> append​(Column<Boolean> column,
                                      int row)
        Appends the value at the given row in the given column to the bottom of this column and return this column
        Specified by:
        append in interface Column<Boolean>
      • set

        public Column<Boolean> set​(int row,
                                   Column<Boolean> column,
                                   int sourceRow)
        Sets the value at row to the value at sourceRow in the given column and return this column
        Specified by:
        set in interface Column<Boolean>
      • byteIterator

        public it.unimi.dsi.fastutil.bytes.ByteIterator byteIterator()
        Returns a ByteIterator for this column
      • asSet

        public it.unimi.dsi.fastutil.booleans.BooleanSet asSet()
        Returns the values in this column as a BooleanSet instance
        Specified by:
        asSet in interface Column<Boolean>
      • contains

        public boolean contains​(boolean aBoolean)
        Returns true if the column contains at least one value like aBoolean
      • byteSize

        public int byteSize()
        Returns the width of a cell in this column, in bytes.
        Specified by:
        byteSize in interface Column<Boolean>
        Returns:
        width in bytes
      • asBytes

        public byte[] asBytes​(int row)
        Returns the contents of the cell at rowNumber as a byte[].
        Specified by:
        asBytes in interface Column<Boolean>
        Parameters:
        row - index of the row
        Returns:
        content as byte[]
      • eval

        public Selection eval​(BytePredicate predicate)
        Returns a Selection of the elements that return true when the predicate is evaluated
      • eval

        public Selection eval​(Predicate<Boolean> predicate)
        Returns a Selection of the elements that return true when the predicate is evaluated
      • eval

        public Selection eval​(BiPredicate<Boolean,​Boolean> predicate,
                              Boolean valueToCompare)
        Returns a Selection of the elements that return true when the predicate is evaluated with the given Boolean argument
      • asDoubleColumn

        public DoubleColumn asDoubleColumn()
        Returns a DoubleColumn containing the elements in this column, with true as 1.0 and false as 0.0.
      • asObjectArray

        public Boolean[] asObjectArray()
        Returns an array of objects as appropriate for my type of column
        Specified by:
        asObjectArray in interface Column<Boolean>
      • trueBytes

        public byte[] trueBytes()
        Returns a byte representation of the true values, encoded in the format specified in BitSet.toByteArray()
      • falseBytes

        public byte[] falseBytes()
        Returns a byte representation of the false values, encoded in the format specified in BitSet.toByteArray()
      • missingBytes

        public byte[] missingBytes()
        Returns a byte representation of the missing values, encoded in the format specified in BitSet.toByteArray()
      • trueBytes

        public void trueBytes​(byte[] encodedValues)
        Sets the true values in the data from a byte[] encoding
        Parameters:
        encodedValues - The true values encoded in the format specified in BitSet
      • falseBytes

        public void falseBytes​(byte[] encodedValues)
        Sets the false values in the data from a byte[] encoding
        Parameters:
        encodedValues - The false values encoded in the format specified in BitSet
      • missingBytes

        public void missingBytes​(byte[] encodedValues)
        Sets the missing values in the data from a byte[] encoding
        Parameters:
        encodedValues - The missing values encoded in the format specified in BitSet