Show / Hide Table of Contents

Class TreeMap<T, TEquate, THash>

A generic tree data structure using a dictionary to store node data.

Inheritance
System.Object
TreeMap<T, TEquate, THash>
Implements
ITree<T>
IDataStructure<T>
ISteppable<T>
System.Collections.Generic.IEnumerable<T>
DataStructure.ICountable
DataStructure.IRemovable<T>
ICloneable<TreeMap<T, TEquate, THash>>
DataStructure.IHashing<T, THash>
DataStructure.IEquating<T, TEquate>
Namespace: Towel.DataStructures
Assembly: Towel.dll
Syntax
public class TreeMap<T, TEquate, THash> : object, ITree<T>, IDataStructure<T>, ISteppable<T>, System.Collections.Generic.IEnumerable<T>, DataStructure.ICountable, DataStructure.IRemovable<T>, ICloneable<TreeMap<T, TEquate, THash>>, DataStructure.IHashing<T, THash>, DataStructure.IEquating<T, TEquate> where TEquate : struct, IFunc<T, T, bool> where THash : struct, IFunc<T, int>
Type Parameters
Name Description
T

The generic type stored in this data structure.

TEquate

The type of function for quality checking T values.

THash

The type of function for hashing T values.

Constructors

| Improve this Doc View Source

TreeMap(T, TEquate, THash)

Constructs a new tree.

Declaration
public TreeMap(T top, TEquate equate = default(TEquate), THash hash = default(THash))
Parameters
Type Name Description
T top

The top of the tree.

TEquate equate

The function for quality checking T values.

THash hash

The function for hashing T values.

Properties

| Improve this Doc View Source

Count

Gets the current count of the data structure.

Declaration
public int Count { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Equate

Gets the value of the type that is checking T values for equality.

Declaration
public TEquate Equate { get; }
Property Value
Type Description
TEquate
| Improve this Doc View Source

Hash

Gets the value of the type that is hashing T values.

Declaration
public THash Hash { get; }
Property Value
Type Description
THash
| Improve this Doc View Source

Top

The head of the tree.

Declaration
public T Top { get; }
Property Value
Type Description
T

Methods

| Improve this Doc View Source

Children(T, Action<T>)

Stepper function for the children of a given node.

Declaration
public void Children(T parent, Action<T> step)
Parameters
Type Name Description
T parent

The node to step through the children of.

Action<T> step

The step function.

| Improve this Doc View Source

Clone()

Clones a T.

Declaration
public TreeMap<T, TEquate, THash> Clone()
Returns
Type Description
TreeMap<T, TEquate, THash>

A clone of the T.

| Improve this Doc View Source

GetEnumerator()

Declaration
public System.Collections.Generic.IEnumerator<T> GetEnumerator()
Returns
Type Description
System.Collections.Generic.IEnumerator<T>
| Improve this Doc View Source

IsChildOf(T, T)

Determines if a node is the child of another node.

Declaration
public bool IsChildOf(T node, T parent)
Parameters
Type Name Description
T node

The child to check the parent of.

T parent

The parent to check the child of.

Returns
Type Description
System.Boolean

True if the node is a child of the parent; False if not.

| Improve this Doc View Source

Parent(T)

Gets the parent of a given node.

Declaration
public T Parent(T child)
Parameters
Type Name Description
T child

The child to get the parent of.

Returns
Type Description
T

The parent of the given child.

| Improve this Doc View Source

StepperBreak<TStep>(TStep)

Traverses values and invokes a function on every T value.

Declaration
public StepStatus StepperBreak<TStep>(TStep step = default(TStep))
    where TStep : struct, IFunc<T, StepStatus>
Parameters
Type Name Description
TStep step

The function to invoke on every T value.

Returns
Type Description
StepStatus

The status of the traversal.

Type Parameters
Name Description
TStep

The type of function to invoke on every T value.

| Improve this Doc View Source

ToArray()

Constructs an array with the values of this data structure.

Declaration
public T[] ToArray()
Returns
Type Description
T[]

An array with the values of this data structure.

| Improve this Doc View Source

TryAdd(T, T)

Adds a node to the tree.

Declaration
public (bool Success, Exception? Exception) TryAdd(T node, T parent)
Parameters
Type Name Description
T node
T parent

The parent of the node to be added.

Returns
Type Description
System.ValueTuple<System.Boolean, System.Nullable<Exception>>

( Success, ? Exception)

  • Success: true if the value was added to the tree or false if not
  • ? Exception: the exception that occured if the add was not successful
| Improve this Doc View Source

TryRemove(T)

Tries to remove a value.

Declaration
public (bool Success, Exception? Exception) TryRemove(T node)
Parameters
Type Name Description
T node
Returns
Type Description
System.ValueTuple<System.Boolean, System.Nullable<Exception>>

True if the value was removed or false if not.

Implements

ITree<T>
IDataStructure<T>
ISteppable<T>
System.Collections.Generic.IEnumerable<>
DataStructure.ICountable
DataStructure.IRemovable<T>
ICloneable<T>
DataStructure.IHashing<T, THash>
DataStructure.IEquating<T, TEquate>
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX