SkipList<T> Class

Represents a sorted skip list that stores unique values.

public sealed class SkipList<T> : ICollection<T>, IEnumerable<T>, IReadOnlyCollection<T>, ICollection, IEnumerable

Type parameters

T
The type of elements in the skip list.
Implements

Nested types

NameDescription
SkipList<T>.EnumeratorEnumerates the elements of a SkipList<T>.

Constructors

NameDescription
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.cs

Initializes a new instance of the SkipList<T> class using Comparer<T>.Default.

public SkipList()

SkipList(IComparer<T>?)

SkipList.cs

Initializes a new instance of the SkipList<T> class with a custom comparer.

public SkipList(IComparer<T>? comparer)
Parameters
comparer IComparer<T>?
The comparer used to order elements.

SkipList(IEnumerable<T>)

SkipList.cs

Initializes a new instance of the SkipList<T> class that contains elements copied from the specified collection.

public SkipList(IEnumerable<T> collection)
Parameters
collection IEnumerable<T>
The collection whose elements are copied to the new skip list.

SkipList(IEnumerable<T>, IComparer<T>?)

SkipList.cs

Initializes 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
collection IEnumerable<T>
The collection whose elements are copied to the new skip list.
comparer IComparer<T>?
The comparer used to order elements.

Properties

NameDescription
ComparerGets the comparer used to order elements.
CountGets 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.cs

Gets the comparer used to order elements.

public IComparer<T> Comparer { get; }

Property value

IComparer<T>

Gets the number of elements contained in the skip list.

public int Count { get; }

Property value

int

System.Collections.Generic.ICollection<T>.IsReadOnly

SkipList.cs
bool ICollection<T>.IsReadOnly { get; }

Property value

bool

No documentation is available.

System.Collections.ICollection.IsSynchronized

SkipList.cs
bool ICollection.IsSynchronized { get; }

Property value

bool

No documentation is available.

System.Collections.ICollection.SyncRoot

SkipList.cs
object ICollection.SyncRoot { get; }

Property value

object

No documentation is available.

Methods

NameDescription
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.

Adds an element to the skip list if it does not already exist.

public bool Add(T item)

Parameters

item T
The element to add.

Returns

bool true if the element was added; otherwise, false.

Removes all elements from the skip list.

public void Clear()

Contains(T)

SkipList.cs

Determines whether the skip list contains a specific element.

public bool Contains(T item)

Parameters

item T
The element to locate.

Returns

bool true if the element is found; otherwise, false.

CopyTo(T[], int)

SkipList.cs

Copies the elements of the skip list to an array, starting at the specified index.

public void CopyTo(T[] array, int arrayIndex)

Parameters

array T[]
The destination array.
arrayIndex int
The zero-based index in array at which copying begins.

GetEnumerator()

SkipList.cs

Returns 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.cs

Removes the specified element from the skip list.

public bool Remove(T item)

Parameters

item T
The element to remove.

Returns

bool true if the element was removed; otherwise, false.

System.Collections.Generic.ICollection<T>.Add(T)

SkipList.cs
void ICollection<T>.Add(T item)

Parameters

item T

No documentation is available.

System.Collections.Generic.IEnumerable<T>.GetEnumerator()

SkipList.cs
IEnumerator<T> IEnumerable<T>.GetEnumerator()

No documentation is available.

System.Collections.ICollection.CopyTo(Array, int)

SkipList.cs
void ICollection.CopyTo(Array array, int arrayIndex)

Parameters

array Array
arrayIndex int

No documentation is available.

System.Collections.IEnumerable.GetEnumerator()

SkipList.cs
IEnumerator IEnumerable.GetEnumerator()

No documentation is available.

TryGetValue(T, T)

SkipList.cs

Searches for an element equal to the specified value and returns the stored value when found.

public bool TryGetValue(T equalValue, out T actualValue)

Parameters

equalValue T
The value to search for.
actualValue T
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.