Show / Hide Table of Contents

    Class SortedDictionary<K, V>

    A sorted Dictionary implementation using balanced binary search tree. IEnumerable will enumerate in sorted order. This may be better than regular Dictionary implementation which can give o(K) in worst case (but O(1) amortized when collisions K is avoided).

    Inheritance
    Object
    SortedDictionary<K, V>
    Implements
    IEnumerable<KeyValuePair<K, V>>
    IEnumerable
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Advanced.Algorithms.DataStructures.Foundation
    Assembly: Advanced.Algorithms.dll
    Syntax
    public class SortedDictionary<K, V> : IEnumerable<KeyValuePair<K, V>>, IEnumerable where K : IComparable
    Type Parameters
    Name Description
    K

    The key datatype.

    V

    The value datatype.

    Constructors

    SortedDictionary()

    Declaration
    public SortedDictionary()

    Properties

    Count

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    Int32

    Item[K]

    Get/set value for given key. Time complexity: O(log(n)).

    Declaration
    public V this[K key] { get; set; }
    Parameters
    Type Name Description
    K key
    Property Value
    Type Description
    V

    Methods

    Add(K, V)

    Add a new value for given key. Time complexity: O(log(n)).

    Declaration
    public void Add(K key, V value)
    Parameters
    Type Name Description
    K key
    V value

    ContainsKey(K)

    Does this dictionary contains the given key. Time complexity: O(log(n)).

    Declaration
    public bool ContainsKey(K key)
    Parameters
    Type Name Description
    K key

    The key to check.

    Returns
    Type Description
    Boolean

    True if this dictionary contains the given key.

    GetEnumerator()

    Declaration
    public IEnumerator<KeyValuePair<K, V>> GetEnumerator()
    Returns
    Type Description
    IEnumerator<KeyValuePair<K, V>>

    NextHigher(K)

    Return the next higher key-value pair after given key in this dictionary. Time complexity: O(log(n)).

    Declaration
    public KeyValuePair<K, V> NextHigher(K key)
    Parameters
    Type Name Description
    K key
    Returns
    Type Description
    KeyValuePair<K, V>

    Null if the given key does'nt exist or next key does'nt exist.

    NextLower(K)

    Return the next lower key-value pair before given key in this dictionary. Time complexity: O(log(n)).

    Declaration
    public KeyValuePair<K, V> NextLower(K key)
    Parameters
    Type Name Description
    K key
    Returns
    Type Description
    KeyValuePair<K, V>

    Null if the given key does'nt exist or previous key does'nt exist.

    Remove(K)

    Remove the given key. Time complexity: O(log(n)).

    Declaration
    public void Remove(K key)
    Parameters
    Type Name Description
    K key

    Explicit Interface Implementations

    IEnumerable.GetEnumerator()

    Declaration
    IEnumerator IEnumerable.GetEnumerator()
    Returns
    Type Description
    IEnumerator

    Implements

    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable
    Back to top Generated by DocFX