TreeStructures 1.7.6

There is a newer version of this package available.
See the version list below for details.
dotnet add package TreeStructures --version 1.7.6                
NuGet\Install-Package TreeStructures -Version 1.7.6                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TreeStructures" Version="1.7.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TreeStructures --version 1.7.6                
#r "nuget: TreeStructures, 1.7.6"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install TreeStructures as a Cake Addin
#addin nuget:?package=TreeStructures&version=1.7.6

// Install TreeStructures as a Cake Tool
#tool nuget:?package=TreeStructures&version=1.7.6                

Introduction

This is a C# library designed for effectively handling tree structures.
Emphasizing flexibility and extensibility, the library allows easy manipulation of various tree structures.

Features:

  1. Rich extension methods for ITreeNode<TNode>
  2. Achieving mutual references between parent and child nodes
  3. Classes forming a tree structure and their Generality
  4. Bidirectional Conversion between Different Data Structures and Tree Structures.

These are the four main features of the library.

Download Nuget Package

Usage

To be documented in the wiki.

Concept

This library does not aim to be standalone.
Various useful libraries are already available, so we aim to handle tree structure-related functions while coexisting with other libraries.

Let's elaborate on the four features mentioned at the beginning.

Rich Extension Methods

Over 60 extension methods for ITreeNode<TNode> are defined, including various overloads.
Examples include:

Enumeration: Preorder, Levelorder, all traversal methods, Leafs, Ancestors, DiscendArrivals, DescendTraces, etc.
Navigation: Root, NextSibling, LastSibling, etc.
Editing: Including TryAddChild, Try●●Child, Disassemble, RemoveAllDescendant, etc.
Parameter Retrieval: NodeIndex, NodePath, Height, Depth, etc.
Predicate Methods: IsDescendantOf, IsAncestorOf, IsRoot, etc.
Conversion: ToNodeMap, ToSerializableNodeMap, ToTreeDiagram, AsValuedTreeNode
Assembly Methods: Convert, AssembleTree, AssembleAsNAryTree

Mutual References Between Parent and Child Nodes

Mutual references between parent and child nodes are handled by base classes (TreeNodeBase<TNode> or HierarchyWrapper<TSrc,TWrpr>).

In the derived types of TreeNodeBase<TNode>, customization can be achieved through protected virtual methods such as RemoveChildProcess and InsertChildProcess, which are defined as ●●ChildProcess methods.

Classes Forming a Tree Structure and Their Generality

If you want to customize in detail, use TreeNodeBase<TNode>.
For a GeneralTree, if you want to use it as a data structure or container for data, use GeneralTreeNode<TNode> or ObservableTreeNode<TNode>.
If you want to use an N-Ary Tree with a fixed number of branches and empty nodes set to null, use NAryTreeNode<TNode>.
If you want to use it as a wrapper for objects or tree structure that forms the hierarchy, use (Hierarchy | TreeNode) Wrapper<TSrc,TWrpr>.
If you need to handle resource disposal and observation, along with its role as a wrapper (e.g., ViewModel in MVVM), inherit and use Bindable(Hierarchy | TreeNode)Wrapper<TSrc,TWrpr>.

In TreeNodeBase<TNode> and its derived types, you can customize the collections used internally and those exposed externally by overriding the Setup(Inner | Public)ChildCollection methods.
HierarchyWrapper<TSrc,TWrpr> and its derived types allow customization only of the collection exposed externally.

Bidirectional Conversion between Different Data Structures and Tree Structures.

Support is provided for exte ITreeNode<TNode> methods to objects that do not implement ITreeNode<TNode>.
This is achieved by wrapping objects in a HierarchyWrapper<TSrc,TWrpr> or BindableHierarchyWrapper<TSrc,TWrpr>, or by calling AsValuedTreeNode to provide the extension methods of ITreeNode<TNode>.

Furthermore, various methods for mutual conversion, such as Convert, AssembleTree, and ToNodeMap, are available through extension methods.

Namespaces Classification

TreeStructures;

 Abstract classes define generic tree nodes, peripheral objects, and event arguments.

Inheritance diagram of generic tree nodes
InheritanceGenericTreeNode

Inheritance diagram of NodePath and NodeIndex (peripheral objects)
InheritancePeripheralObjects

TreeStructures.Linq;

 Extension methods for ITreeNode<TNode>, IMutableTreeNode<TNode>, IEnumerable<T>

TreeStructures.Utility;

 Definition of ResultWithValue<T> used as a return value for Try●● methods

TreeStructures.Collections;

 It defines collections used in internal implementations or processing steps of extension methods.
 These include the synchronizable ImitableCollection<TSrc,TConv>,
 the combinable observable collection CombinableObservableCollection<T>,
 and the ReadOnlySortFilterObservableCollection<T> that applies sorting and filtering while synchronizing with an observable collection.

TreeStructures.EventManagement;

 Objects used in event handling, implementing Observable tree nodes

TreeStructures.Xml.Serialization;

 Dictionary and others used in serialization and deserialization

TreeStrucutures.Tree;

 Purpose-specific trees

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.7.8 71 11/24/2024
1.7.7 65 11/24/2024
1.7.6 67 11/23/2024
1.7.5 77 11/22/2024
1.7.4 149 1/31/2024
1.7.3 105 1/31/2024
1.7.2 105 1/31/2024
1.7.1 106 1/31/2024
1.7.0 86 1/30/2024
1.6.3 109 1/21/2024
1.6.2 103 1/21/2024
1.6.1 108 1/21/2024
1.6.0 103 1/21/2024
1.5.0 107 1/18/2024
1.4.6 120 1/14/2024
1.4.5 109 1/14/2024
1.4.4 103 1/10/2024
1.4.3 101 1/10/2024
1.4.1 105 1/8/2024
1.4.0 97 1/6/2024
1.3.1 88 1/3/2024
1.3.0 112 1/2/2024
1.2.0 152 12/30/2023
1.1.1 111 12/26/2023
1.1.0 129 12/21/2023
1.0.1 130 12/16/2023
1.0.0 133 12/14/2023