Class SkipList<T, TCompare, TRandom>
SkipList Data structure
Inheritance
Implements
Namespace: Towel.DataStructures
Assembly: Towel.dll
Syntax
public class SkipList<T, TCompare, TRandom> : object, IList<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<SkipList<T, TCompare, TRandom>> where TCompare : struct, IFunc<T, T, CompareResult> where TRandom : struct, IFunc<int, int, int>
Type Parameters
Name | Description |
---|---|
T | The type of values. |
TCompare | The type for comparing |
TRandom | The type for generation algorithm. |
Constructors
| Improve this Doc View SourceSkipList(Byte, TCompare, TRandom)
Creates a new SkipList object
Declaration
public SkipList(byte levels, TCompare compare = default(TCompare), TRandom random = default(TRandom))
Parameters
Type | Name | Description |
---|---|---|
System.Byte | levels | The levels of lists within this list |
TCompare | compare | The compare type for this list |
TRandom | random | The type for generation algorithm. |
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 |
Levels
The current number of levels in this SkipList<T, TCompare, TRandom>.
Declaration
public int Levels { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Random
Gets the value of the random generation algorithm.
Declaration
public TRandom Random { get; }
Property Value
Type | Description |
---|---|
TRandom |
Methods
| Improve this Doc View SourceClear()
Returns the data structure to an empty state.
Declaration
public void Clear()
Clone()
Clones a T
.
Declaration
public SkipList<T, TCompare, TRandom> Clone()
Returns
Type | Description |
---|---|
SkipList<T, TCompare, TRandom> | A clone of the |
Contains(T)
Searches for an value in the list
Declaration
public bool Contains(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to search |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if search is successful, otherwise false |
GetEnumerator()
Declaration
public System.Collections.Generic.IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<T> |
RemoveAll<TPredicate>(TPredicate)
Removes all occurences of predicated values from the list.
Declaration
public void RemoveAll<TPredicate>(TPredicate predicate = default(TPredicate))
where TPredicate : struct, IFunc<T, bool>
Parameters
Type | Name | Description |
---|---|---|
TPredicate | predicate | The predicate to determine removals. |
Type Parameters
Name | Description |
---|---|
TPredicate | The type of predicate to determine removals. |
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 |
Returns
Type | Description |
---|---|
StepStatus | The status of the traversal. |
Type Parameters
Name | Description |
---|---|
TStep | The type of function to invoke on every |
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. |
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. |
TryRemove(T)
Searches and removes a value from the list (if found)
Declaration
public (bool Success, Exception? Exception) TryRemove(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to remove from the list |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, System.Nullable<Exception>> | True if value is found and removed, otherwise false |
TryRemoveFirst<TPredicate>(out Nullable<Exception>, TPredicate)
Tries to remove the first predicated value if the value exists.
Declaration
public bool TryRemoveFirst<TPredicate>(out Exception? exception, TPredicate predicate = default(TPredicate))
where TPredicate : struct, IFunc<T, bool>
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<Exception> | exception | The exception that occurred if the remove failed. |
TPredicate | predicate | The predicate to determine removal. |
Returns
Type | Description |
---|---|
System.Boolean | True if the value was removed. False if the value did not exist. |
Type Parameters
Name | Description |
---|---|
TPredicate | The type of predicate to determine removal. |