41 static constexpr uint64_t
no_parent = std::numeric_limits<uint64_t>::max();
50 [[nodiscard]]
static std::optional<ForestIndex>
build(
51 std::span<const uint64_t> parents, std::string& error,
52 uint64_t* error_row =
nullptr);
55 [[nodiscard]]
size_t size() const noexcept {
return m_parent.size(); }
58 [[nodiscard]] std::optional<uint64_t> parent(
size_t row)
const noexcept;
61 [[nodiscard]] std::span<const uint64_t> children(
size_t row)
const noexcept;
64 [[nodiscard]] std::span<const uint64_t>
roots() const noexcept {
return m_roots; }
67 [[nodiscard]]
size_t subtree_size(
size_t row)
const noexcept;
70 [[nodiscard]] uint32_t depth(
size_t row)
const noexcept;
79 [[nodiscard]] std::optional<RowRange> subtree_range(
size_t row)
const noexcept;
std::vector< uint64_t > m_child_row
std::span< const uint64_t > roots() const noexcept
Rows without a parent, in row order.
size_t size() const noexcept
Number of rows.
std::vector< uint64_t > m_parent
bool preorder() const noexcept
Whether every subtree occupies consecutive rows.
static constexpr uint64_t no_parent
Parent value of a root row.
std::vector< uint64_t > m_subtree_size
std::vector< uint64_t > m_roots
static std::optional< ForestIndex > build(std::span< const uint64_t > parents, std::string &error, uint64_t *error_row=nullptr)
Build the index from one parent per row.
std::vector< uint64_t > m_child_offset
std::vector< uint32_t > m_depth
Parent, child, depth and subtree structure over rows linked by parent index.
Consecutive rows starting at first.