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.IDictionary< K, V > Interface Template Reference

A dictionary with keys of type K and values of type V. Equivalent to a finite partial map from K to V. More...

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

Public Member Functions

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

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 keys of type K and values of type V. Equivalent to a finite partial map from K to V.

Member Function Documentation

void C5.IDictionary< K, V >.Add ( key,
val 
)

Add a new (key, value) pair (a mapping) to the dictionary.

Exceptions
DuplicateNotAllowedExceptionif there already is an entry with the same key.

>

Parameters
keyKey to add
valValue to add

Implemented in C5.GuardedDictionary< K, V >, and C5.DictionaryBase< K, V >.

void C5.IDictionary< K, V >.AddAll< U, W > ( SCG.IEnumerable< KeyValuePair< U, W >>  entries)

Add the entries from a collection of T:C5.KeyValuePair`2 pairs to this dictionary.

Exceptions
DuplicateNotAllowedExceptionIf the input contains duplicate keys or a key already present in this dictionary.
Parameters
entries
Type Constraints
U :K 
W :V 
bool C5.IDictionary< K, V >.Check ( )

Check the integrity of the internal data structures of this dictionary. Only available in DEBUG builds???

Returns
True if check does not fail.

Implemented in C5.GuardedDictionary< K, V >, and C5.DictionaryBase< K, V >.

void C5.IDictionary< K, V >.Clear ( )

Remove all entries from the dictionary

Implemented in C5.GuardedDictionary< K, V >, and C5.DictionaryBase< K, V >.

bool C5.IDictionary< K, V >.Contains ( key)

Check if there is an entry with a specified key

Parameters
keyThe key to look for
Returns
True if key was found

Implemented in C5.GuardedDictionary< K, V >, and C5.DictionaryBase< K, V >.

bool C5.IDictionary< K, V >.ContainsAll< H > ( SCG.IEnumerable< H >  items)

Check whether this collection contains all the values in another collection. If this collection has bag semantics (

AllowsDuplicates==true) the check is made with respect to multiplicities, else multiplicities are not taken into account.

Parameters
itemsThe
Returns
True if all values in
items
is in this collection.

Implemented in C5.GuardedDictionary< K, V >, and C5.DictionaryBase< K, V >.

Type Constraints
H :K 
bool C5.IDictionary< K, V >.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]".

Parameters
keyThe key to look for
valOn exit, the value of the entry
Returns
True if key was found

Implemented in C5.GuardedDictionary< K, V >, and C5.DictionaryBase< K, V >.

bool C5.IDictionary< K, V >.FindOrAdd ( 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.

Parameters
keyThe key to look for
valOn entry the value to add if the key is not found. On exit the value found if any.
Returns
True if key was found

Implemented in C5.GuardedDictionary< K, V >, and C5.DictionaryBase< K, V >.

bool C5.IDictionary< K, V >.Remove ( key)

Remove an entry with a given key from the dictionary

Parameters
keyThe key of the entry to remove
Returns
True if an entry was found (and removed)

Implemented in C5.GuardedDictionary< K, V >, and C5.DictionaryBase< K, V >.

bool C5.IDictionary< K, V >.Remove ( key,
out V  val 
)

Remove an entry with a given key from the dictionary and report its value.

Parameters
keyThe key of the entry to remove
valOn exit, the value of the removed entry
Returns
True if an entry was found (and removed)

Implemented in C5.GuardedDictionary< K, V >, and C5.DictionaryBase< K, V >.

bool C5.IDictionary< K, V >.Update ( key,
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".

Parameters
keyThe key to look for
valThe new value
Returns
True if key was found

Implemented in C5.GuardedDictionary< K, V >, and C5.DictionaryBase< K, V >.

bool C5.IDictionary< K, V >.Update ( key,
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.

Parameters
keyThe key to look for
valThe new value
oldvalThe old value if any
Returns
True if key was found

Implemented in C5.GuardedDictionary< K, V >, and C5.DictionaryBase< K, V >.

bool C5.IDictionary< K, V >.UpdateOrAdd ( key,
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.

Parameters
keyThe key to look for
valThe value to add or replace with.
Returns
True if key was found and value updated.

Implemented in C5.GuardedDictionary< K, V >, and C5.DictionaryBase< K, V >.

bool C5.IDictionary< K, V >.UpdateOrAdd ( key,
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.

Parameters
keyThe key to look for
valThe value to add or replace with.
oldvalThe old value if any
Returns
True if key was found and value updated.

Implemented in C5.GuardedDictionary< K, V >, and C5.DictionaryBase< K, V >.

Property Documentation

Speed C5.IDictionary< K, V >.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).

See T:C5.Speed for the set of symbols.

A characterization of the speed of lookup operations (Contains() etc.) of the implementation of this dictionary.

SCG.IEqualityComparer<K> C5.IDictionary< K, V >.EqualityComparer
get

The key equalityComparer.

Func<K, V> C5.IDictionary< K, V >.Func
get

A delegate of type T:Func`2 defining the partial function from K to V give by the dictionary.

bool C5.IDictionary< K, V >.IsReadOnly
get

True if dictionary is read-only

ICollectionValue<K> C5.IDictionary< K, V >.Keys
get

A collection containing all the keys of the dictionary

V C5.IDictionary< K, V >.this[K key]
getset

Indexer for dictionary.

Exceptions
NoSuchItemExceptionif no entry is found.

The value corresponding to the key

ICollectionValue<V> C5.IDictionary< K, V >.Values
get

A collection containing all the values of the dictionary


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