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
Abstract methods
Concrete methods
Returns the bitwise AND of this chunk and the specified chunk.
Returns the bitwise AND of this chunk and the specified chunk.
Returns the concatenation of this chunk with the specified chunk.
Returns the concatenation of this chunk with the specified chunk.
Returns the concatenation of this chunk with the specified chunk.
Returns the concatenation of this chunk with the specified chunk.
Returns the bitwise XOR of this chunk and the specified chunk.
Returns the bitwise XOR of this chunk and the specified chunk.
Crates a new String based on this chunk of bytes and using the given charset.
Crates a new String based on this chunk of bytes and using the given charset.
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.
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 .
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.
Deduplicates adjacent elements that are identical.
Deduplicates adjacent elements that are identical.
Drops the first n
elements of the chunk.
Drops the first n
elements of the chunk.
- Definition Classes
- IndexedSeqOps -> IterableOps -> IterableOnceOps
Drops the last n
elements of the chunk.
Drops the last n
elements of the chunk.
- Definition Classes
- StrictOptimizedIterableOps -> IndexedSeqOps -> IterableOps
Drops all elements until the predicate returns true.
Drops all elements until the predicate returns true.
Drops all elements until the effectful predicate returns true.
Drops all elements until the effectful predicate returns true.
Drops all elements so long as the predicate returns true.
Drops all elements so long as the predicate returns true.
- Definition Classes
- IterableOps -> IterableOnceOps
Drops all elements so long as the effectful predicate returns true.
Drops all elements so long as the effectful predicate returns true.
Compares the receiver object (this
) with the argument object (that
) for equivalence.
Compares the receiver object (this
) with the argument object (that
) for equivalence.
Any implementation of this method should be an equivalence relation:
- It is reflexive: for any instance
x
of typeAny
,x.equals(x)
should returntrue
. - It is symmetric: for any instances
x
andy
of typeAny
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any instances
x
,y
, andz
of typeAny
ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
.
If you override this method, you should verify that your implementation remains an equivalence relation.
Additionally, when overriding this method it is usually necessary to override hashCode
to ensure that
objects which are "equal" (o1.equals(o2)
returns true
) hash to the same scala.Int.
(o1.hashCode.equals(o2.hashCode)
).
- Value parameters:
- that
the object to compare against this object for equality.
- Returns:
true
if the receiver object is equivalent to the argument;false
otherwise.- Definition Classes
- Seq -> Equals -> Any
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
- IterableOnceOps
Returns a filtered subset of this chunk.
Returns a filtered subset of this chunk.
- Definition Classes
- StrictOptimizedIterableOps -> IterableOps -> IterableOnceOps
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
- IterableOnceOps
Returns the first element that satisfies the effectful predicate.
Returns the first element that satisfies the effectful predicate.
Folds over the elements in this chunk from the left.
Folds over the elements in this chunk from the left.
- Definition Classes
- IterableOnceOps
Folds over the elements in this chunk from the right.
Folds over the elements in this chunk from the right.
- Definition Classes
- IndexedSeqOps -> IterableOnceOps
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.
Effectfully folds over the elements in this chunk from the left.
Effectfully folds over the elements in this chunk from the left.
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
- IterableOnceOps
Calculate a hash code value for the object.
Calculate a hash code value for the object.
The default hashing algorithm is platform dependent.
Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)
) yet
not be equal (o1.equals(o2)
returns false
). A degenerate implementation could always return 0
.
However, it is required that if two objects are equal (o1.equals(o2)
returns true
) that they have
identical hash codes (o1.hashCode.equals(o2.hashCode)
). Therefore, when overriding this method, be sure
to verify that the behavior is consistent with the equals
method.
- Returns:
the hash code value for this object.
- Definition Classes
- Seq -> Any
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
- IndexedSeqOps -> IterableOps
Returns the first element of this chunk if it exists.
Returns the first element of this chunk if it exists.
- Definition Classes
- IndexedSeqOps -> IterableOps
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
- SeqOps
Determines if the chunk is empty.
Determines if the chunk is empty.
- Definition Classes
- SeqOps -> IterableOnceOps
Returns the last element of this chunk if it exists.
Returns the last element of this chunk if it exists.
- Definition Classes
- IterableOps
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 purely for the effects.
Effectfully maps the elements of this chunk purely for the effects.
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.
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
- StrictOptimizedIterableOps -> IterableOps
Returns two splits of this chunk at the specified index.
Returns two splits of this chunk at the specified index.
- Definition Classes
- IterableOps -> IterableOnceOps
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
- IndexedSeqOps -> IterableOps -> IterableOnceOps
Takes the last n
elements of the chunk.
Takes the last n
elements of the chunk.
- Definition Classes
- StrictOptimizedIterableOps -> IndexedSeqOps -> IterableOps
Takes all elements so long as the predicate returns true.
Takes all elements so long as the predicate returns true.
- Definition Classes
- IterableOps -> IterableOnceOps
Takes all elements so long as the effectual predicate returns true.
Takes all elements so long as the effectual predicate returns true.
Converts the chunk into an array.
Converts the chunk into an array.
- Definition Classes
- IterableOnceOps
Returns a string representation of the object.
Returns a string representation of the object.
The default representation is platform dependent.
- Returns:
a string representation of the object.
- Definition Classes
- Seq -> Function1 -> Iterable -> Any
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.
Inherited methods
- Definition Classes
- StrictOptimizedSeqOps -> StrictOptimizedSeqOps -> SeqOps
- Inherited from:
- StrictOptimizedSeqOps
- Definition Classes
- StrictOptimizedIterableOps -> IterableOps -> IterableOnceOps
- Inherited from:
- StrictOptimizedIterableOps
- Definition Classes
- StrictOptimizedIterableOps -> IterableOps
- Inherited from:
- StrictOptimizedIterableOps
- Inherited from:
- IndexedSeq
- Inherited from:
- StrictOptimizedSeqOps
- Definition Classes
- StrictOptimizedIterableOps -> IterableOps -> IterableOnceOps
- Inherited from:
- StrictOptimizedIterableOps
- Definition Classes
- IndexedSeqOps -> IndexedSeqOps -> IterableOps -> IterableOnceOps
- Inherited from:
- IndexedSeqOps
- Definition Classes
- StrictOptimizedIterableOps -> IterableOps -> IterableOnceOps
- Inherited from:
- StrictOptimizedIterableOps
- Definition Classes
- StrictOptimizedIterableOps -> IterableOps -> IterableOnceOps
- Inherited from:
- StrictOptimizedIterableOps
- Definition Classes
- StrictOptimizedIterableOps -> IterableOps
- Inherited from:
- StrictOptimizedIterableOps
- Definition Classes
- StrictOptimizedIterableOps -> IterableOps
- Inherited from:
- StrictOptimizedIterableOps
- Definition Classes
- StrictOptimizedIterableOps -> IterableOps
- Inherited from:
- StrictOptimizedIterableOps
Deprecated and Inherited methods
- 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]
Check .knownSize instead of .hasDefiniteSize for more actionable information (see scaladoc for details)- Inherited from:
- IterableOnceOps
- 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 .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
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