Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/traits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
A trait which indicates whether a tree node stores references to its parents (`StoredParents()`) or
if the parents must be inferred from the tree structure (`ImplicitParents()`).

Trees for which `parentlinks` returns `StoredParents()` *MUST* implement [`parent`](@ref).
Trees for which `ParentLinks` returns `StoredParents()` *MUST* implement [`parent`](@ref).

If `StoredParents()`, all nodes in the tree must also have `StoredParents()`, otherwise use
`ImplicitParents()`.

**OPTIONAL**: This should be implemented for a tree if parents of nodes are stored
```julia
AbstractTrees.parentlinks(::Type{<:TreeType}) = AbstractTrees.StoredParents()
AbstractTrees.ParentLinks(::Type{<:TreeType}) = AbstractTrees.StoredParents()
parent(t::TreeType) = get_parent(t)
```
"""
Expand Down Expand Up @@ -92,12 +92,15 @@ SiblingLinks(tree) = SiblingLinks(typeof(tree))
ChildIndexing(node)

A trait indicating whether the tree node `n` has children (as returned by [`children`](@ref)) which can be
indexed using 1-based indexing.
indexed using 1-based indexing. Options are either [`NonIndexedChildren`](@ref) (default) or [`IndexedChildren`](@ref).

To declare that the tree `TreeType` supports one-based indexing on the children, define
```julia
AbstractTrees.ChildIndexing(::Type{<:TreeType}) = AbstractTrees.IndexedChildren()
```

If a node has the `IndexedChildren()` so must all connected nodes in the tree. Otherwise, use
`NonIndexedChildren()` instead.

Options are either [`NonIndexedChildren`](@ref) (default) or [`IndexedChildren`](@ref).
"""
abstract type ChildIndexing end

Expand Down