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.

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

报告相同问题?

悬赏问题

  • ¥15 openwrt双栈NAT
  • ¥15 部分网页页面无法显示!
  • ¥15 怎样解决power bi 中设置管理聚合,详细信息表和详细信息列显示灰色,而不能选择相应的内容呢?
  • ¥15 QTOF MSE数据分析
  • ¥15 平板录音机录音问题解决
  • ¥15 请问维特智能的安卓APP在手机上存储传感器数据后,如何找到它的存储路径?
  • ¥15 (SQL语句|查询结果翻了4倍)
  • ¥15 Odoo17操作下面代码的模块时出现没有'读取'来访问
  • ¥50 .net core 并发调用接口问题
  • ¥15 网上各种方法试过了,pip还是无法使用