Class AvlTreeLinked<T, TCompare>
A self-sorting binary tree based on the heights of each node.
Inheritance
Implements
Namespace: Towel.DataStructures
Assembly: Towel.dll
Syntax
public class AvlTreeLinked<T, TCompare> : object, IAvlTree<T, TCompare>, IAvlTree<T>, ISortedBinaryTree<T, TCompare>, ISortedBinaryTree<T>, IDataStructure<T>, ISteppable<T>, System.Collections.Generic.IEnumerable<T>, DataStructure.IAddable<T>, DataStructure.IRemovable<T>, DataStructure.ICountable, DataStructure.IClearable, DataStructure.IAuditable<T>, DataStructure.IComparing<T, TCompare>, ICloneable<AvlTreeLinked<T, TCompare>> where TCompare : struct, IFunc<T, T, CompareResult>
Type Parameters
Name | Description |
---|---|
T | The type of values stored in this data structure. |
TCompare | The type that is comparing |
Constructors
| Improve this Doc View SourceAvlTreeLinked(TCompare)
Constructs an AVL Tree.
Declaration
public AvlTreeLinked(TCompare compare = default(TCompare))
Parameters
Type | Name | Description |
---|---|---|
TCompare | compare | The comparison function for sorting |
Properties
| Improve this Doc View SourceCompare
Gets the value of the comparer that is comparing T
values.
Declaration
public TCompare Compare { get; }
Property Value
Type | Description |
---|---|
TCompare |
Count
Gets the current count of the data structure.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
CurrentGreatest
Gets the current greated value in the tree.
Declaration
public T CurrentGreatest { get; }
Property Value
Type | Description |
---|---|
T |
CurrentLeast
Gets the current least value in the tree.
Declaration
public T CurrentLeast { get; }
Property Value
Type | Description |
---|---|
T |
Methods
| Improve this Doc View SourceClear()
Returns the data structure to an empty state.
Declaration
public void Clear()
Clone()
Clones a T
.
Declaration
public AvlTreeLinked<T, TCompare> Clone()
Returns
Type | Description |
---|---|
AvlTreeLinked<T, TCompare> | A clone of the |
Contains(T)
Checks if the data structure contains a value.
Declaration
public bool Contains(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to look for in the data structure. |
Returns
Type | Description |
---|---|
System.Boolean | True if the value exists in the data structure. False if not. |
ContainsSift<TSift>(TSift)
Determines if the tree contains a value.
Declaration
public bool ContainsSift<TSift>(TSift sift = default(TSift))
where TSift : struct, IFunc<T, CompareResult>
Parameters
Type | Name | Description |
---|---|---|
TSift | sift | The sifting function that respects the sorting of the tree. |
Returns
Type | Description |
---|---|
System.Boolean | True if the value is in the tree or false if not. |
Type Parameters
Name | Description |
---|---|
TSift | The type of the sifting function. |
TryAdd(T)
Tries to add a value to a data structure.
Declaration
public (bool Success, Exception? Exception) TryAdd(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to add to the data structure. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>> | True if the value was added or false if not. |
TryGet<TSift>(TSift)
Tries to get a value.
Declaration
public (bool Success, T Value, Exception? Exception) TryGet<TSift>(TSift sift = default(TSift))
where TSift : struct, IFunc<T, CompareResult>
Parameters
Type | Name | Description |
---|---|---|
TSift | sift | The sifting function that respects the sorting of the tree. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, T, System.Nullable<Exception>> | True if the value was found or false if not. |
Type Parameters
Name | Description |
---|---|
TSift | The type of the sifting function. |
TryRemove(T)
Tries to remove a value.
Declaration
public (bool Success, Exception? Exception) TryRemove(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to remove. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>> | True if the value was removed or false if not. |
TryRemoveSift<TSift>(TSift)
Tries to remove a value.
Declaration
public (bool Success, Exception? Exception) TryRemoveSift<TSift>(TSift sift = default(TSift))
where TSift : struct, IFunc<T, CompareResult>
Parameters
Type | Name | Description |
---|---|---|
TSift | sift | The sifting function that respects the sorting of the tree. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>> | True if the remove succeeded or false if not. |
Type Parameters
Name | Description |
---|---|
TSift | The type of the sifting function. |