Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Repeated node names #7
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.
Thank you for your project! And congraturatons! You got rubytree is the facto ruby standart for a very very important data structure.
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.