开发者

Established data structure/pattern? List with dynamically linked children

开发者 https://www.devze.com 2023-03-28 18:50 出处:网络
I need a solution where I have one \"master\" list/array that has a number of sequentially ordered linked children, each one representing a sub-segment of the parent list. It resembles the \"unrolled

I need a solution where I have one "master" list/array that has a number of sequentially ordered linked children, each one representing a sub-segment of the parent list. It resembles the "unrolled linked list" pattern, but here the segment-list size should be dynamic.

Here I will try to explain further. I would like to find out if there's an established term for this kind of data structure/pattern (in the same manner of "graph", "binary tree" etc.) that would be to my help when further investigating this, trying to find the best implementation.

Let's say we have a "master" list with a size of ten items, 0-9, and with three childr开发者_开发技巧en a, b and c representing sub-segments of the master in the following way:

"master"    -------------------
 0-9        0 1 2 3 4 5 6 7 8 9
            ===== ========= ===
"children"  a     b         c
            0-2   3-7       8-9

Ideally, the solution should allow

  • the master to create and adjust sub-segment size of it's children (depending on rules connected to the master list data items content)
  • the children to change their sub-segment size, causing the linked siblings to adjust their size/positions accordingly
  • handle under- and overflow of total children sizes compared to master size

Any blogs, articles, code snippets etc that tackles something like this would be to great help! (My solutions will be created in php and as3, but language doesn't matter here).

Thanx!


If I understand correctly what you want. Build your data structure the other way around. List (or vector) of children nodes and each keeps a list to master node with backlink. Changing sub-segment size in such case would be simple moving of master nodes from one list to another.

 1 -> 2 -> 3 -> 4 -> 5
 \ /     /      \  /
  a-----          b
0

精彩评论

暂无评论...
验证码 换一张
取 消