Repeated node names #7

pmros opened this Issue Jun 9, 2012 · 2 comments


None yet

2 participants

pmros commented Jun 9, 2012

Documentation says this about node name: "Expected to be unique within the tree". But what could happend when names are not unique? In many cases you really don't need to care about it, you don't need a unique id.
I'd like you make a comment about it in documentation.

Thank you for your project! And congraturatons! You got rubytree is the facto ruby standart for a very very important data structure.

@evolve75 evolve75 was assigned Aug 19, 2012


The issue with the node name having to be unique is that the internal data structures are based on hashes, and also the semantic does require that each of the nodes in the tree be directly accesible via the node name (we could potentially change the logic so that an array of nodes is returned if the name is the same, but this might not be exactly what we need).

I think a better option would be to treat the name as a unique handler/ID for the node, and the duplicate node objects themselves can be added in the value part. This actually works out better (and works in the current version as well).

I am going to take your suggestion to update the documentation so that this scenario is addressed more explicitly.

@evolve75 evolve75 closed this Aug 19, 2012
pmros commented Aug 20, 2012

Thank you for answering. I could use object_id as node id, it's easy, it's unique. So I could forget that unique id issue, that I don't really care for my purposes. I'd use value for node tag and other node data.
Thank you again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment