views:

36

answers:

2

Is there a built in node-like collection that will allow me to store information within information without building long hard to read generic declarations?

C# or VB.Net solutions would be appreciated.

For example:

dim base as new Dictionary(of String, Dictionary(of String, List(of String)))
dim mid as new Dictionary(of String, List(of String)
dim leaf as new List(of String)
leaf.add("leaf1")
leaf.add("leaf2")
mid.add("middle", leaf)
base.add("base", mid)

Logical Representation:

               / leaf
        mid    - leaf
     /         \ leaf
base
     \         / leaf
        mid    - leaf
               \ leaf
+2  A: 

Nothing built in. Take a look at this.

Yuriy Faktorovich
+1  A: 

There is nothing builtin, you're probably better off building your own class for each tree node.

public class Node {
  private List<Node> children = new List<Node>();

  public void Node(Node parent,Object node_data) {
    ...
  }

  // put some methods for adding, removing, retrieving children here
}

And only one private generic class!

krs1