aristanetworks / goarista

Fairly general building blocks used in Arista Go code and open-sourced for the benefit of all.
Apache License 2.0
213 stars 68 forks source link

Add VisitChildren functionality to path.Map #62

Open kimmidi opened 3 years ago

kimmidi commented 3 years ago

The data structure internally maintains a list of children of the node.

jfrabaute commented 3 years ago

How does one decide the way the tree is traversed as there are several ways to traverse the tree?

kimmidi commented 3 years ago

I'm not sure I understand your question. If there are several matches for the provided path due to wildcards, every matching node's children are visited.

jfrabaute commented 3 years ago

How is the tree traversed in the current implementation? (reference: https://en.wikipedia.org/wiki/Tree_traversal#Types) depth first? pre-order? post-order? in-order?

kimmidi commented 3 years ago

It's not a complete tree traversal for the Visit methods, so it's not a clear answer. I'd characterize it more as BFS, as the ordering amongst child nodes is not guaranteed due to it being a map. The root certainly before the children.

But I don't see the connection with this pull request ?

jfrabaute commented 3 years ago

But I don't see the connection with this pull request ?

I suppose this functionality is added for clients to use. Some clients might know how is the tree traversal is happening (or do it in a specific way) based on what they're doing, hence my question.

kimmidi commented 3 years ago

I suppose this functionality is added for clients to use. Some clients might know how is the tree traversal is happening (or do it in a specific way) based on what they're doing, hence my question.

OK. There are no guarantees wrt the order within the children nodes.