Interface ISortedDictionary<K,V>

A dictionary with sorted keys.

Implements

System.Collections.Generic.IEnumerable<KeyValuePair<K,V>>, System.Collections.IEnumerable, System.IFormattable, System.ICloneable, ICollectionValue<KeyValuePair<K,V>>, IDictionary<K,V>, IShowable

Implemented by

GuardedSortedDictionary<K,V>, SortedDictionaryBase<K,V>, TreeDictionary<K,V>

Property overview

Comparer ,
Keys

Method overview

AddSorted(System.Collections.Generic.IEnumerable<KeyValuePair<K,V>> items) ,
Cut(System.IComparable<K> cutFunction, out KeyValuePair<K,V> lowEntry, out bool lowIsValid, out KeyValuePair<K,V> highEntry, out bool highIsValid) ,
DeleteMax() ,
DeleteMin() ,
FindMax() ,
FindMin() ,
Predecessor(K key) ,
RangeAll() ,
RangeFrom(K bot) ,
RangeFromTo(K lowerBound, K upperBound) ,
RangeTo(K top) ,
RemoveRangeFrom(K low) ,
RemoveRangeFromTo(K low, K hi) ,
RemoveRangeTo(K hi) ,
Successor(K key) ,
TryPredecessor(K key, out KeyValuePair<K,V> res) ,
TrySuccessor(K key, out KeyValuePair<K,V> res) ,
TryWeakPredecessor(K key, out KeyValuePair<K,V> res) ,
TryWeakSuccessor(K key, out KeyValuePair<K,V> res) ,
WeakPredecessor(K key) ,
WeakSuccessor(K key)

Property details

A System.Collections.Generic.IComparer<K> ComparerAccess: Read-Only

Value:

The key comparer used by this dictionary.
A ISorted<K> KeysAccess: Read-Only

Value:

Method details

A void AddSorted(System.Collections.Generic.IEnumerable<KeyValuePair<K,V>> items) Add all the items from another collection with an enumeration order that is increasing in the items.
Throws
System.ArgumentException if the enumerated items turns out not to be in increasing order.
Parameters:
items:The collection to add.
A bool Cut(System.IComparable<K> cutFunction, out KeyValuePair<K,V> lowEntry, out bool lowIsValid, out KeyValuePair<K,V> highEntry, out bool highIsValid) Given a "cut" function from the items of the sorted collection to int whose only sign changes when going through items in increasing order can be
  • from positive to zero
  • from positive to negative
  • from zero to negative
The "cut" function is supplied as the CompareTo method of an object c implementing IComparable<K>. A typical example is the case where K is comparable and c is itself of type K.

This method performs a search in the sorted collection for the ranges in which the "cut" function is negative, zero respectively positive. If K is comparable and c is of type K, this is a safe way (no exceptions thrown) to find predecessor and successor of c.

If the supplied cut function does not satisfy the sign-change condition, the result of this call is undefined.

Returns:True if the cut function is zero somewhere on this collection.
Parameters:
cutFunction:The cut function K to int, given by the CompareTo method of an object implementing IComparable<K>.
lowEntry:Returns the largest item in the collection, where the cut function is positive (if any).
lowIsValid:Returns true if the cut function is positive somewhere on this collection.
highEntry:Returns the least item in the collection, where the cut function is negative (if any).
highIsValid:Returns true if the cut function is negative somewhere on this collection.
A KeyValuePair<K,V> DeleteMax() Remove the largest item from this sorted collection.
Throws
NoSuchItemException if the collection is empty.
Returns:The removed item.
A KeyValuePair<K,V> DeleteMin() Remove the least item from this sorted collection.
Throws
NoSuchItemException if the collection is empty.
Returns:The removed item.
A KeyValuePair<K,V> FindMax() Find the current largest item of this sorted collection.
Throws
NoSuchItemException if the collection is empty.
Returns:The largest item.
A KeyValuePair<K,V> FindMin() Find the current least item of this sorted collection.
Throws
NoSuchItemException if the collection is empty.
Returns:The least item.
A KeyValuePair<K,V> Predecessor(K key) Find the entry with the largest key less than a given key.
Throws
NoSuchItemException if there is no such entry.
Returns:The entry
Parameters:
key:The key to compare to
A IDirectedCollectionValue<KeyValuePair<K,V>> RangeAll() Create a directed collection with the same items as this collection.

The returned collection is not a copy but a view into the collection.

The view is fragile in the sense that changes to the underlying collection will invalidate the view so that further operations on the view throws InvalidView exceptions.

Returns:The result directed collection.
A IDirectedEnumerable<KeyValuePair<K,V>> RangeFrom(K bot) Query this sorted collection for items greater than or equal to a supplied value.

The returned collection is not a copy but a view into the collection.

The view is fragile in the sense that changes to the underlying collection will invalidate the view so that further operations on the view throws InvalidView exceptions.

Returns:The result directed collection.
Parameters:
bot:The lower bound (inclusive).
A IDirectedEnumerable<KeyValuePair<K,V>> RangeFromTo(K lowerBound, K upperBound) Query this sorted collection for items between two supplied values.

The returned collection is not a copy but a view into the collection.

The view is fragile in the sense that changes to the underlying collection will invalidate the view so that further operations on the view throws InvalidView exceptions.

Returns:The result directed collection.
Parameters:
lowerBound:The lower bound (inclusive).
upperBound:The upper bound (exclusive).
A IDirectedEnumerable<KeyValuePair<K,V>> RangeTo(K top) Query this sorted collection for items less than a supplied value.

The returned collection is not a copy but a view into the collection.

The view is fragile in the sense that changes to the underlying collection will invalidate the view so that further operations on the view throws InvalidView exceptions.

Returns:The result directed collection.
Parameters:
top:The upper bound (exclusive).
A void RemoveRangeFrom(K low) Remove all items of this collection above or at a supplied threshold.
Parameters:
low:The lower threshold (inclusive).
A void RemoveRangeFromTo(K low, K hi) Remove all items of this collection between two supplied thresholds.
Parameters:
low:The lower threshold (inclusive).
hi:The upper threshold (exclusive).
A void RemoveRangeTo(K hi) Remove all items of this collection below a supplied threshold.
Parameters:
hi:The upper threshold (exclusive).
A KeyValuePair<K,V> Successor(K key) Find the entry with the least key greater than a given key.
Throws
NoSuchItemException if there is no such entry.
Returns:The entry
Parameters:
key:The key to compare to
A bool TryPredecessor(K key, out KeyValuePair<K,V> res) Find the entry in the dictionary whose key is the predecessor of the specified key.
Returns:True if key has a predecessor
Parameters:
key:The key
res:The predecessor, if any
A bool TrySuccessor(K key, out KeyValuePair<K,V> res) Find the entry in the dictionary whose key is the successor of the specified key.
Returns:True if the key has a successor
Parameters:
key:The key
res:The successor, if any
A bool TryWeakPredecessor(K key, out KeyValuePair<K,V> res) Find the entry in the dictionary whose key is the weak predecessor of the specified key.
Returns:True if key has a weak predecessor
Parameters:
key:The key
res:The predecessor, if any
A bool TryWeakSuccessor(K key, out KeyValuePair<K,V> res) Find the entry in the dictionary whose key is the weak successor of the specified key.
Returns:True if the key has a weak successor
Parameters:
key:The key
res:The weak successor, if any
A KeyValuePair<K,V> WeakPredecessor(K key) Find the entry with the largest key less than or equal to a given key.
Throws
NoSuchItemException if there is no such entry.
Returns:The entry
Parameters:
key:The key to compare to
A KeyValuePair<K,V> WeakSuccessor(K key) Find the entry with the least key greater than or equal to a given key.
Throws
NoSuchItemException if there is no such entry.
Returns:The entry
Parameters:
key:The key to compare to