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.DictionaryBase< K, V > Class Template Reference

A base class for implementing a dictionary based on a set collection implementation. See the source code for T:C5.HashDictionary`2 for an example More...

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

Classes

class  KeysCollection
 
class  ValuesCollection
 

Public Member Functions

virtual void Add (K key, V value)
 Add a new (key, value) pair (a mapping) to the dictionary. More...
 
virtual void AddAll< L, W > (SCG.IEnumerable< KeyValuePair< L, W >> entries)
 Add the entries from a collection of T:C5.KeyValuePair`2 pairs to this dictionary. More...
 
virtual bool Remove (K key)
 Remove an entry with a given key from the dictionary More...
 
virtual bool Remove (K key, out V value)
 Remove an entry with a given key from the dictionary and report its value. More...
 
virtual void Clear ()
 Remove all entries from the dictionary More...
 
virtual bool Contains (K key)
 Check if there is an entry with a specified key More...
 
virtual bool ContainsAll< H > (SCG.IEnumerable< H > keys)
 
virtual bool Find (ref K key, out V value)
 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...
 
virtual bool Update (K key, V value)
 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...
 
virtual bool Update (K key, V value, out V oldvalue)
 
virtual bool FindOrAdd (K key, ref V value)
 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...
 
virtual bool UpdateOrAdd (K key, V value)
 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...
 
virtual bool UpdateOrAdd (K key, V value, out V oldvalue)
 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 and the old value if any. More...
 
virtual bool Check ()
 Check the integrity of the internal data structures of this dictionary. More...
 
override KeyValuePair< K, V > Choose ()
 Choose some entry in this Dictionary. More...
 
override SCG.IEnumerator< KeyValuePair< K, V > > GetEnumerator ()
 Create an enumerator for the collection of entries of the dictionary More...
 
override bool Show (System.Text.StringBuilder stringbuilder, ref int rest, IFormatProvider formatProvider)
 
- Public Member Functions inherited from C5.IDictionary< K, V >
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...
 

Protected Member Functions

 DictionaryBase (SCG.IEqualityComparer< K > keyequalityComparer)
 

Protected Attributes

ICollection< KeyValuePair< K, V > > pairs
 The set collection of entries underlying this dictionary implementation More...
 

Properties

override CollectionChangedHandler< KeyValuePair< K, V > > CollectionChanged
 The change event. Will be raised for every change operation on the collection. More...
 
override CollectionClearedHandler< KeyValuePair< K, V > > CollectionCleared
 The change event. Will be raised for every change operation on the collection. More...
 
override ItemsAddedHandler< KeyValuePair< K, V > > ItemsAdded
 The item added event. Will be raised for every individual addition to the collection. More...
 
override ItemsRemovedHandler< KeyValuePair< K, V > > ItemsRemoved
 The item added event. Will be raised for every individual removal from the collection. More...
 
override EventTypeEnum ListenableEvents [get]
 
override EventTypeEnum ActiveEvents [get]
 
virtual SCG.IEqualityComparer< K > EqualityComparer [get]
 
virtual Speed ContainsSpeed [get]
 
virtual ICollectionValue< K > Keys [get]
 
virtual ICollectionValue< V > Values [get]
 
virtual Func< K, V > Func [get]
 
virtual V this[K key] [get, set]
 Indexer by key for dictionary. More...
 
virtual bool IsReadOnly [get]
 
override bool IsEmpty [get]
 
override int Count [get]
 
override Speed CountSpeed [get]
 
