You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As far as I understand, the default for ChildIndexing is NonIndexedChildren, which should imply that it shouldn't be necessary to implement indexing for children? The other iterators (*OrderDFS, Leaves) work fine with my type.
This should work as an MWE:
struct VectorTreeNode
children ::Vector{Any}VectorTreeNode(cs) = (cs isa Vector) ?new(cs) :new([])
endstruct VectorTreeChildren
node ::VectorTreeNodeend
Base.IteratorSize(::Type{VectorTreeChildren}) = Base.SizeUnknown()
function Base.iterate(it::VectorTreeChildren, state =1)
if state <=length(it.node.children)
(VectorTreeNode(it.node.children[state]), state +1)
elsenothingendendusing AbstractTrees
AbstractTrees.children(n::VectorTreeNode) =VectorTreeChildren(n)
n =VectorTreeNode([1,[2,3],4])
collect(StatelessBFS(n))
Note: there is also #15 which seems to be a similar issue, but is quite outdated I think -- Leaves works and the indexability trait (ChildIndexing) exists now.
The text was updated successfully, but these errors were encountered:
Iterating over
StatelessBFS
callsgetindex
on the object returned bychildren()
:As far as I understand, the default for
ChildIndexing
isNonIndexedChildren
, which should imply that it shouldn't be necessary to implement indexing forchildren
? The other iterators (*OrderDFS
,Leaves
) work fine with my type.This should work as an MWE:
Note: there is also #15 which seems to be a similar issue, but is quite outdated I think --
Leaves
works and the indexability trait (ChildIndexing
) exists now.The text was updated successfully, but these errors were encountered: