2009-09-02 16 views
2

非バイナリツリーとそれに関連する操作を実装する最も優れた.NETライブラリ(商用またはオープンソース)は何ですか?要件は、ノードを動的に挿入および削除し、ノードをコピー/ペーストし、ノードに埋め込まれた情報を見つけ、フォルダの1つの領域から別の領域にフォルダおよびその子をコピー/ペーストすることです。ツリーはビジネスロジックレイヤーにあります。プレゼンテーション層はWPFです。実装言語はC#です。ツリー用のベスト.NETライブラリ

+0

そして、あなたが 'ベスト' とはどういう意味ですか?最も速いシーク時間?最小メモリフットプリント?簡単にクエリできますか? – Pondidum

+0

性能が高く、学習曲線があり、質の高いものです。 –

+0

もう1つ:XMLまたはSQLSERVERからツリーを作成する –

答えて

2

ツリーは非常に書きやすく、特定の要件が比較的多様で、「ツリーライブラリ」が非常に有用であるかどうかはわかりません。どうしてあなたは自分で書くのですか?

3

コードプレックスでQuickGraphを見たいと思うかもしれません。

4

私は間違いなくLINQ to XMLと言います。

class MyTreeNode : List<MyTreeNode> 
{ 
    // declare per-node properties here, e.g. 
    public string Name { get; set; } 
} 

ビルや木を再配置することは非常に簡単です::

XDocument doc = new XDocument(
    new XDeclaration("1.0", "utf-8", "true"), 
    new XComment("Comment"), 
    new XElement("Employees", 
     new XElement("RootElement", 
      new XElement("Employee", 
       new XAttribute("id", "123"), 
       new XElement("name", "John"), 
       new XCData("CData"))))); 

// Selection multiple nodes 
var allEmployees = xdoc.Root.Elements("Employees"); 
// Select single node 
var employeeJohn = from node in xdoc.Root.Descendants().Elements("Employees").Elements("Employee") 
        where node.Attribute("id").Value == "123" 
        select node; 

// Insert node 
XElement newNode = new XElement("NewNode", "Node content"); 
allEmployees.Add(newNode); 

// Delete node 
employeeJohn.Remove(); 
+0

既存のツリーにノードを動的に挿入したり削除したりする方法の例を追加してください。 –

4

私が使用し

MyTreeNode root = new MyTreeNode {Name = "root"}; 

MyTreeNode firstChild = new MyTreeNode {Name = "1"}; 
root.Add(firstChild); 

MyTreeNode secondChild = new MyTreeNode { Name = "2" }; 
root.Add(secondChild); 

root.Remove(firstChild); 
secondChild.Add(firstChild); 
関連する問題