Gets the i
-th element of this chunk, throwing an IndexOutOfBoundsException
if the index is not in the range [0,size)
.
Copies the elements of this chunk in to the specified array at the specified start index.
Returns a new chunk made up of the elemenets of this chunk without the first n
elements.
Returns a new chunk made up of the elements of this chunk for which the specified predicate returns true.
Reduces this chunk to a value of type B
by applying f
to each element, left to right,
passing the output of each invocation of f
to the next invocation of f
and starting with z
.
Reduces this chunk to a value of type B
by applying f
to each element, right to left,
passing the output of each invocation of f
to the next invocation of f
and starting with z
.
Returns the number of elements in this chunk.
Returns a new chunk made up of the first n
elemenets of this chunk.
Maps and filters this chunk simultaneously using the supplied partial function.
Returns the index of the first element for which p
returns true.
Returns true if this chunk has no elements.
Creates an iterator that iterates the elements of this chunk.
Creates an iterator that iterates the elements of this chunk. The returned iterator is not thread safe.
Applies f
to each element of this chunk, resulting in a new chunk of the same size.
Simultaneously folds and maps this chunk, returning the output of the fold and the transformed chunk.
Returns true if this chunk has at least 1 element.
Like foldLeft
but each intermediate B
value is output.
Copies the elements of this chunk to an array.
Converts this chunk to a Chunk.Booleans
, allowing access to the underlying array of elements.
Converts this chunk to a Chunk.Booleans
, allowing access to the underlying array of elements.
If this chunk is already backed by an unboxed array of booleans, this method runs in constant time.
Otherwise, this method will copy of the elements of this chunk in to a single array.
Converts this chunk to a Chunk.Bytes
, allowing access to the underlying array of elements.
Converts this chunk to a Chunk.Bytes
, allowing access to the underlying array of elements.
If this chunk is already backed by an unboxed array of booleans, this method runs in constant time.
Otherwise, this method will copy of the elements of this chunk in to a single array.
Converts this chunk to a Chunk.Doubles
, allowing access to the underlying array of elements.
Converts this chunk to a Chunk.Doubles
, allowing access to the underlying array of elements.
If this chunk is already backed by an unboxed array of booleans, this method runs in constant time.
Otherwise, this method will copy of the elements of this chunk in to a single array.
Converts this chunk to a list.
Converts this chunk to a Chunk.Longs
, allowing access to the underlying array of elements.
Converts this chunk to a Chunk.Longs
, allowing access to the underlying array of elements.
If this chunk is already backed by an unboxed array of booleans, this method runs in constant time.
Otherwise, this method will copy of the elements of this chunk in to a single array.
Converts this chunk to a vector.
If this chunk is non-empty, returns the first element of the chunk and the rest as a new chunk.
If this chunk is non-empty, returns the first element of the chunk and the rest as a new chunk. Otherwise, returns none.
A strict, in-memory sequence of
A
values.Chunks can be constructed via various constructor methods on the
Chunk
companion object.Chunks are internally specialized for both single element chunks and unboxed arrays of primitives.
Supports unboxed operations for booleans, bytes, longs, and doubles, using a
Chunk
implementation that is backed by an array of primitives. When possible, operations onChunk
preserves unboxed-ness. To get access the the underlying unboxed arrays, usetoBooleans
,toBytes
,toLongs
, andtoDoubles
.Note: the NonEmptyChunk type is a subtype of
Chunk
which is limited to chunks with at least one element.