File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -9,14 +9,14 @@ A package for dealing with generalized tree-like data structures.
99
1010## Examples
1111``` julia
12- julia> t = [[1 ,2 ], [3 ,4 ]]; # collections in Base are trees
12+ julia> t = [[1 ,2 ], [3 ,4 ]]; # AbstractArray and AbstractDict are trees
1313
1414julia> children (t)
15152 - element Vector{Vector{Int64}}:
1616 [1 , 2 ]
1717 [3 , 4 ]
1818
19- julia> childindex (t, (2 ,1 ))
19+ julia> getdescendant (t, (2 ,1 ))
20203
2121
2222julia> collect (PreOrderDFS (t)) # iterate from root to leaves
Original file line number Diff line number Diff line change @@ -79,9 +79,10 @@ several major obstacles
7979All of this means that you are unlikely to get type-stable code from AbstractTrees.jl without some
8080effort.
8181
82- The simplest way around this is to define the ` eltype ` of tree iterators via
82+ The simplest way around this is to define the ` NodeType ` trait and ` nodetype ` (analogous to
83+ ` Base.IteratorEltype ` and ` eltype ` ):
8384``` julia
84- Base . NodeType (:: Type{<:ExampleNode} ) = HasNodeType ()
85+ AbstractTrees . NodeType (:: Type{<:ExampleNode} ) = HasNodeType ()
8586AbstractTrees. nodetype (:: Type{<:ExampleNode} ) = ExampleNode
8687```
8788which is equivalent to asserting that all nodes of a tree are of the same type. Performance
You can’t perform that action at this time.
0 commit comments