class

Pf::BlockList(T)

Inherits Enumerable / Reference / Object

A simple persistent linked list of blocks, storing at most 8x Ts per block. The block that you append to is copied wholesale, which is usually cheap enough while giving you semi-bearable locality during iteration (e.g. if T is pointer- sized, you get 64-byte blocks which are in theory big friends with the CPU, but let me not make myself sound like I understand what I'm talking about here!)

Constructors

new

Constructs an empty block list.

Source

Class methods

[](*objects)

Constructs a block list containing objects.

Source

Instance methods

==(other : BlockList(T)) : Bool

Returns true if this list is equal to other.

Source
[](index : Int) : T

See Indexable#[].

Source
[]?(index : Int) : T | Nil

See Indexable#[]?.

Source
append(object : T) : BlockList(T)

Inserts object at the back of this list.

Source
each

Yields elements in this list in front-to-back order.

This method may allocate some buffer memory because it must reverse the list to yield elements in the correct order.

NOTE: All Enumerable methods eventually end up calling this method, so you must evaluate the costs (if that matters to you!)

Source
fetch(index : Int, &)

See Indexable#fetch(index : Int, &).

Source
hash(hasher)

See Object#hash(hasher)

Source
last

Returns the last element in this list. Raises IndexError if this list is empty.

Source
last?

Returns the last element in this list, or nil if this list is empty.

Source
pretty_print(pp)
Source
prior

Returns the part of this list before the last element. If this list is empty, returns an empty list.

Source
reverse_each

Yields elements in this list in back-to-front order.

Note that this is the memory order of BlockList, so this method is a pure traversal (compared to e.g. each, which does additional work to give you elements in expected order).

Source
rincludes?(object needle) : Bool

Like includes?, but faster for BlockList in particular since it iterates in memory-order (using reverse_each) vs. Enumerable's includes? which uses each.

Source
size

Returns the number of elements in this list.

Source