douxing9567 2012-03-25 15:38
浏览 38
已采纳

用于建模包含/复合关系的数据结构

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.

  1. In go, I see two libraries implementing LLRB and treap. What would you recommend? Is there a more suitable data structure available?
  2. 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.
  3. 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.
  • 写回答

1条回答 默认 最新

  • duanshang3230 2012-03-25 20:13
    关注

    You got good answers on the Go-Nuts list. Sameer Ajmani's advice to start with built in types is good. Don't get bogged down in something more complex until simple solutions prove inadequate. Si guy has your solution for persistence. Gob is fast and simple.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路