- 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 base class for implementing a dictionary based on a set collection implementation. See the source code for T:C5.HashDictionary`2 for an example

Constructor & Destructor Documentation

C5.DictionaryBase< K, V >.DictionaryBase ( SCG.IEqualityComparer< K >  keyequalityComparer)
protected

Parameters
keyequalityComparer

Member Function Documentation

virtual void C5.DictionaryBase< K, V >.Add ( key,
value 
)
virtual

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
valueValue to add

Implements C5.IDictionary< K, V >.

virtual void C5.DictionaryBase< K, V >.AddAll< L, W > ( SCG.IEnumerable< KeyValuePair< L, W >>  entries)
virtual

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

TODO: add restrictions L:K and W:V when the .Net SDK allows it

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

Check the integrity of the internal data structures of this dictionary.

Returns
True if check does not fail.

Implements C5.IDictionary< K, V >.

override KeyValuePair<K, V> C5.DictionaryBase< K, V >.Choose ( )

Choose some entry in this Dictionary.

Exceptions
NoSuchItemExceptionif collection is empty.
Returns
virtual void C5.DictionaryBase< K, V >.Clear ( )
virtual

Remove all entries from the dictionary

Implements C5.IDictionary< K, V >.

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

Check if there is an entry with a specified key

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

Implements C5.IDictionary< K, V >.

virtual bool C5.DictionaryBase< K, V >.ContainsAll< H > ( SCG.IEnumerable< H >  keys)
virtual

Parameters
keys
Returns

Implements C5.IDictionary< K, V >.

Type Constraints
H :K 
virtual bool C5.DictionaryBase< K, V >.Find ( ref K  key,
out V  value 
)
virtual

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
valueOn exit, the value of the entry
Returns
True if key was found

Implements C5.IDictionary< K, V >.

virtual bool C5.DictionaryBase< K, V >.FindOrAdd ( key,
ref V  value 
)
virtual

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
keyOn entry the key to look for
valueOn entry the value to add if the key is not found. On exit the value found if any.
Returns
True if key was found

Implements C5.IDictionary< K, V >.

override SCG.IEnumerator<KeyValuePair<K, V> > C5.DictionaryBase< K, V >.GetEnumerator ( )

Create an enumerator for the collection of entries of the dictionary

Returns
The enumerator
virtual bool C5.DictionaryBase< K, V >.Remove ( key)
virtual

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)

Implements C5.IDictionary< K, V >.

virtual bool C5.DictionaryBase< K, V >.Remove ( key,
out V  value 
)
virtual

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

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

Implements C5.IDictionary< K, V >.

override bool C5.DictionaryBase< K, V >.Show ( System.Text.StringBuilder  stringbuilder,
ref int  rest,
IFormatProvider  formatProvider 
)

Parameters
stringbuilder
rest
formatProvider
Returns
virtual bool C5.DictionaryBase< K, V >.Update ( key,
value 
)
virtual

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
valueThe new value
Returns
True if key was found

Implements C5.IDictionary< K, V >.

virtual bool C5.DictionaryBase< K, V >.Update ( key,
value,
out V  oldvalue 
)
virtual

Parameters
key
value
oldvalue
Returns

Implements C5.IDictionary< K, V >.

virtual bool C5.DictionaryBase< K, V >.UpdateOrAdd ( key,
value 
)
virtual

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
valueThe value to add or replace with.
Returns
True if entry was updated.

Implements C5.IDictionary< K, V >.

virtual bool C5.DictionaryBase< K, V >.UpdateOrAdd ( key,
value,
out V  oldvalue 
)
virtual

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 and the old value if any.

Parameters
key
value
oldvalue
Returns

Implements C5.IDictionary< K, V >.

Member Data Documentation

ICollection<KeyValuePair<K, V> > C5.DictionaryBase< K, V >.pairs
protected

The set collection of entries underlying this dictionary implementation

Property Documentation

override EventTypeEnum C5.DictionaryBase< K, V >.ActiveEvents
get

override CollectionChangedHandler<KeyValuePair<K, V> > C5.DictionaryBase< K, V >.CollectionChanged
addremove

The change event. Will be raised for every change operation on the collection.

override CollectionClearedHandler<KeyValuePair<K, V> > C5.DictionaryBase< K, V >.CollectionCleared
addremove

The change event. Will be raised for every change operation on the collection.

virtual Speed C5.DictionaryBase< K, V >.ContainsSpeed
get

override int C5.DictionaryBase< K, V >.Count
get

The number of entries in the dictionary

override Speed C5.DictionaryBase< K, V >.CountSpeed
get

The number of entries in the dictionary

virtual SCG.IEqualityComparer<K> C5.DictionaryBase< K, V >.EqualityComparer
get

virtual Func<K, V> C5.DictionaryBase< K, V >.Func
get

override bool C5.DictionaryBase< K, V >.IsEmpty
get

True if this collection is empty.

virtual bool C5.DictionaryBase< K, V >.IsReadOnly
get

True if dictionary is read only

override ItemsAddedHandler<KeyValuePair<K, V> > C5.DictionaryBase< K, V >.ItemsAdded
addremove

The item added event. Will be raised for every individual addition to the collection.

override ItemsRemovedHandler<KeyValuePair<K, V> > C5.DictionaryBase< K, V >.ItemsRemoved
addremove

The item added event. Will be raised for every individual removal from the collection.

virtual ICollectionValue<K> C5.DictionaryBase< K, V >.Keys
get

A collection containing all the keys of the dictionary

override EventTypeEnum C5.DictionaryBase< K, V >.ListenableEvents
get

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

Indexer by key for dictionary.

The get method will throw an exception if no entry is found.

The set method behaves like M:C5.DictionaryBase`2.UpdateOrAdd(`0,`1).

Exceptions
NoSuchItemExceptionOn get if no entry is found.

The value corresponding to the key

virtual ICollectionValue<V> C5.DictionaryBase< K, V >.Values
get

A collection containing all the values of the dictionary


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