Mercury library  1.0
Translation of CFG grammars into an object model (Bachelor's thesis).
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties
Public Member Functions | Properties | List of all members
Mercury.Nucleus.Collections.ListMultiDictionary< TKey, TValue > Class Template Reference

An implementation of IMultiDictionary{TKey,TValue} using T:System.Collections.Generic.List{T} as an underlying collection of values. More...

Inheritance diagram for Mercury.Nucleus.Collections.ListMultiDictionary< TKey, TValue >:
Mercury.Nucleus.Collections.IMultiDictionary< TKey, TValue > Mercury.Nucleus.Collections.IReadOnlyMultiDictionary< TKey, TValue > Mercury.Nucleus.Collections.UniqueListMultiDictionary< TKey, TValue >

Public Member Functions

 ListMultiDictionary ()
 Default constructor, creates an empty dictionary More...
 
 ListMultiDictionary (IMultiDictionary< TKey, TValue > source)
 Creates a multidictionary initialized by values from another multidictionary. More...
 
TValue GetValue (TKey key, int ix)
 Gets the value from the underlying list. More...
 
int GetValuesCount (TKey key)
 The size of underlying list. More...
 
virtual bool Add (TKey key, TValue value)
 Adds the value to the dictionary. The actual behaviour and handling of duplicities is specified by an implementation. More...
 
virtual bool Add (KeyValuePair< TKey, TValue > pair)
 Adds the value to the dictionary. The actual behaviour and handling of duplicities is specified by an implementation. More...
 
virtual bool Add (TKey key, IEnumerable< TValue > values)
 Adds the collection of values to the dictionary. If the key is already present, NO value is added and false will be returned. More...
 
virtual bool Contains (TKey key, TValue value)
 Indicates whether this collection contains the specified key and value. More...
 
bool ContainsKey (TKey key)
 Indicates whether this collection contains the specified key. More...
 
virtual void Clear ()
 Removes the content of collection. More...
 
bool TryGetValue (TKey key, out IReadOnlyList< TValue > collection)
 Gets the value associated with the specified key. More...
 
IEnumerator< KeyValuePair
< TKey, TValue > > 
GetEnumerator ()
 

Properties

ICollection< TKey > Keys [get]
 
IReadOnlyList< TValue > this[TKey key] [get]
 
- Properties inherited from Mercury.Nucleus.Collections.IReadOnlyMultiDictionary< TKey, TValue >
ICollection< TKey > Keys [get]
 The collection of keys. More...
 
IReadOnlyList< TValue > this[TKey key] [get]
 Gets the collection of values associated with the specified key. More...
 

Detailed Description

An implementation of IMultiDictionary{TKey,TValue} using T:System.Collections.Generic.List{T} as an underlying collection of values.

This implementation of IMultiDictionary{TKey,TValue} DOES allow duplicit (key,value) pairs.

Template Parameters
TKeyThe type of the key.
TValueThe type of the value.

Definition at line 223 of file MultiDictionary.cs.

Constructor & Destructor Documentation

Mercury.Nucleus.Collections.ListMultiDictionary< TKey, TValue >.ListMultiDictionary ( )

Default constructor, creates an empty dictionary

Definition at line 234 of file MultiDictionary.cs.

Mercury.Nucleus.Collections.ListMultiDictionary< TKey, TValue >.ListMultiDictionary ( IMultiDictionary< TKey, TValue >  source)

Creates a multidictionary initialized by values from another multidictionary.

Parameters
sourceSource multidictionary

Definition at line 242 of file MultiDictionary.cs.

Member Function Documentation

virtual bool Mercury.Nucleus.Collections.ListMultiDictionary< TKey, TValue >.Add ( TKey  key,
TValue  value 
)
virtual

Adds the value to the dictionary. The actual behaviour and handling of duplicities is specified by an implementation.

Parameters
keyThe key.
valueThe value.
Returns
true if value added successfully, false otherwise (depends on the implementation).
Exceptions
ArgumentNullExceptionThe key is null.

Implements Mercury.Nucleus.Collections.IMultiDictionary< TKey, TValue >.

Reimplemented in Mercury.Nucleus.Collections.UniqueListMultiDictionary< TKey, TValue >.

Definition at line 264 of file MultiDictionary.cs.

virtual bool Mercury.Nucleus.Collections.ListMultiDictionary< TKey, TValue >.Add ( KeyValuePair< TKey, TValue >  tuple)
virtual

Adds the value to the dictionary. The actual behaviour and handling of duplicities is specified by an implementation.

Parameters
tupleThe tuple of key and value.
Returns
true if value added successfully, false otherwise (depends on the implementation).
Exceptions
ArgumentNullExceptionThe tuple is null.

Implements Mercury.Nucleus.Collections.IMultiDictionary< TKey, TValue >.

Definition at line 275 of file MultiDictionary.cs.

virtual bool Mercury.Nucleus.Collections.ListMultiDictionary< TKey, TValue >.Add ( TKey  key,
IEnumerable< TValue >  values 
)
virtual

Adds the collection of values to the dictionary. If the key is already present, NO value is added and false will be returned.

Parameters
keyThe key.
valuesThe collection of values.
Returns
true if key is not present yet and at least one value was successfully added; false otherwise.
Exceptions
ArgumentNullExceptionThe key is null.

Implements Mercury.Nucleus.Collections.IMultiDictionary< TKey, TValue >.

Definition at line 278 of file MultiDictionary.cs.

virtual void Mercury.Nucleus.Collections.ListMultiDictionary< TKey, TValue >.Clear ( )
virtual
virtual bool Mercury.Nucleus.Collections.ListMultiDictionary< TKey, TValue >.Contains ( TKey  key,
TValue  value 
)
virtual

Indicates whether this collection contains the specified key and value.

Parameters
keyThe key.
valueThe value.
Returns
true if this collection contains the given key and value.

Implements Mercury.Nucleus.Collections.IReadOnlyMultiDictionary< TKey, TValue >.

Reimplemented in Mercury.Nucleus.Collections.UniqueListMultiDictionary< TKey, TValue >.

Definition at line 286 of file MultiDictionary.cs.

bool Mercury.Nucleus.Collections.ListMultiDictionary< TKey, TValue >.ContainsKey ( TKey  key)

Indicates whether this collection contains the specified key.

Parameters
keyThe key.
Returns
true if the collection contains the key, false otherwise.
Exceptions
ArgumentNullExceptionThe key is null.

Implements Mercury.Nucleus.Collections.IReadOnlyMultiDictionary< TKey, TValue >.

Definition at line 295 of file MultiDictionary.cs.

IEnumerator<KeyValuePair<TKey, TValue> > Mercury.Nucleus.Collections.ListMultiDictionary< TKey, TValue >.GetEnumerator ( )

Definition at line 320 of file MultiDictionary.cs.

TValue Mercury.Nucleus.Collections.ListMultiDictionary< TKey, TValue >.GetValue ( TKey  key,
int  ix 
)

Gets the value from the underlying list.

Parameters
keyThe key of the list.
ixThe index of the value.
Returns
The element at position ix.

Definition at line 251 of file MultiDictionary.cs.

int Mercury.Nucleus.Collections.ListMultiDictionary< TKey, TValue >.GetValuesCount ( TKey  key)

The size of underlying list.

Parameters
keyThe key of the list.
Returns
Count of elements of the list.

Definition at line 257 of file MultiDictionary.cs.

bool Mercury.Nucleus.Collections.ListMultiDictionary< TKey, TValue >.TryGetValue ( TKey  key,
out IReadOnlyList< TValue >  collection 
)

Gets the value associated with the specified key.

Parameters
keyThe key.
collectionWhen this method returns true, this fuek contains the values associated with the given key, otherwise it is set to null.
Returns
true if the key was found, false otherwise

Implements Mercury.Nucleus.Collections.IReadOnlyMultiDictionary< TKey, TValue >.

Definition at line 301 of file MultiDictionary.cs.

Property Documentation

ICollection<TKey> Mercury.Nucleus.Collections.ListMultiDictionary< TKey, TValue >.Keys
get

Definition at line 311 of file MultiDictionary.cs.

IReadOnlyList<TValue> Mercury.Nucleus.Collections.ListMultiDictionary< TKey, TValue >.this[TKey key]
get

Definition at line 314 of file MultiDictionary.cs.


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