Package tech.tablesaw.selection
Class BitmapBackedSelection
java.lang.Object
tech.tablesaw.selection.BitmapBackedSelection
A Selection implemented using bitmaps
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty SelectionBitmapBackedSelection
(int size) Returns a selection initialized from 0 to the given size, which cane be used for queries that exclude certain items, by first selecting the items to exclude, then flipping the bits.BitmapBackedSelection
(int[] arr) Constructs a selection containing the elements in the given arrayBitmapBackedSelection
(org.roaringbitmap.RoaringBitmap bitmap) Constructs a selection containing the elements in the given bitmap -
Method Summary
Modifier and TypeMethodDescriptionadd
(int... ints) Adds the given integers to the Selection if it is not already present, and does nothing otherwiseaddRange
(int start, int end) Adds to the current bitmap all integers in [rangeStart,rangeEnd)Intersects the receiver andotherSelection
, updating the receiverImplements the set difference operation between the receiver andotherSelection
, after updating the receiverclear()
Returns this selection with all its values clearedboolean
contains
(int i) Returns true if the index i is selected in this objectboolean
flip
(int rangeStart, int rangeEnd) Returns a selection with the bits from this selection flipped over the given rangeint
get
(int i) Returns the value of the ith element.int
hashCode()
boolean
isEmpty()
Returns true if this selection has no values, and false otherwiseit.unimi.dsi.fastutil.ints.IntIterator
iterator()
Returns a fastUtil intIterator that wraps a bitmap intIteratorImplements the union of the receiver andotherSelection
, updating the receiverremoveRange
(long start, long end) Removes from the current bitmap from all integers in [rangeStart,rangeEnd)protected static Selection
selectNRowsAtRandom
(int n, int max) Returns an randomly generated selection of size N where Max is the largest possible valueint
size()
Returns the number of integers represented by this Selectionint[]
toArray()
Returns the elements of this selection as an array of intstoString()
protected static Selection
with
(int... rows) Returns a Selection containing all indexes in the arrayprotected static Selection
withoutRange
(int totalRangeStart, int totalRangeEnd, int excludedRangeStart, int excludedRangeEnd) Returns a Selection containing all values from totalRangeStart to totalRangeEnd, except for those in the range from excludedRangeStart to excludedRangeEnd.protected static Selection
withRange
(int start, int end) Returns a Selection containing all indexes in the range start (inclusive) to end (exclusive),Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface it.unimi.dsi.fastutil.ints.IntIterable
forEach, forEach, forEach, intIterator, intSpliterator, spliterator
-
Constructor Details
-
BitmapBackedSelection
public BitmapBackedSelection(int size) Returns a selection initialized from 0 to the given size, which cane be used for queries that exclude certain items, by first selecting the items to exclude, then flipping the bits.- Parameters:
size
- The size The end point, exclusive
-
BitmapBackedSelection
public BitmapBackedSelection(int[] arr) Constructs a selection containing the elements in the given array -
BitmapBackedSelection
public BitmapBackedSelection(org.roaringbitmap.RoaringBitmap bitmap) Constructs a selection containing the elements in the given bitmap -
BitmapBackedSelection
public BitmapBackedSelection()Constructs an empty Selection
-
-
Method Details
-
removeRange
Removes from the current bitmap from all integers in [rangeStart,rangeEnd)- Specified by:
removeRange
in interfaceSelection
- Parameters:
start
- inclusive beginning of rangeend
- exclusive ending of range
-
flip
Returns a selection with the bits from this selection flipped over the given range -
add
Adds the given integers to the Selection if it is not already present, and does nothing otherwise -
toString
-
size
public int size()Returns the number of integers represented by this Selection -
toArray
public int[] toArray()Returns the elements of this selection as an array of ints -
and
Intersects the receiver andotherSelection
, updating the receiver -
or
Implements the union of the receiver andotherSelection
, updating the receiver -
andNot
Implements the set difference operation between the receiver andotherSelection
, after updating the receiver -
isEmpty
public boolean isEmpty()Returns true if this selection has no values, and false otherwise -
clear
Returns this selection with all its values cleared -
contains
public boolean contains(int i) Returns true if the index i is selected in this object -
addRange
Adds to the current bitmap all integers in [rangeStart,rangeEnd) -
get
public int get(int i) Returns the value of the ith element. For example, if there are three ints {4, 32, 71} in the selection, get(0) returns 4, get(1) returns 32, and get(2) returns 71It can be useful if you need to iterate over the data, although there is also an iterator
-
equals
-
hashCode
public int hashCode() -
iterator
public it.unimi.dsi.fastutil.ints.IntIterator iterator()Returns a fastUtil intIterator that wraps a bitmap intIterator -
with
Returns a Selection containing all indexes in the array -
withRange
Returns a Selection containing all indexes in the range start (inclusive) to end (exclusive), -
withoutRange
protected static Selection withoutRange(int totalRangeStart, int totalRangeEnd, int excludedRangeStart, int excludedRangeEnd) Returns a Selection containing all values from totalRangeStart to totalRangeEnd, except for those in the range from excludedRangeStart to excludedRangeEnd. Start values are inclusive, end values exclusive. -
selectNRowsAtRandom
Returns an randomly generated selection of size N where Max is the largest possible value
-