C5  2.4
The C5 Generic Collection Library for C# and CLI is a comprehensive collection library supporting lists, sets, bags, dictionaries, priority queues, (FIFO) queues, and (LIFO) stacks. C5 runs on .NET 3.5+, Silverlight 5, Windows Phone 8, Xamarin.iOS, Xamarin.Android, and Mono.
C5.ISortedDictionary< K, V > Interface Template Reference

A dictionary with sorted keys. More...

Inheritance diagram for C5.ISortedDictionary< K, V >:
C5.IDictionary< K, V > C5.GuardedSortedDictionary< K, V > C5.SortedDictionaryBase< K, V > C5.TreeDictionary< K, V > C5.SortedArrayDictionary< K, V > C5.TreeDictionary< K, V >

Public Member Functions

KeyValuePair< K, V > FindMin ()
 Find the current least item of this sorted collection. More...
 
KeyValuePair< K, V > DeleteMin ()
 Remove the least item from this sorted collection. More...
 
KeyValuePair< K, V > FindMax ()
 Find the current largest item of this sorted collection. More...
 
KeyValuePair< K, V > DeleteMax ()
 Remove the largest item from this sorted collection. More...
 
bool TryPredecessor (K key, out KeyValuePair< K, V > res)
 Find the entry in the dictionary whose key is the predecessor of the specified key. More...
 
bool TrySuccessor (K key, out KeyValuePair< K, V > res)
 Find the entry in the dictionary whose key is the successor of the specified key. More...
 
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. More...
 
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. More...
 
KeyValuePair< K, V > Predecessor (K key)
 Find the entry with the largest key less than a given key. More...
 
KeyValuePair< K, V > Successor (K key)
 Find the entry with the least key greater than a given key. More...
 
KeyValuePair< K, V > WeakPredecessor (K key)
 Find the entry with the largest key less than or equal to a given key. More...
 
KeyValuePair< K, V > WeakSuccessor (K key)
 Find the entry with the least key greater than or equal to a given key. More...
 
