Alex
Alex

Reputation: 4948

Dictionary of recursive tree nodes

I am batch printing through many assemblies of AutoCAD documents. I have a recursive method that goes through each drawing to verify if it has any children, and then goes into each children to see if they have any children... and so on (recursively).

It has occured that I encounter a drawing that I has already printed, and it is completely useless for me to go through that drawing and print all it's children again.

So... I wanted to build a virtual list, if you will, of the exact replica of items in my tree view. I would use it to verify if the item I'm trying to print, already exists in the virtual list, if so ... then I would just insert the KeyValue in the tree, saving a lot of time.

I figured my declaration of my dictionary would look something like this ...

Dim dic_AllAssemblies As New Dictionary(Of String, TreeNodeCollection)

I took a screenshot for an example of my treeview:

Recursive treeview

The dictionary would contain the main top item "ADF020-080A0" as it's first key, and in that key the values of all it's children would be included ... Is that even possible? It might go down 6-7 levels or even more... Can a dictionary or ... list handle that? Or is there another method that I'm not yet aware of?

 ADF020-080A0
     ADF020-081A0
         M17981
         M17981
     ADF000-092AS
         Etc...
             Etc...

Upvotes: 0

Views: 383

Answers (1)

OneFineDay
OneFineDay

Reputation: 9024

I don't know any reason that would not work. With a Dictionary you have the .ContainsKey(string) to check for a duplicate key name. If the key is found, skip it.

Upvotes: 2

Related Questions