How to store data - binary tree?

P

piotrek

Hi

I would like to ask you a question.

Ian creating app. that download from server directory structure ( whole
tree ) and those data are placed in proper places into my treeview control.
I decided that the most effective way would be : When i connect to the
server once, I download the list and disconnect, instead of connecting every
time i go, to the lower node in my tree hierarhy.
Thus i have a problem - how to store data.
On the C++ i once created binary tree - i tought it might be good idea.
But when i googleed, i found an interesting for me note:
"In most cases binary trees can be replaced by use of one of the .NET
Framework container classes."

Can you tell me few words about this?
Do you think that in my case i should use container class, binary tree or
you have better idea.

Thanks
PK
 
G

Guest

You're right to look for an alternative to writing your own binary tree
system, though there are some you could buy for .Net. Writing a very basic
one is not exactly trivial but then it is not terribly difficult either.

As an alternative, you could use something like a Hashtable or ArrayList to
store your structure, with each succeeding level being stored as another
Hashtable or ArrayList stored as an element of the first collection. But I
wouldn't. Keeping track of your levels of objects and the parent objects,
etc. can be as difficult as writing a simple binary tree.

Another option is to create a custom collection extending CollectionBase and
add a property to your custom collection that is another instance of its own
type. But, again, you'd have to code your own navigation implementation.

I suggest that you create an XmlDocument in memory and build your tree
there. XML is great for storing data in tree-like structures.
 
P

piotrek

Thank you.

I have been thinking about XML, but i seetled that file operations will be
slower than in-memory operations.
Anyway i try with XML.
 
G

Guest

You can do XML completely in memory.

The benefit is that all the tools are there to navigate and search your tree
structured data. The negative is that there all that functionality comes at
a price. If your set of data is very small it may not be worth the overhead.
If your set of data is very large, it may not be efficient. For what comes
in between, it may be just the ticket.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top