Class DictionaryBase<K,V>

A base class for implementing a dictionary based on a set collection implementation. See the source code for HashDictionary<K,V> for an example

Implements

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

Bases

object, EnumerableBase<KeyValuePair<K,V>>, CollectionValueBase<KeyValuePair<K,V>>

Base of

HashDictionary<K,V>, SortedDictionaryBase<K,V>, TreeDictionary<K,V>

Field overview

pairs

Event overview

CollectionChanged ,
CollectionCleared ,
ItemInserted, Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
ItemRemovedAt, Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
ItemsAdded ,
ItemsRemoved

Property overview

ActiveEvents ,
ContainsSpeed ,
Count ,
CountSpeed ,
EqualityComparer ,
Fun ,
IsEmpty ,
IsReadOnly ,
this[K key] ,
Keys ,
ListenableEvents ,
Values

Constructor overview

DictionaryBase<K,V>(System.Collections.Generic.IEqualityComparer<K> keyequalityComparer)

Method overview

Add(K key, V value) ,
AddAll<L,W>(System.Collections.Generic.IEnumerable<KeyValuePair<L,W>> entries) ,
All(Fun<KeyValuePair<K,V>,bool> predicate), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
Apply(Act<KeyValuePair<K,V>> action), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
Check() ,
Choose() ,
Clear() ,
Clone() ,
Contains(K key) ,
ContainsAll<H>(System.Collections.Generic.IEnumerable<H> keys) ,
CopyTo(KeyValuePair<K,V>[] array, int index), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
Equals(object obj), Inherited from object ,
Exists(Fun<KeyValuePair<K,V>,bool> predicate), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
Filter(Fun<KeyValuePair<K,V>,bool> predicate), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
Finalize(), Inherited from object ,
Find(K key, out V value) ,
Find(ref K key, out V value) ,
Find(Fun<KeyValuePair<K,V>,bool> predicate, out KeyValuePair<K,V> item), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
FindOrAdd(K key, ref V value) ,
GetEnumerator() ,
GetHashCode(), Inherited from object ,
GetType(), Inherited from object ,
MemberwiseClone(), Inherited from object ,
raiseCollectionChanged(), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
raiseCollectionCleared(bool full, int count), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
raiseCollectionCleared(bool full, int count, System.Nullable<int> offset), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
raiseForAdd(KeyValuePair<K,V> item), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
raiseForInsert(int i, KeyValuePair<K,V> item), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
raiseForRemove(KeyValuePair<K,V> item), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
raiseForRemove(KeyValuePair<K,V> item, int count), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
raiseForRemoveAll(ICollectionValue<KeyValuePair<K,V>> wasRemoved), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
raiseForRemoveAt(int index, KeyValuePair<K,V> item), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
raiseForSetThis(int index, KeyValuePair<K,V> value, KeyValuePair<K,V> item), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
raiseForUpdate(KeyValuePair<K,V> newitem, KeyValuePair<K,V> olditem), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
raiseForUpdate(KeyValuePair<K,V> newitem, KeyValuePair<K,V> olditem, int count), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
raiseItemInserted(KeyValuePair<K,V> item, int index), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
raiseItemRemovedAt(KeyValuePair<K,V> item, int index), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
raiseItemsAdded(KeyValuePair<K,V> item, int count), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
raiseItemsRemoved(KeyValuePair<K,V> item, int count), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
Remove(K key) ,
Remove(K key, out V value) ,
Show(System.Text.StringBuilder stringbuilder, ref int rest, System.IFormatProvider formatProvider) ,
ToArray(), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
ToString(string format, System.IFormatProvider formatProvider), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
ToString(), Inherited from CollectionValueBase<KeyValuePair<K,V>> ,
Update(K key, V value) ,
Update(K key, V value, out V oldvalue) ,
UpdateOrAdd(K key, V value) ,
UpdateOrAdd(K key, V value, out V oldvalue)

Field details

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

Event details

