Value Pack
Pack is the most ubiquitous immutable collection, like List in Scala
Unlike List, Pack is mostly backed by an Array and can be specialized. It usually has smaller memory footprint and in most cases is faster to manipulate data.
- Source
- __.scala
Def
Head reversed filter
Head reversed filter
Creates a new Pack from current Pack, skipping given number of first elements
- Source
- __.scala
Tail reversed filter
Tail reversed filter
Creates a new Pack from current Pack, skipping given number of last elements
- Source
- __.scala
Range reversed filter
Range reversed filter
Creates a new Pack from current Pack, skipping elements within given range
- Source
- __.scala
Range reversed filter
Range reversed filter
Creates a new Pack from current Pack, skipping elements within given range
- Source
- __.scala
Process all elements
Process all elements
Applies given function to each Pack element.
This method is more eficient than Stream foreach.
- Source
- __.scala
Join value
Join value
Creates a new Pack with given value appended to the end of current Pack
- Source
- __.scala
Join stream
Join stream
Creates a new Pack with given stream values appended to the end of current Pack
- Source
- __.scala
Join stream at position
Join stream at position
Creates a new Pack with given stream values inserted into current Pack at given position
- Source
- __.scala
Join value at position
Join value at position
Creates a new Pack with given value inserted into current Pack at given position
- Source
- __.scala
Optimize storage
Optimize storage
Returns this.type
Pack is mostly backed by Array. When created from an unknown size stream, Array within pack can end up with larger capacity than required. Because most Packs are short lived, it is wastfull to copy by default this potentially big array to proper size, but operation "pack" on "Pack" type does exactly this on request.
So, when assigning type Pack to a longer term variable, it might be usefull to "double pack" if memory is a concern
val pack = (1 <> 1_000_000).stream.drop(_ % 100 == 0).pack.pack
Note. pack can be called multiple times, but will do anything only if type Pack is not compacted
- Source
- __.scala
Specialize
Specialize
This operation will not compile for reference types
Returns specialized pack for undelying primitive type
Note: If this instance is already specialized, it is returned as is
- Source
- __.scala
Head filter
Head filter
Creates a new Pack from current Pack, taking only given number of first elements
- Source
- __.scala
Tail filter
Tail filter
Creates a new Pack from current Pack, taking only given number of last elements
- Source
- __.scala
Range filter
Range filter
Creates a new Pack from current Pack, taking only elements within given range
- Source
- __.scala
Range filter
Range filter
Creates a new Pack from current Pack, taking only elements within given range
- Source
- __.scala