I posted a similar message in golang mailing list, as it involve some language specific details. I hope the cuncurrency support native to the language may have a better way to model this than a pattern. If you are not familar with golang, please help me with your knowledge of data structure in general. I think most of my doubts are lanuage neutral and I had better response from SO.
I am trying model a storage area (has a containement relation like, storage -> Rack(s) -> Shelf(s) -> Bin(s). As I learned, typically it may model with "composite pattern". But, in an effort to - Keep the structural (hierarchy) details seperate from objects - Use the language constructs (channels to walk the tree etc) I was thinking of modelling the information in a tree.I do not have an understanding of what is the best tree structure suitable for this application.
- In go, I see two libraries implementing LLRB and treap. What would you recommend? Is there a more suitable data structure available?
- Does the tree has to be balanced? for example, I may have only ine shelf in one rack, but can be arbitrariy long containment in others.
- For quick traversal, I will keep it in memory. How do I manage loading, building and persisting the tree structure? Do I build the tree everytime I open the application, and do not persist the tree itself but the objects.