><

abstract class Pack[A] extends Idx[A]

List for Processing

Pack is the most ubiquitous immutable collection, like scala.List

Unlike List, Pack is mostly backed by Array and can be specialized

Usually Pack has smaller memory footprint and in most cases is faster to manipulate data

Companion
object
Source
__.scala
trait Idx[A]
trait Collection[A]
trait Able.Size
trait Able.~[A]
class Object
trait Matchable
class Any
class Boolean.G.><[A]
class Byte.G.><[A]
class Char.G.><[A]
class Double.G.><[A]
class Float.G.><[A]
class Int.G.><[A]
class Long.G.><[A]
class Short.G.><[A]

Def

@targetName("_join")
inline def +(inline v: A): THIS_TYPE

Alias for join

Alias for join

Creates a new Pack with given value appended to the end of current Pack

Source
__.scala
@targetName("_joinAll")
inline def ++(inline v: ~[A]): THIS_TYPE

Alias for joinAll

Alias for joinAll

Creates a new Pack with given stream values appended to the end of current Pack

Source
__.scala
@targetName("_joinAllAt")
inline def ++@(inline i: Int, inline v: ~[A]): THIS_TYPE

Alias for joinAllAt

Alias for joinAllAt

Creates a new Pack with given stream values inserted into current Pack at given position

Source
__.scala
@targetName("_joinAt")
inline def +@(inline i: Int, inline v: A): THIS_TYPE

Alias for joinAt

Alias for joinAt

Creates a new Pack with given value inserted into current Pack at given position

Source
__.scala
def compact: ><[A]

Optimize storage

Optimize storage

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 compact does exactly this on reqest.

So, when assigning Pack to a longer term variable, it might be usefull to run compact if memory is a concern

val list = (1 <> 1_000_000).~.drop(_ % 100 == 0).><.compact

Note. compact can be called multiple times, but will do anything only if Pack is not compacted

Source
__.scala
@targetName("drop_Range")
def drop_<>(from: Int, size: Int): THIS_TYPE

Range reversed filter

Range reversed filter

Creates a new Pack from current Pack, skipping elements within given range

Source
__.scala
@targetName("drop_Range")
inline def drop_<>(r: <>): THIS_TYPE

Range reversed filter

Range reversed filter

Creates a new Pack from current Pack, skipping elements within given range

Source
__.scala
inline def dropFirst(cnt: Int): THIS_TYPE

Head reversed filter

Head reversed filter

Creates a new Pack from current Pack, skipping given number of first elements

Source
__.scala
inline def dropLast(cnt: Int): THIS_TYPE

Tail reversed filter

Tail reversed filter

Creates a new Pack from current Pack, skipping given number of last elements

Source
__.scala
def head: A

First element

First element

Returns first elements or fails for empty Pack

Use head_? for safer access

Source
__.scala
@targetName("head_Opt")
def head_?: Opt[A]

First optional element

First optional element

Returns first elements or empty option for empty Pack

Source
__.scala
def join(v: A): THIS_TYPE

Join value

Join value

Creates a new Pack with given value appended to the end of current Pack

Source
__.scala
def joinAll(v: ~[A]): THIS_TYPE

Join stream

Join stream

Creates a new Pack with given stream values appended to the end of current Pack

Source
__.scala
def joinAllAt(i: Int, v: ~[A]): THIS_TYPE

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
def joinAt(i: Int, v: A): THIS_TYPE

Join value at position

Join value at position

Creates a new Pack with given value inserted into current Pack at given position

Source
__.scala
inline def raw[PACK <: Raw[A]](using inline s: Shape.OfPack.Tag.Raw[A, PACK]): PACK

Specialize

Specialize

This operation will not compile for reference types

Returns specialized List for undelying primitive type

Note: If this instance is already specialized, it is returned as as

Source
__.scala
def tail: ><[A]

Pack without first element

Pack without first element

Note. The returned tail can be empty

Source
__.scala
@targetName("take_Range")
def take_<>(from: Int, size: Int): THIS_TYPE

Range filter

Range filter

Creates a new Pack from current Pack, taking only elements within given range

Source
__.scala
@targetName("take_Range")
inline def take_<>(r: <>): THIS_TYPE

Range filter

Range filter

Creates a new Pack from current Pack, taking only elements within given range

Source
__.scala
inline def takeFirst(cnt: Int): THIS_TYPE

Head filter

Head filter

Creates a new Pack from current Pack, taking only given number of first elements

Source
__.scala
inline def takeLast(cnt: Int): THIS_TYPE

Tail filter

Tail filter

Creates a new Pack from current Pack, taking only given number of last elements

Source
__.scala
def toBuffer: Buffer[A]

To Buffer

To Buffer

Creates a Buffer collection filled with Pack elements

Both Buffer and Pack are mostly Array based, so the convertions between them are very efficient

Source
__.scala

Inherited

@targetName("stream")
def ~: ~[A]

Returns a Stream of all elements

Returns a Stream of all elements

The element order is same as in the Idx itself

  val l: Idx[Char] = ('a' <> 'g').~.><

  l.~.tp  // Prints ~(a, b, c, d, e, f, g)
Inherited from
Idx
Source
__.scala
def apply(i: Int): A

Returns element at specified position

Returns element at specified position

 val idx: Idx[Char] = ('A' <> 'Z').~.><

 idx(1).tp // Prints: B

 idx(4).tp // Prints: E
Inherited from
Idx
Source
__.scala
def isEmpty: Boolean
Inherited from
Size
Source
Size.scala
def size: Int
Inherited from
Idx
Source
__.scala