struct
Pf::UPath32
- Pf::UPath32
- Struct
- Value
- Object
Overview
An immutable vector of UInt32s (here called indices) with tree path-
specific optimizations.
path = Pf::UPath32[100, 20]
path.append(3) # => UPath32[100, 20, 3]
path.append(7) # => UPath32[100, 20, 7]
path # => UPath32[100, 20]
Included Modules
Defined in:
permafrost/upath32.crConstructors
-
.[] : UPath32
Constructs an empty path.
- .[](*ns : UInt32) : UPath32
-
.end : UPath32
Returns the sentinel End path.
Instance Method Summary
- #==(other : UPath32) : Bool
-
#[](index : Int) : UInt32
See
Indexable#[](index : Int). -
#[]?(index : Int) : UInt32 | Nil
See
Indexable#[]?(index : Int). -
#append(step : UInt32) : UPath32
Inserts step at the back of this path.
-
#dense? : Bool
Returns
trueif the underlying representation of this path is dense. -
#each(& : UInt32 -> )
Yields each index in this path in front-to-back order.
-
#end? : Bool
Returns
trueif this path is the sentinel End path. -
#hash(hasher)
See
Object#hash(hasher) -
#index? : Bool
Returns
trueif the underlying representation of this path is an index. - #inspect(io)
-
#last : UInt32
Returns the last index in this path.
-
#last? : UInt32 | Nil
Returns the last index in this path, or
nilif this path is empty. -
#prior : UPath32
Returns the part of this path before the last index.
-
#size : Int32
Returns the number of indices in this path as an index within zero or positive
Int32bounds. -
#sparse? : Bool
Returns
trueif the underlying representation of this path is sparse. -
#usize : UInt32
Returns the number of indices in this path as an index within
UInt32bounds.
Instance methods inherited from module Enumerable(UInt32)
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
Instance Method Detail
Inserts step at the back of this path. Returns the modified copy.
Returns true if the underlying representation of this path is dense.
As an optimization, we store small paths inline, packing them in 57 bits plus 4-bit size.
The shape of the "path gamut" for this representation is currently 14-9-8-6-4-4-4-4.
Paths that are outside of this "gamut" are transferred to (or constructed on)
the GC heap (#sparse?).
- The first index receives a larger number of bits, because indices near the root are usually large.
- Successive indices receive a smaller number of bits, because nodes closer to the root are expected to be large, but smaller than their predecessor.
Returns true if this path is the sentinel End path.
Sentinel End marker useful in traversals that must distinguish entering
the root from reentering it at the end of traversal.
Returns true if the underlying representation of this path is an index.
Index optimizes singleton UPath32's, which can be encountered when one uses
UPath32 as an index, or when it happens to be used as one (e.g. skipping over
root terms during DFS or BFS).
Returns the part of this path before the last index. If this path is empty, returns an empty path.
Returns the number of indices in this path as an index within zero
or positive Int32 bounds.
Returns true if the underlying representation of this path is sparse.
Sparse paths are stored on the GC heap.