CollectionChangedHandler<KeyValuePair<K,V>> CollectionChanged The change event. Will be raised for every change operation on the collection.
CollectionClearedHandler<KeyValuePair<K,V>> CollectionCleared The change event. Will be raised for every change operation on the collection.
ItemsAddedHandler<KeyValuePair<K,V>> ItemsAdded The item added event. Will be raised for every individual addition to the collection.
ItemsRemovedHandler<KeyValuePair<K,V>> ItemsRemoved The item added event. Will be raised for every individual removal from the collection.

Property details

EventTypeEnum ActiveEventsAccess: Read-Only
Speed ContainsSpeedAccess: Read-Only

Value:

int CountAccess: Read-Only

Value:The number of entrues in the dictionary

Speed CountSpeedAccess: Read-Only

Value:The number of entrues in the dictionary

System.Collections.Generic.IEqualityComparer<K> EqualityComparerAccess: Read-Only

Value:

Fun<K,V> FunAccess: Read-Only
bool IsEmptyAccess: Read-Only

Value:True if this collection is empty.

bool IsReadOnlyAccess: Read-Only

Value:True if dictionary is read only

V this[K key]Access: Read-Write

Value:The value corresponding to the key

Indexer by key for dictionary.

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

The set method behaves like UpdateOrAdd(K key, V value).

Throws
NoSuchItemException On get if no entry is found.
ICollectionValue<K> KeysAccess: Read-Only

Value:A collection containg the all the keys of the dictionary

EventTypeEnum ListenableEventsAccess: Read-Only
ICollectionValue<V> ValuesAccess: Read-Only

Value:A collection containing all the values of the dictionary

Constructor details

PDictionaryBase<K,V>(System.Collections.Generic.IEqualityComparer<K> keyequalityComparer)
Parameters:
keyequalityComparer:

Method details

void Add(K key, V value) Add a new (key, value) pair (a mapping) to the dictionary.
Throws
DuplicateNotAllowedException if there already is an entry with the same key.
Parameters:
key:Key to add
value:Value to add
void AddAll<L,W>(System.Collections.Generic.IEnumerable<KeyValuePair<L,W>> entries) Add the entries from a collection of KeyValuePair<K,V> pairs to this dictionary.

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

Throws
DuplicateNotAllowedException If the input contains duplicate keys or a key already present in this dictionary.
Parameters:
entries:
bool Check() Check the integrity of the internal data structures of this dictionary.
Returns:True if check does not fail.
KeyValuePair<K,V> Choose() Choose some entry in this Dictionary.
Throws
NoSuchItemExceptionif collection is empty.
Returns:
void Clear() Remove all entries from the dictionary
A object Clone()
Returns:
bool Contains(K key) Check if there is an entry with a specified key
Returns:True if key was found
Parameters:
key:The key to look for
bool ContainsAll<H>(System.Collections.Generic.IEnumerable<H> keys)
Returns:
Parameters:
keys:
bool Find(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]".
Returns:True if key was found
Parameters:
key:The key to look for
value:On exit, the value of the entry
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]".
Returns:True if key was found
Parameters:
key:The key to look for
value:On exit, the value of the entry
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.
Returns:True if key was found
Parameters:
key:On entry the key to look for
value:On entry the value to add if the key is not found. On exit the value found if any.
System.Collections.Generic.IEnumerator<KeyValuePair<K,V>> GetEnumerator() Create an enumerator for the collection of entries of the dictionary
Returns:The enumerator
bool Remove(K key) Remove an entry with a given key from the dictionary
Returns:True if an entry was found (and removed)
Parameters:
key:The key of the entry to remove
bool Remove(K key, out V value) Remove an entry with a given key from the dictionary and report its value.
Returns:True if an entry was found (and removed)
Parameters:
key:The key of the entry to remove
value:On exit, the value of the removed entry
bool Show(System.Text.StringBuilder stringbuilder, ref int rest, System.IFormatProvider formatProvider)
Returns:
Parameters:
stringbuilder:
rest:
formatProvider:
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".
Returns:True if key was found
Parameters:
key:The key to look for
value:The new value
bool Update(K key, V value, out V oldvalue)
Returns:
Parameters:
key:
value:
oldvalue:
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.
Returns:True if entry was updated.
Parameters:
key:The key to look for
value:The value to add or replace with.
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.
Returns:
Parameters:
key:
value:
oldvalue: