SkipList<T> Class
Represents a sorted skip list that stores unique values.
public sealed class SkipList<T> : ICollection<T>, IEnumerable<T>, IReadOnlyCollection<T>, ICollection, IEnumerableType parameters
T- The type of elements in the skip list.
Nested types
| Name | Description |
|---|---|
| SkipList<T>.Enumerator | Enumerates the elements of a SkipList<T>. |
Constructors
| Name | Description |
|---|---|
| SkipList() | Initializes a new instance of the SkipList<T> class using Comparer<T>.Default. |
| SkipList(IComparer<T>?) | Initializes a new instance of the SkipList<T> class with a custom comparer. |
| SkipList(IEnumerable<T>) | Initializes a new instance of the SkipList<T> class that contains elements copied from the specified collection. |
| SkipList(IEnumerable<T>, IComparer<T>?) | Initializes a new instance of the SkipList<T> class that contains elements copied from the specified collection and uses a custom comparer. |
SkipList overloads
SkipList()
SkipList.csInitializes a new instance of the SkipList<T> class using Comparer<T>.Default.
public SkipList()SkipList(IComparer<T>?)
SkipList.csInitializes a new instance of the SkipList<T> class with a custom comparer.
public SkipList(IComparer<T>? comparer)Parameters
comparerIComparer<T>?- The comparer used to order elements.
SkipList(IEnumerable<T>)
SkipList.csInitializes a new instance of the SkipList<T> class that contains elements copied from the specified collection.
public SkipList(IEnumerable<T> collection)Parameters
collectionIEnumerable<T>- The collection whose elements are copied to the new skip list.
SkipList(IEnumerable<T>, IComparer<T>?)
SkipList.csInitializes a new instance of the SkipList<T> class that contains elements copied from the specified collection and uses a custom comparer.
public SkipList(IEnumerable<T> collection, IComparer<T>? comparer)Parameters
collectionIEnumerable<T>- The collection whose elements are copied to the new skip list.
comparerIComparer<T>?- The comparer used to order elements.
Properties
| Name | Description |
|---|---|
| Comparer | Gets the comparer used to order elements. |
| Count | Gets the number of elements contained in the skip list. |
| System.Collections.Generic.ICollection<T>.IsReadOnly | |
| System.Collections.ICollection.IsSynchronized | |
| System.Collections.ICollection.SyncRoot |
Comparer
SkipList.csCount
SkipList.csSystem.Collections.Generic.ICollection<T>.IsReadOnly
SkipList.csSystem.Collections.ICollection.IsSynchronized
SkipList.csSystem.Collections.ICollection.SyncRoot
SkipList.csMethods
| Name | Description |
|---|---|
| Add(T) | Adds an element to the skip list if it does not already exist. |
| Clear() | Removes all elements from the skip list. |
| Contains(T) | Determines whether the skip list contains a specific element. |
| CopyTo(T[], int) | Copies the elements of the skip list to an array, starting at the specified index. |
| GetEnumerator() | Returns an enumerator that iterates through the skip list. |
| Remove(T) | Removes the specified element from the skip list. |
| System.Collections.Generic.ICollection<T>.Add(T) | |
| System.Collections.Generic.IEnumerable<T>.GetEnumerator() | |
| System.Collections.ICollection.CopyTo(Array, int) | |
| System.Collections.IEnumerable.GetEnumerator() | |
| TryGetValue(T, T) | Searches for an element equal to the specified value and returns the stored value when found. |
Add(T)
SkipList.csClear()
SkipList.csRemoves all elements from the skip list.
public void Clear()Contains(T)
SkipList.csCopyTo(T[], int)
SkipList.csGetEnumerator()
SkipList.csReturns an enumerator that iterates through the skip list.
public SkipList<T>.Enumerator GetEnumerator()Returns
SkipList<T>.Enumerator An enumerator for the skip list.
Remove(T)
SkipList.csSystem.Collections.Generic.ICollection<T>.Add(T)
SkipList.csSystem.Collections.Generic.IEnumerable<T>.GetEnumerator()
SkipList.csSystem.Collections.ICollection.CopyTo(Array, int)
SkipList.csSystem.Collections.IEnumerable.GetEnumerator()
SkipList.csTryGetValue(T, T)
SkipList.csSearches for an element equal to the specified value and returns the stored value when found.
public bool TryGetValue(T equalValue, out T actualValue)Parameters
equalValueT- The value to search for.
actualValueT- When this method returns, contains the matching value from the skip list, if found.
Returns
bool true if a matching element was found; otherwise, false.