class
Pf::BlockList(T)
- Pf::BlockList(T)
- Reference
- Object
Overview
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!)
Included Modules
Defined in:
permafrost/block_list.crConstructors
-
.new : BlockList(T)
Constructs an empty block list.
Class Method Summary
-
.[](*objects)
Constructs a block list containing objects.
Instance Method Summary
-
#==(other : BlockList(T)) : Bool
Returns
trueif this list is equal to other. -
#[](index : Int) : T
See
Indexable#[]. -
#[]?(index : Int) : T | Nil
See
Indexable#[]?. -
#append(object : T) : BlockList(T)
Inserts object at the back of this list.
-
#each(& : T -> ) : Nil
Yields elements in this list in front-to-back order.
-
#fetch(index : Int, &)
See
Indexable#fetch(index : Int, &). -
#hash(hasher)
See
Object#hash(hasher) -
#last : T
Returns the last element in this list.
-
#last? : T | Nil
Returns the last element in this list, or
nilif this list is empty. - #pretty_print(pp)
-
#prior : BlockList(T)
Returns the part of this list before the last element.
-
#reverse_each(& : T -> ) : Nil
Yields elements in this list in back-to-front order.
-
#rincludes?(object needle) : Bool
Like
includes?, but faster forBlockListin particular since it iterates in memory-order (using#reverse_each) vs. -
#size : Int32
Returns the number of elements in this list.
Instance methods inherited from module Enumerable(T)
to_pf_bidi
to_pf_bidi,
to_pf_map(& : T -> Tuple(K, V)) : Pf::Map(K, V) forall K, Vto_pf_map to_pf_map, to_pf_set : Pf::Set(T) to_pf_set, to_pf_uset32 : Pf::USet32 to_pf_uset32
Constructor Detail
Class Method Detail
Instance Method Detail
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!)
Returns the part of this list before the last element. If this list is empty, returns an empty list.
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).
Like includes?, but faster for BlockList in particular since it iterates
in memory-order (using #reverse_each) vs. Enumerable's includes? which
uses #each.