bool Cut (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 More...
 
IDirectedEnumerable< KeyValuePair< K, V > > RangeFrom (K bot)
 Query this sorted collection for items greater than or equal to a supplied value. More...
 
IDirectedEnumerable< KeyValuePair< K, V > > RangeFromTo (K lowerBound, K upperBound)
 Query this sorted collection for items between two supplied values. More...
 
IDirectedEnumerable< KeyValuePair< K, V > > RangeTo (K top)
 Query this sorted collection for items less than a supplied value. More...
 
IDirectedCollectionValue< KeyValuePair< K, V > > RangeAll ()
 Create a directed collection with the same items as this collection. More...
 
void AddSorted (SCG.IEnumerable< KeyValuePair< K, V >> items)
 Add all the items from another collection with an enumeration order that is increasing in the items. More...
 
void RemoveRangeFrom (K low)
 Remove all items of this collection above or at a supplied threshold. More...
 
void RemoveRangeFromTo (K low, K hi)
 Remove all items of this collection between two supplied thresholds. More...
 
void RemoveRangeTo (K hi)
 Remove all items of this collection below a supplied threshold. More...
 
- Public Member Functions inherited from C5.IDictionary< K, V >
void Add (K key, V val)
 Add a new (key, value) pair (a mapping) to the dictionary. More...
 
void AddAll< U, W > (SCG.IEnumerable< KeyValuePair< U, W >> entries)
 Add the entries from a collection of T:C5.KeyValuePair`2 pairs to this dictionary. More...
 
bool ContainsAll< H > (SCG.IEnumerable< H > items)
 Check whether this collection contains all the values in another collection. If this collection has bag semantics ( More...
 
bool Remove (K key)
 Remove an entry with a given key from the dictionary More...
 
bool Remove (K key, out V val)
 Remove an entry with a given key from the dictionary and report its value. More...
 
void Clear ()
 Remove all entries from the dictionary More...
 
bool Contains (K key)
 Check if there is an entry with a specified key More...
 
bool Find (ref K key, out V val)
 Check if there is an entry with a specified key and report the corresponding value if found. This can be seen as a safe form of "val = this[key]". More...
 
bool Update (K key, V val)
 Look for a specific key in the dictionary and if found replace the value with a new one. This can be seen as a non-adding version of "this[key] = val". More...
 
bool Update (K key, V val, out V oldval)
 Look for a specific key in the dictionary and if found replace the value with a new one. This can be seen as a non-adding version of "this[key] = val" reporting the old value. More...
 
bool FindOrAdd (K key, ref V val)
 Look for a specific key in the dictionary. If found, report the corresponding value, else add an entry with the key and the supplied value. More...
 
bool UpdateOrAdd (K key, V val)
 Update value in dictionary corresponding to key if found, else add new entry. More general than "this[key] = val;" by reporting if key was found. More...
 
bool UpdateOrAdd (K key, V val, out V oldval)
 Update value in dictionary corresponding to key if found, else add new entry. More general than "this[key] = val;" by reporting if key was found. More...
 
bool Check ()
 Check the integrity of the internal data structures of this dictionary. Only available in DEBUG builds??? More...
 

Properties

new ISorted< K > Keys [get]
 
SCG.IComparer< K > Comparer [get]
 The key comparer used by this dictionary. More...
 
- Properties inherited from C5.IDictionary< K, V >
SCG.IEqualityComparer< K > EqualityComparer [get]
 The key equalityComparer. More...
 
this[K key] [get, set]
 Indexer for dictionary. More...
 
bool IsReadOnly [get]
 
ICollectionValue< K > Keys [get]
 
ICollectionValue< V > Values [get]
 
Func< K, V > Func [get]
 
Speed ContainsSpeed [get]
 The value is symbolic indicating the type of asymptotic complexity in terms of the size of this collection (worst-case or amortized as relevant). More...
 

Detailed Description

A dictionary with sorted keys.

Member Function Documentation

void C5.ISortedDictionary< K, V >.AddSorted ( SCG.IEnumerable< KeyValuePair< K, V >>  items)

Add all the items from another collection with an enumeration order that is increasing in the items.

Exceptions
ArgumentExceptionif the enumerated items turns out not to be in increasing order.
Parameters
itemsThe collection to add.

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

bool C5.ISortedDictionary< K, V >.Cut ( 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.

Parameters
cutFunctionThe cut function
K
to
int
, given by the
CompareTo
method of an object implementing
IComparable<K>
.
lowEntryReturns the largest item in the collection, where the cut function is positive (if any).
lowIsValidReturns true if the cut function is positive somewhere on this collection.
highEntryReturns the least item in the collection, where the cut function is negative (if any).
highIsValidReturns true if the cut function is negative somewhere on this collection.
Returns
True if the cut function is zero somewhere on this collection.

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

KeyValuePair<K, V> C5.ISortedDictionary< K, V >.DeleteMax ( )

Remove the largest item from this sorted collection.

Exceptions
NoSuchItemExceptionif the collection is empty.
Returns
The removed item.

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

KeyValuePair<K, V> C5.ISortedDictionary< K, V >.DeleteMin ( )

Remove the least item from this sorted collection.

Exceptions
NoSuchItemExceptionif the collection is empty.
Returns
The removed item.

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

KeyValuePair<K, V> C5.ISortedDictionary< K, V >.FindMax ( )

Find the current largest item of this sorted collection.

Exceptions
NoSuchItemExceptionif the collection is empty.
Returns
The largest item.

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

KeyValuePair<K, V> C5.ISortedDictionary< K, V >.FindMin ( )

Find the current least item of this sorted collection.

Exceptions
NoSuchItemExceptionif the collection is empty.
Returns
The least item.

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

KeyValuePair<K, V> C5.ISortedDictionary< K, V >.Predecessor ( key)

Find the entry with the largest key less than a given key.

Exceptions
NoSuchItemExceptionif there is no such entry.
Parameters
keyThe key to compare to
Returns
The entry

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

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.

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

IDirectedEnumerable<KeyValuePair<K, V> > C5.ISortedDictionary< K, V >.RangeFrom ( 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.

Parameters
botThe lower bound (inclusive).
Returns
The result directed collection.

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

IDirectedEnumerable<KeyValuePair<K, V> > C5.ISortedDictionary< K, V >.RangeFromTo ( lowerBound,
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.

Parameters
lowerBoundThe lower bound (inclusive).
upperBoundThe upper bound (exclusive).
Returns
The result directed collection.

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

IDirectedEnumerable<KeyValuePair<K, V> > C5.ISortedDictionary< K, V >.RangeTo ( 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.

Parameters
topThe upper bound (exclusive).
Returns
The result directed collection.

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

void C5.ISortedDictionary< K, V >.RemoveRangeFrom ( low)

Remove all items of this collection above or at a supplied threshold.

Parameters
lowThe lower threshold (inclusive).

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

void C5.ISortedDictionary< K, V >.RemoveRangeFromTo ( low,
hi 
)

Remove all items of this collection between two supplied thresholds.

Parameters
lowThe lower threshold (inclusive).
hiThe upper threshold (exclusive).

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

void C5.ISortedDictionary< K, V >.RemoveRangeTo ( hi)

Remove all items of this collection below a supplied threshold.

Parameters
hiThe upper threshold (exclusive).

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

KeyValuePair<K, V> C5.ISortedDictionary< K, V >.Successor ( key)

Find the entry with the least key greater than a given key.

Exceptions
NoSuchItemExceptionif there is no such entry.
Parameters
keyThe key to compare to
Returns
The entry

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

bool C5.ISortedDictionary< K, V >.TryPredecessor ( key,
out KeyValuePair< K, V >  res 
)

Find the entry in the dictionary whose key is the predecessor of the specified key.

Parameters
keyThe key
resThe predecessor, if any
Returns
True if key has a predecessor

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

bool C5.ISortedDictionary< K, V >.TrySuccessor ( key,
out KeyValuePair< K, V >  res 
)

Find the entry in the dictionary whose key is the successor of the specified key.

Parameters
keyThe key
resThe successor, if any
Returns
True if the key has a successor

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

bool C5.ISortedDictionary< K, V >.TryWeakPredecessor ( key,
out KeyValuePair< K, V >  res 
)

Find the entry in the dictionary whose key is the weak predecessor of the specified key.

Parameters
keyThe key
resThe predecessor, if any
Returns
True if key has a weak predecessor

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

bool C5.ISortedDictionary< K, V >.TryWeakSuccessor ( key,
out KeyValuePair< K, V >  res 
)

Find the entry in the dictionary whose key is the weak successor of the specified key.

Parameters
keyThe key
resThe weak successor, if any
Returns
True if the key has a weak successor

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

KeyValuePair<K, V> C5.ISortedDictionary< K, V >.WeakPredecessor ( key)

Find the entry with the largest key less than or equal to a given key.

Exceptions
NoSuchItemExceptionif there is no such entry.
Parameters
keyThe key to compare to
Returns
The entry

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

KeyValuePair<K, V> C5.ISortedDictionary< K, V >.WeakSuccessor ( key)

Find the entry with the least key greater than or equal to a given key.

Exceptions
NoSuchItemExceptionif there is no such entry.
Parameters
keyThe key to compare to
Returns
The entry

Implemented in C5.GuardedSortedDictionary< K, V >, and C5.SortedDictionaryBase< K, V >.

Property Documentation

SCG.IComparer<K> C5.ISortedDictionary< K, V >.Comparer
get

The key comparer used by this dictionary.

new ISorted<K> C5.ISortedDictionary< K, V >.Keys
get


The documentation for this interface was generated from the following file: