开发者

Treelike structure for .Net

I get a collection of items:

item_id
parent_item_id
name

I need to represent it in directory tree like structure. Is there any three like .net structure that would enable to find item in it with some unique id.(fast) ,and enables me to query the items based on their and their parents names.

Thanks in 开发者_JS百科advance.


Most people will just implement this themselves. Typically by adding a children collection

item_id
parent_item_id
name
children 

You'll have to be careful to keep parent item id in synch and you'll probably need to implement rules like, children can only have one parent, and you'll also need to keep parent_item_id read only from outside the class.

Since performance is important to you and the effort is so small, I would baseline the times and memory with one structure actually that does what you need but you probably don't want to use, datatables . To make this work you just define the three columns (item_id, parent_item_id, name) and add a relationship between item_id and parent_item_id.

Once you have your baseline DataTable numbers you should be able to do better otherwise you might as well just use the DataTable.


There is nothing built in as far as I know. This is a good article that goes over how to implement a Binary Search Tree in .NET

http://msdn.microsoft.com/library/ms379572.aspx

Sounds like it would be a good place for you to start.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