Class OrderedSet<T>
Represents a collection of objects that is maintained in sorted order and allows duplicates.
Inheritance
Namespace: AlchemyBow.Navigation.Collections
Assembly: AlchemyBow.Navigation.dll
Syntax
public sealed class OrderedSet<T>
where T : class, IComparable<T>
Type Parameters
Name | Description |
---|---|
T | The type of elements in the set. |
Remarks
This collection is a hybrid of an AVL tree and a linked list.
The AVL tree part was based on this cool article - https://www.geeksforgeeks.org/avl-tree-set-1-insertion/ .
Properties
| Improve this Doc View SourceAny
Determines whether the set contains any value.
Declaration
public bool Any { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Min
Gets the first minimum value in the set.
Declaration
public T Min { get; }
Property Value
Type | Description |
---|---|
T | The first minimum value in the set. |
Methods
| Improve this Doc View SourceAdd(T)
Adds an item to the set.
Declaration
public void Add(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The element to add. |
BruteFind(Predicate<T>)
Searches for an item that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire set.
Declaration
public T BruteFind(Predicate<T> predicate)
Parameters
Type | Name | Description |
---|---|---|
System.Predicate<T> | predicate | The predicate that defines the conditions of the element to search for. |
Returns
Type | Description |
---|---|
T | The first element that matches the conditions defined by the specified predicate, if found; otherwise, |
Contains(T)
Determines whether the set contains a specific item.
Declaration
public bool Contains(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The element to locate in the set. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Remove(T)
Removes a specified item from the set.
Declaration
public void Remove(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The element to remove. |
ToArray()
Copies the elements of the set to a new array.
Declaration
public T[] ToArray()
Returns
Type | Description |
---|---|
T[] | An array containing copies of the elements of the set. |
UseRangeComparer(OrderedSetRangeComparer<T>)
Uses the comparer on the set.
Declaration
public void UseRangeComparer(OrderedSetRangeComparer<T> comparer)
Parameters
Type | Name | Description |
---|---|---|
OrderedSetRangeComparer<T> | comparer | The comparer to use. |