Package tech.tablesaw.columns.booleans
Class BitSetBooleanData
- java.lang.Object
-
- tech.tablesaw.columns.booleans.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 ByteArrayListBitSetBooleanData(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 voidadd(byte b)Adds a boolean value represented as a byte, where 0=false, 1=true, and -1=missingSelectionasSelection()Returns a selection matching all the true values in the datavoidclear()Removes all data valuesbooleancontains(byte b)Returns true if the value at b is true.BooleanDatacopy()Returns a copy of this BooleanData objectintcountFalse()Returns the number of false values in the data *intcountMissing()Returns the number of missing values in the data *intcountTrue()Returns the number of true values in the data *intcountUnique()Returns the number of unique values in the data.byte[]falseBytes()Returns a byte representation of the true values, encoded in the format specified inBitSet.toByteArray()bytegetByte(int i)Returns the value at i as a byte, where -1 represents missing valuesbooleanisEmpty()Returns true if the data is empty, and false otherwise.SelectionisFalse()Returns a selection matching all the false values in the dataSelectionisMissing()Returns a selection matching all the missing values in the dataSelectionisTrue()Returns a selection matching all the true values in the datait.unimi.dsi.fastutil.bytes.ByteIteratoriterator()byte[]missingBytes()Returns a byte representation of the missing values, encoded in the format specified inBitSet.toByteArray()voidset(int i, byte b)Sets the value at position i to byte bvoidsetFalseBytes(byte[] bytes)Sets the false values in the data from a byte[] encodingvoidsetMissingBytes(byte[] bytes)Sets the missing values in the data from a byte[] encodingvoidsetTrueBytes(byte[] bytes)Sets the true values in the data from a byte[] encodingintsize()Returns the number of values in the data, including missing valuesvoidsortAscending()Sorts the data in-place in ascending order, with missing values firstvoidsortDescending()Sorts the data in-place in descending order, with missing values lastbyte[]toByteArray()Returns the data as a byte[] containing 0 and 1, with any missing values encoded as -128it.unimi.dsi.fastutil.bytes.ByteArrayListtoByteArrayList()Returns the data as a ByteArrayList containing 0 and 1, with any missing values encoded as -128StringtoString()byte[]trueBytes()Returns a byte representation of the false values, encoded in the format specified inBitSet.toByteArray()
-
-
-
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:
sizein interfaceBooleanData
-
add
public void add(byte b)
Adds a boolean value represented as a byte, where 0=false, 1=true, and -1=missing- Specified by:
addin interfaceBooleanData
-
clear
public void clear()
Removes all data values- Specified by:
clearin interfaceBooleanData
-
sortAscending
public void sortAscending()
Sorts the data in-place in ascending order, with missing values first- Specified by:
sortAscendingin interfaceBooleanData
-
sortDescending
public void sortDescending()
Sorts the data in-place in descending order, with missing values last- Specified by:
sortDescendingin interfaceBooleanData
-
copy
public BooleanData copy()
Returns a copy of this BooleanData object- Specified by:
copyin interfaceBooleanData
-
getByte
public byte getByte(int i)
Returns the value at i as a byte, where -1 represents missing values- Specified by:
getBytein interfaceBooleanData
-
countFalse
public int countFalse()
Returns the number of false values in the data *- Specified by:
countFalsein interfaceBooleanData
-
countTrue
public int countTrue()
Returns the number of true values in the data *- Specified by:
countTruein interfaceBooleanData
-
countMissing
public int countMissing()
Returns the number of missing values in the data *- Specified by:
countMissingin interfaceBooleanData
-
countUnique
public int countUnique()
Returns the number of unique values in the data. There can only be 3 (true, false, and missing) *- Specified by:
countUniquein interfaceBooleanData
-
toByteArray
public byte[] toByteArray()
Returns the data as a byte[] containing 0 and 1, with any missing values encoded as -128- Specified by:
toByteArrayin interfaceBooleanData
-
toByteArrayList
public it.unimi.dsi.fastutil.bytes.ByteArrayList toByteArrayList()
Description copied from interface:BooleanDataReturns the data as a ByteArrayList containing 0 and 1, with any missing values encoded as -128- Specified by:
toByteArrayListin interfaceBooleanData
-
set
public void set(int i, byte b)Sets the value at position i to byte b- Specified by:
setin interfaceBooleanData- Parameters:
i- the 0-based index of the element in the datab- 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:
isEmptyin interfaceBooleanData
-
contains
public boolean contains(byte b)
Returns true if the value at b is true.- Specified by:
containsin interfaceBooleanData
-
asSelection
public Selection asSelection()
Returns a selection matching all the true values in the data- Specified by:
asSelectionin interfaceBooleanData
-
isFalse
public Selection isFalse()
Returns a selection matching all the false values in the data- Specified by:
isFalsein interfaceBooleanData
-
isTrue
public Selection isTrue()
Returns a selection matching all the true values in the data- Specified by:
isTruein interfaceBooleanData
-
isMissing
public Selection isMissing()
Returns a selection matching all the missing values in the data- Specified by:
isMissingin interfaceBooleanData
-
falseBytes
public byte[] falseBytes()
Returns a byte representation of the true values, encoded in the format specified inBitSet.toByteArray()- Specified by:
falseBytesin interfaceBooleanData
-
trueBytes
public byte[] trueBytes()
Returns a byte representation of the false values, encoded in the format specified inBitSet.toByteArray()- Specified by:
trueBytesin interfaceBooleanData
-
missingBytes
public byte[] missingBytes()
Returns a byte representation of the missing values, encoded in the format specified inBitSet.toByteArray()- Specified by:
missingBytesin interfaceBooleanData
-
setTrueBytes
public void setTrueBytes(byte[] bytes)
Sets the true values in the data from a byte[] encoding- Specified by:
setTrueBytesin interfaceBooleanData- Parameters:
bytes- The true values encoded in the format specified inBitSet
-
setFalseBytes
public void setFalseBytes(byte[] bytes)
Sets the false values in the data from a byte[] encoding- Specified by:
setFalseBytesin interfaceBooleanData- Parameters:
bytes- The false values encoded in the format specified inBitSet
-
setMissingBytes
public void setMissingBytes(byte[] bytes)
Sets the missing values in the data from a byte[] encoding- Specified by:
setMissingBytesin interfaceBooleanData- Parameters:
bytes- The missing values encoded in the format specified inBitSet
-
-