A Chunk[A]
represents a chunk of values of type A
. Chunks are designed
are usually backed by arrays, but expose a purely functional, safe interface
to the underlying elements, and they become lazy on operations that would be
costly with arrays, such as repeated concatenation.
The implementation of balanced concatenation is based on the one for Conc-Trees in "Conc-Trees for Functional and Parallel Programming" by Aleksandar Prokopec and Martin Odersky. http://aleksandar-prokopec.com/resources/docs/lcpc-conc-trees.pdf
NOTE: For performance reasons Chunk
does not box primitive types. As a
result, it is not safe to construct chunks from heterogeneous primitive
types.
- Companion:
- object
Value members
Concrete methods
Returns the concatenation of this chunk with the specified chunk.
Returns the concatenation of this chunk with the specified chunk.
Returns a filtered, mapped subset of the elements of this chunk based on a .
Returns a filtered, mapped subset of the elements of this chunk based on a .
Transforms all elements of the chunk for as long as the specified partial function is defined.
Transforms all elements of the chunk for as long as the specified partial function is defined.
Determines whether this chunk and the specified chunk have the same length and every pair of corresponding elements of this chunk and the specified chunk satisfy the specified predicate.
Determines whether this chunk and the specified chunk have the same length and every pair of corresponding elements of this chunk and the specified chunk satisfy the specified predicate.
Drops the first n
elements of the chunk.
Drops the first n
elements of the chunk.
- Definition Classes
Drops all elements so long as the predicate returns true.
Drops all elements so long as the predicate returns true.
- Definition Classes
Determines whether a predicate is satisfied for at least one element of this chunk.
Determines whether a predicate is satisfied for at least one element of this chunk.
- Definition Classes
Returns a filtered subset of this chunk.
Returns a filtered subset of this chunk.
- Definition Classes
Filters this chunk by the specified effectful predicate, retaining all elements for which the predicate evaluates to true.
Filters this chunk by the specified effectful predicate, retaining all elements for which the predicate evaluates to true.
Returns the first element that satisfies the predicate.
Returns the first element that satisfies the predicate.
- Definition Classes
Flattens a chunk of chunks into a single chunk by concatenating all chunks.
Flattens a chunk of chunks into a single chunk by concatenating all chunks.
Folds over the elements in this chunk from the left.
Folds over the elements in this chunk from the left.
- Definition Classes
Effectfully folds over the elements in this chunk from the left.
Effectfully folds over the elements in this chunk from the left.
Folds over the elements in this chunk from the right.
Folds over the elements in this chunk from the right.
- Definition Classes
Folds over the elements in this chunk from the left. Stops the fold early when the condition is not fulfilled.
Folds over the elements in this chunk from the left. Stops the fold early when the condition is not fulfilled.
Determines whether a predicate is satisfied for all elements of this chunk.
Determines whether a predicate is satisfied for all elements of this chunk.
- Definition Classes
Returns the first element of this chunk. Note that this method is partial
in that it will throw an exception if the chunk is empty. Consider using
headOption
to explicitly handle the possibility that the chunk is empty
or iterating over the elements of the chunk in lower level, performance
sensitive code unless you really only need the first element of the chunk.
Returns the first element of this chunk. Note that this method is partial
in that it will throw an exception if the chunk is empty. Consider using
headOption
to explicitly handle the possibility that the chunk is empty
or iterating over the elements of the chunk in lower level, performance
sensitive code unless you really only need the first element of the chunk.
- Definition Classes
Returns the first element of this chunk if it exists.
Returns the first element of this chunk if it exists.
- Definition Classes
Returns the first index for which the given predicate is satisfied after or at some given index.
Returns the first index for which the given predicate is satisfied after or at some given index.
- Definition Classes
Returns the last element of this chunk if it exists.
Returns the last element of this chunk if it exists.
- Definition Classes
Statefully maps over the chunk, producing new elements of type B
.
Statefully maps over the chunk, producing new elements of type B
.
Statefully and effectfully maps over the elements of this chunk to produce new elements.
Statefully and effectfully maps over the elements of this chunk to produce new elements.
Effectfully maps the elements of this chunk in parallel.
Effectfully maps the elements of this chunk in parallel.
Effectfully maps the elements of this chunk in parallel purely for the effects.
Effectfully maps the elements of this chunk in parallel purely for the effects.
Effectfully maps the elements of this chunk purely for the effects.
Effectfully maps the elements of this chunk purely for the effects.
Materializes a chunk into a chunk backed by an array. This method can improve the performance of bulk operations.
Materializes a chunk into a chunk backed by an array. This method can improve the performance of bulk operations.
Runs fn
if a chunk
is not empty or returns default value
Runs fn
if a chunk
is not empty or returns default value
Partitions the elements of this chunk into two chunks using the specified function.
Partitions the elements of this chunk into two chunks using the specified function.
- Definition Classes
Returns two splits of this chunk at the specified index.
Returns two splits of this chunk at the specified index.
- Definition Classes
Splits this chunk on the first element that matches this predicate.
Splits this chunk on the first element that matches this predicate.
Takes the first n
elements of the chunk.
Takes the first n
elements of the chunk.
- Definition Classes
Takes all elements so long as the predicate returns true.
Takes all elements so long as the predicate returns true.
- Definition Classes
Takes all elements so long as the effectual predicate returns true.
Takes all elements so long as the effectual predicate returns true.
Zips this chunk with the specified chunk to produce a new chunk with pairs of elements from each chunk. The returned chunk will have the length of the shorter chunk.
Zips this chunk with the specified chunk to produce a new chunk with pairs of elements from each chunk. The returned chunk will have the length of the shorter chunk.
Zips this chunk with the specified chunk to produce a new chunk with pairs
of elements from each chunk, filling in missing values from the shorter
chunk with None
. The returned chunk will have the length of the longer
chunk.
Zips this chunk with the specified chunk to produce a new chunk with pairs
of elements from each chunk, filling in missing values from the shorter
chunk with None
. The returned chunk will have the length of the longer
chunk.
Zips with chunk with the specified chunk to produce a new chunk with pairs
of elements from each chunk combined using the specified function both
.
If one chunk is shorter than the other uses the specified function left
or right
to map the element that does exist to the result type.
Zips with chunk with the specified chunk to produce a new chunk with pairs
of elements from each chunk combined using the specified function both
.
If one chunk is shorter than the other uses the specified function left
or right
to map the element that does exist to the result type.
Zips this chunk with the specified chunk using the specified combiner.
Zips this chunk with the specified chunk using the specified combiner.
Deprecated methods
Appends an element to the chunk
Appends an element to the chunk
- Deprecated
Inherited methods
- Inherited from:
- SeqOps
Returns a filtered, mapped subset of the elements of this Chunk
.
Returns a filtered, mapped subset of the elements of this Chunk
.
- Definition Classes
- Inherited from:
- ChunkLike
- Inherited from:
- IterableOnceOps
- Inherited from:
- IterableOnceOps
Returns the concatenation of mapping every element into a new chunk using the specified function.
Returns the concatenation of mapping every element into a new chunk using the specified function.
- Definition Classes
- Inherited from:
- ChunkLike
- Inherited from:
- SeqOps
- Inherited from:
- SeqOps
- Inherited from:
- SeqOps
- Inherited from:
- SeqOps
- Inherited from:
- SeqOps
Returns a chunk with the elements mapped by the specified function.
Returns a chunk with the elements mapped by the specified function.
- Definition Classes
- Inherited from:
- ChunkLike
- Inherited from:
- IterableOnceOps
- Inherited from:
- IndexedSeq
- Inherited from:
- StrictOptimizedSeqOps
Zips this chunk with the index of every element.
Zips this chunk with the index of every element.
- Definition Classes
- Inherited from:
- ChunkLike
Deprecated and Inherited methods
- Deprecated
[Since version 2.13.0]
Use foldLeft instead of /:- Inherited from:
- IterableOnceOps
- Deprecated
[Since version 2.13.0]
Use foldRight instead of :\\- Inherited from:
- IterableOnceOps
- Deprecated
[Since version 2.13.0]
`aggregate` is not relevant for sequential collections. Use `foldLeft(z)(seqop)` instead.- Inherited from:
- IterableOnceOps
- Deprecated
[Since version 2.13.0]
Use iterableFactory instead- Inherited from:
- IterableOps
- Deprecated
[Since version 2.13.0]
Use `dest ++= coll` instead- Inherited from:
- IterableOnceOps
- Deprecated
[Since version 2.13.0]
Check .knownSize instead of .hasDefiniteSize for more actionable information (see scaladoc for details)- Inherited from:
- IterableOnceOps
- Deprecated
[Since version 2.13.0]
Use segmentLength instead of prefixLength- Inherited from:
- SeqOps
- Deprecated
[Since version 2.13.0]
Use coll instead of repr in a collection implementation, use the collection value itself from the outside- Inherited from:
- IterableOps
- Deprecated
[Since version 2.13.0]
Use .reverseIterator.map(f).to(...) instead of .reverseMap(f)- Inherited from:
- SeqOps
- Deprecated
[Since version 2.13.0]
Iterable.seq always returns the iterable itself- Inherited from:
- Iterable
- Deprecated
[Since version 2.13.7]
toIterable is internal and will be made protected; its name is similar to `toList` or `toSeq`, but it doesn\'t copy non-immutable collections- Inherited from:
- Iterable
- Deprecated
[Since version 2.13.0]
Use .iterator instead of .toIterator- Inherited from:
- IterableOnceOps
- Deprecated
[Since version 2.13.0]
Use .to(LazyList) instead of .toStream- Inherited from:
- IterableOnceOps
- Deprecated
[Since version 2.13.0]
toTraversable is internal and will be made protected; its name is similar to `toList` or `toSeq`, but it doesn\'t copy non-immutable collections- Inherited from:
- IterableOps
- Deprecated
[Since version 2.13.0]
Use `concat` instead- Inherited from:
- SeqOps
- Deprecated
[Since version 2.13.0]
Use .view.slice(from, until) instead of .view(from, until)- Definition Classes
- Inherited from:
- IndexedSeqOps
Inherited fields
Returns a SeqFactory
that can construct Chunk
values. The SeqFactory
exposes a newBuilder
method that is not referentially transparent because
it allocates mutable state.
Returns a SeqFactory
that can construct Chunk
values. The SeqFactory
exposes a newBuilder
method that is not referentially transparent because
it allocates mutable state.
- Inherited from:
- ChunkLike