PC Review


Reply
Thread Tools Rate Thread

Creating a tree with generics

 
 
Polaris431
Guest
Posts: n/a
 
      9th May 2007
I need to implement a tree structure that can accept various types of
classes or structs. When the tree is created, all of its nodes are
based on a single type and not a mixture of types.

Generics seem to be the solution. However when I look at the
System.Collections.Generic namespace, there isn't anything specific
for building generic trees. There are however classes in this
namespace that I can use to build a tree. My question is, is this the
way I should go about creating the tree? Or do any of the existing
classes in this namespace have built-in tree functionality?

My tree is not for GUI purposes, so I don't want to use the TreeView
class which appears to have limitations that are overcome by Generics.

Thanks

 
Reply With Quote
 
 
 
 
Niels Ull
Guest
Posts: n/a
 
      9th May 2007
The simplest way would be to use an open source implementation, e.g. http://www.codeproject.com/csharp/treecollection2.asp

By the way, there are several other open source C# collection framewroks,
e.g. C5 (http://www.itu.dk/research/c5/) and PowerCollections (http://www.wintellect.com/PowerCollections.aspx).

These don't have a tree, though


 
Reply With Quote
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      9th May 2007
Polaris431,

There isn't any data structure out of the box in the framework which
will help you. However, you can use generics yourself to create tree
structure which takes a parameterized type for the value of your nodes.

As Neils said as well, there are third party implementations which might
be suitable for you as well.


--
- Nicholas Paldino [.NET/C# MVP]
- (E-Mail Removed)


"Polaris431" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I need to implement a tree structure that can accept various types of
> classes or structs. When the tree is created, all of its nodes are
> based on a single type and not a mixture of types.
>
> Generics seem to be the solution. However when I look at the
> System.Collections.Generic namespace, there isn't anything specific
> for building generic trees. There are however classes in this
> namespace that I can use to build a tree. My question is, is this the
> way I should go about creating the tree? Or do any of the existing
> classes in this namespace have built-in tree functionality?
>
> My tree is not for GUI purposes, so I don't want to use the TreeView
> class which appears to have limitations that are overcome by Generics.
>
> Thanks
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: creating a family tree Charlie Hoffpauir Microsoft Access 2 29th Dec 2006 02:17 PM
generics - creating a new item =?Utf-8?B?Z3V5?= Microsoft VB .NET 3 4th Jan 2006 04:46 PM
Creating a File Tree John Ortt Microsoft Access 0 23rd May 2005 11:51 AM
Creating Tree Views in Excel =?Utf-8?B?SkQ=?= Microsoft Excel Programming 3 21st Sep 2004 12:58 PM
Creating BSP tree Morten Nielsen Microsoft C# .NET 0 23rd Mar 2004 05:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:46 PM.