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 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么