C# Class LSCollections.SkipList

Represents a collection of key-and-value pairs.
The SkipList class is an implementation of the IDictionary interface. It is based on the data structure created by William Pugh.
Inheritance: IDictionary
Mostra file Open project: jeske/StepsDB-alpha Class Usage Examples

Public Methods

Method Description
Add ( object key, object value ) : void

Adds an element with the provided key and value to the SkipList.

Clear ( ) : void

Removes all elements from the SkipList.

Contains ( object key ) : bool

Determines whether the SkipList contains an element with the specified key.

CopyTo ( Array array, int index ) : void

Copies the elements of the SkipList to an Array, starting at a particular Array index.

GetEnumerator ( ) : IDictionaryEnumerator

Returns an IDictionaryEnumerator for the SkipList.

Remove ( object key ) : void

Removes the element with the specified key from the SkipList.

SkipList ( ) : System

Initializes a new instance of the SkipList class that is empty and is sorted according to the IComparable interface implemented by each key added to the SkipList.

Each key must implement the IComparable interface to be capable of comparisons with every other key in the SortedList. The elements are sorted according to the IComparable implementation of each key added to the SkipList.

SkipList ( IComparer comparer ) : System

Initializes a new instance of the SkipList class that is empty and is sorted according to the specified IComparer interface.

The elements are sorted according to the specified IComparer implementation. If comparer is a null reference, the IComparable implementation of each key is used; therefore, each key must implement the IComparable interface to be capable of comparisons with every other key in the SkipList.

this ( object key ) : object

Gets or sets the element with the specified key. This is the indexer for the SkipList.

Private Methods

Method Description
GetNewLevel ( ) : int

Returns a level value for a new SkipList node.

Initialize ( ) : void

Initializes the SkipList.

Insert ( object key, object val, Node update ) : void

Inserts a key/value pair into the SkipList.

Search ( object key ) : bool

Searches for the specified key.

Search ( object key, Node &curr ) : bool

Searches for the specified key.

Search ( object key, Node &curr, Node update ) : bool

Searches for the specified key.

SearchWithComparable ( object key, Node &curr, Node update ) : bool

Search for the specified key using the IComparable interface implemented by each key.

Assumes each key inserted into the SkipList implements the IComparable interface. If the specified key is in the SkipList, the curr parameter will reference the node with the key. If the specified key is not in the SkipList, the curr paramater will either hold the node with the first key value greater than the specified key or null indicating that the search reached the end of the SkipList.

SearchWithComparer ( object key, Node &curr, Node update ) : bool

Search for the specified key using a comparer.

System ( ) : IEnumerator

Returns an enumerator that can iterate through the SkipList.

Method Details

Add() public method

Adds an element with the provided key and value to the SkipList.
public Add ( object key, object value ) : void
key object /// The Object to use as the key of the element to add. ///
value object /// The Object to use as the value of the element to add. ///
return void

Clear() public method

Removes all elements from the SkipList.
public Clear ( ) : void
return void

Contains() public method

Determines whether the SkipList contains an element with the specified key.
public Contains ( object key ) : bool
key object /// The key to locate in the SkipList. ///
return bool

CopyTo() public method

Copies the elements of the SkipList to an Array, starting at a particular Array index.
public CopyTo ( Array array, int index ) : void
array System.Array /// The one-dimensional Array that is the destination of the elements /// copied from SkipList. ///
index int /// The zero-based index in array at which copying begins. ///
return void

GetEnumerator() public method

Returns an IDictionaryEnumerator for the SkipList.
public GetEnumerator ( ) : IDictionaryEnumerator
return IDictionaryEnumerator

Remove() public method

Removes the element with the specified key from the SkipList.
public Remove ( object key ) : void
key object /// The key of the element to remove. ///
return void

SkipList() public method

Initializes a new instance of the SkipList class that is empty and is sorted according to the IComparable interface implemented by each key added to the SkipList.
Each key must implement the IComparable interface to be capable of comparisons with every other key in the SortedList. The elements are sorted according to the IComparable implementation of each key added to the SkipList.
public SkipList ( ) : System
return System

SkipList() public method

Initializes a new instance of the SkipList class that is empty and is sorted according to the specified IComparer interface.
The elements are sorted according to the specified IComparer implementation. If comparer is a null reference, the IComparable implementation of each key is used; therefore, each key must implement the IComparable interface to be capable of comparisons with every other key in the SkipList.
public SkipList ( IComparer comparer ) : System
comparer IComparer /// The IComparer implementation to use when comparing keys. ///
return System

this() public method

Gets or sets the element with the specified key. This is the indexer for the SkipList.
public this ( object key ) : object
key object
return object