stlab 2.3.0
Modern, modular C++ algorithms, data structures, and concurrency primitives
Loading...
Searching...
No Matches
forest_algorithms.hpp File Reference

Forest utilities in namespace stlab::forests (shape checks, flatten/transcribe, etc.). More...

#include <optional>
#include <stlab/forest.hpp>

Go to the source code of this file.

Classes

struct  stlab::forests::transcribe_iterator< Container >
 Output iterator that inserts projected values into a forest (or similar container). More...

Functions

template<class Forest1, class Forest2>
auto stlab::forests::equal_shape (const Forest1 &x, const Forest2 &y) -> bool
 Returns true if x and y have the same full-order edge sequence (values may differ).
template<class Container>
auto stlab::forests::transcriber (Container &c)
 Returns a transcribe_iterator starting at c.begin() for building c from a walk.
template<class I, class O, class P, class UP>
auto stlab::forests::transcribe (I first, const I &last, O out, P proj, UP pred)
 Walks [first, last); for positions where pred is true, assigns proj(*first) to out, otherwise calls out.trailing().
template<class R, class O, class P, class UP>
auto stlab::forests::transcribe (const R &range, O out, P proj, UP pred)
 Range overload of transcribe with explicit leading/trailing predicate pred.
template<class I, class O, class P>
auto stlab::forests::transcribe (const I &first, const I &last, O out, P proj)
 Walks [first, last) using is_leading as the predicate (default transcribe behavior).
template<class R, class O, class P>
auto stlab::forests::transcribe (const R &range, O out, P proj)
 Range overload of transcribe with is_leading as the predicate.
template<class I, class O>
auto stlab::forests::flatten (I first, const I &last, O out)
 Writes each leading node's value to out; writes std::nullopt at trailing edges.
template<class I, class F>
auto stlab::forests::unflatten (I first, I last, F &f)
 Rebuilds forest f from a flattened std::optional sequence (inverse of flatten).

Detailed Description

Forest utilities in namespace stlab::forests (shape checks, flatten/transcribe, etc.).

Algorithms that operate on forest full-order iterators: compare tree shape without comparing values (equal_shape), copy structure with a projection (transcribe), serialize leading nodes to a flat sequence with placeholders for trailing edges (flatten), and rebuild a forest from that representation (unflatten).