Class BooleanColumn

All Implemented Interfaces:
Iterable<Boolean>, Comparator<Boolean>, CategoricalColumn<Boolean>, BooleanFillers<BooleanColumn>, BooleanFilters, BooleanMapUtils, Column<Boolean>, BooleanFilterSpec<Selection>, FilterSpec<Selection>

A column that contains boolean values
  • Field Details

    • data

      protected it.unimi.dsi.fastutil.bytes.ByteArrayList data
      The data held by this column
  • Method Details

    • 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, Collection<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
    • create

      public static BooleanColumn create(String name, Stream<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
    • unique

      public BooleanColumn unique()
      Returns a column of the same type containing only the unique values
      Specified by:
      unique in interface Column<Boolean>
      Returns:
      a Column
    • append

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

      public BooleanColumn append(Boolean b)
      Appends value to the bottom of this column and return this column
      Specified by:
      append in interface Column<Boolean>
    • appendObj

      public BooleanColumn appendObj(Object obj)
      Appends the given value to the bottom of this column and return this column
      Specified by:
      appendObj in interface Column<Boolean>
    • append

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

      public BooleanColumn appendMissing()
      Appends a missing value appropriate to the column
      Specified by:
      appendMissing in interface Column<Boolean>
    • 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()
      Returns a copy of the receiver with no data. The column name and type are the same.
      Specified by:
      emptyCopy in interface Column<Boolean>
      Specified by:
      emptyCopy in class AbstractColumn<BooleanColumn,Boolean>
      Returns:
      a empty copy of Column
    • 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>
    • copy

      public BooleanColumn copy()
      Returns a deep copy of the receiver
      Specified by:
      copy in interface Column<Boolean>
      Returns:
      a Column
    • 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>
    • appendCell

      public BooleanColumn appendCell(String object, AbstractColumnParser<?> parser)
      Add one element to the bottom of this column and set its value to the parsed value of the given String, as performed by the given parser
      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
    • isFalse

      public Selection isFalse()
      Specified by:
      isFalse in interface BooleanFilters
      Specified by:
      isFalse in interface BooleanFilterSpec<Selection>
    • isTrue

      public Selection isTrue()
      Specified by:
      isTrue in interface BooleanFilters
      Specified by:
      isTrue in interface BooleanFilterSpec<Selection>
    • isEqualTo

      public Selection isEqualTo(BooleanColumn other)
      Specified by:
      isEqualTo in interface BooleanFilters
      Specified by:
      isEqualTo in interface BooleanFilterSpec<Selection>
    • data

      public it.unimi.dsi.fastutil.bytes.ByteArrayList data()
      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, Boolean val)
      Sets the value at index row to the given value and return this column
      Specified by:
      set in interface Column<Boolean>
    • set

      public BooleanColumn set(int row, String stringValue, AbstractColumnParser<?> parser)
      Sets the value at row to the parsed value of the given String using the given parser and returns this column
      Specified by:
      set in interface Column<Boolean>
    • 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 BooleanColumn append(Column<Boolean> column)
      Appends all the values in the argument to the bottom of this column and return this column
      Specified by:
      append 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>
    • asSelection

      public Selection asSelection()
      Specified by:
      asSelection in interface BooleanMapUtils
    • isMissing

      public Selection isMissing()
      Returns a selection containing an index for every missing value in this column
      Specified by:
      isMissing in interface BooleanFilters
      Specified by:
      isMissing in interface Column<Boolean>
      Specified by:
      isMissing in interface FilterSpec<Selection>
    • isNotMissing

      public Selection isNotMissing()
      Returns a selection containing an index for every non-missing value in this column
      Specified by:
      isNotMissing in interface BooleanFilters
      Specified by:
      isNotMissing in interface Column<Boolean>
      Specified by:
      isNotMissing in interface FilterSpec<Selection>
    • iterator

      public Iterator<Boolean> iterator()
      Specified by:
      iterator in interface Iterable<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[]
    • where

      public BooleanColumn where(Selection selection)
      Returns a new column containing the subset referenced by the Selection
      Specified by:
      where in interface Column<Boolean>
    • removeMissing

      public BooleanColumn removeMissing()
      Returns a copy of this column with the missing values removed
      Specified by:
      removeMissing in interface Column<Boolean>
    • 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.
    • compare

      public int compare(Boolean o1, Boolean o2)
      Specified by:
      compare in interface Comparator<Boolean>
    • fillWith

      public BooleanColumn fillWith(it.unimi.dsi.fastutil.booleans.BooleanIterator iterator)
      Specified by:
      fillWith in interface BooleanFillers<BooleanColumn>
    • fillWith

      public BooleanColumn fillWith(it.unimi.dsi.fastutil.booleans.BooleanIterable iterable)
      Specified by:
      fillWith in interface BooleanFillers<BooleanColumn>
    • fillWith

      public BooleanColumn fillWith(Supplier<Boolean> supplier)
      Specified by:
      fillWith in interface BooleanFillers<BooleanColumn>
    • asObjectArray

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