Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
pluginbase.Helpers.Collections.BiDictionary< T, Q > Class Template Reference

A specialized dictionary that allows either side to be accessed as if it were the key More...

Inheritance diagram for pluginbase.Helpers.Collections.BiDictionary< T, Q >:

Public Member Functions

 BiDictionary ()
 Initialize the class More...
 
 BiDictionary (IDictionary< T, Q > src)
 Initialize the class given an existing dictionary More...
 
Dictionary< T, Q > ToDict ()
 Convert the BiDictionary into a Dictionary More...
 
IEnumerator< KeyValuePair< T, Q > > GetEnumerator ()
 Gets the enumerator. More...
 
void Add (KeyValuePair< T, Q > item)
 Add the specified item. More...
 
void Clear ()
 Clear this instance. More...
 
bool Contains (KeyValuePair< T, Q > item)
 Contains the specified item. More...
 
void CopyTo (KeyValuePair< T, Q >[] array, int arrayIndex)
 Copies to a target array More...
 
bool Remove (KeyValuePair< T, Q > item)
 Remove the specified item. More...
 
void Add (T key, Q value)
 Add the specified key and value. More...
 
bool ContainsKey (T key)
 Containses the key. More...
 
bool ContainsValue (Q value)
 Checks if dictionary contains a given value More...
 
bool Remove (T key)
 Remove the specified key. More...
 
bool Remove (Q value)
 Remove the specified value. More...
 
bool TryGetValue (T key, out Q value)
 Try to get a value by a given key More...
 

Properties

int Count [get]
 Gets the count. More...
 
bool IsReadOnly [get]
 Gets a value indicating whether this instance is read only. More...
 

Detailed Description

A specialized dictionary that allows either side to be accessed as if it were the key

Constructor & Destructor Documentation

pluginbase.Helpers.Collections.BiDictionary< T, Q >.BiDictionary ( )

Initialize the class

19  {
20  }
pluginbase.Helpers.Collections.BiDictionary< T, Q >.BiDictionary ( IDictionary< T, Q >  src)

Initialize the class given an existing dictionary

Parameters
srcSource.
27  {
28  foreach(var kv in src)
29  {
30  Add(kv);
31  }
32  }
void Add(KeyValuePair< T, Q > item)
Add the specified item.
Definition: BiDictionary.cs:70

Member Function Documentation

void pluginbase.Helpers.Collections.BiDictionary< T, Q >.Add ( KeyValuePair< T, Q >  item)

Add the specified item.

<Docs>The item to add to the current collection.</Docs>

Adds an item to the current collection.

To be added.

Exceptions
System.NotSupportedExceptionThe current collection is read-only.
Parameters
itemItem.

Attribute: item.Key

= item.Value;

Attribute: item.Value

= item.Key;

71  {
72  _forward[item.Key] = item.Value;
73  _reverse[item.Value] = item.Key;
74  }
void pluginbase.Helpers.Collections.BiDictionary< T, Q >.Add ( key,
value 
)

Add the specified key and value.

Parameters
keyKey.
valueValue.

Attribute: key

= value;

Attribute: value

= key;

155  {
156  if (_forward.ContainsKey(key) || _reverse.ContainsKey(value))
157  {
158  throw new ArgumentException("Pair key conflict");
159  }
160  _forward[key] = value;
161  _reverse[value] = key;
162  }
void pluginbase.Helpers.Collections.BiDictionary< T, Q >.Clear ( )

Clear this instance.

80  {
81  _forward.Clear();
82  _reverse.Clear();
83  }
bool pluginbase.Helpers.Collections.BiDictionary< T, Q >.Contains ( KeyValuePair< T, Q >  item)

Contains the specified item.

<Docs>The object to locate in the current collection.</Docs>

Determines whether the current collection contains a specific value.

Parameters
itemItem.
92  {
93  Q ele;
94  if (_forward.TryGetValue(item.Key, out ele))
95  {
96  return ele.Equals(item.Value);
97  }
98  return false;
99  }
bool pluginbase.Helpers.Collections.BiDictionary< T, Q >.ContainsKey ( key)

Containses the key.

<Docs>The key to locate in the current instance.</Docs>

Determines whether the current instance contains an entry with the specified key.

Returns
true, if key was containsed, false otherwise.
Parameters
keyKey.
172  {
173  return _forward.ContainsKey(key);
174  }
bool pluginbase.Helpers.Collections.BiDictionary< T, Q >.ContainsValue ( value)

Checks if dictionary contains a given value

Returns
true, if value was containsed, false otherwise.
Parameters
valueValue.
182  {
183  return _reverse.ContainsKey(value);
184  }
void pluginbase.Helpers.Collections.BiDictionary< T, Q >.CopyTo ( KeyValuePair< T, Q >[]  array,
int  arrayIndex 
)

Copies to a target array

Parameters
arrayArray.
arrayIndexArray index.

Attribute: i+arrayIndex

= item;

107  {
108  int i=0;
109  foreach(var item in _forward)
110  {
111  array[i+arrayIndex] = item;
112  ++i;
113  }
114  }
IEnumerator<KeyValuePair<T, Q> > pluginbase.Helpers.Collections.BiDictionary< T, Q >.GetEnumerator ( )

Gets the enumerator.

Returns
The enumerator.
56  {
57  return _forward.GetEnumerator();
58  }
bool pluginbase.Helpers.Collections.BiDictionary< T, Q >.Remove ( KeyValuePair< T, Q >  item)

Remove the specified item.

<Docs>The item to remove from the current collection.</Docs>

Removes the first occurrence of an item from the current collection.

Parameters
itemItem.
123  {
124  return _reverse.Remove(item.Value) && _forward.Remove(item.Key);
125  }
bool pluginbase.Helpers.Collections.BiDictionary< T, Q >.Remove ( key)

Remove the specified key.

<Docs>The item to remove from the current collection.</Docs>

Removes the first occurrence of an item from the current collection.

Parameters
keyKey.
193  {
194  Q val;
195  if (_forward.TryGetValue(key, out val))
196  {
197  _reverse.Remove(val);
198  return _forward.Remove(key);;
199  }
200  return false;
201  }
bool pluginbase.Helpers.Collections.BiDictionary< T, Q >.Remove ( value)

Remove the specified value.

<Docs>The item to remove from the current collection.</Docs>

Removes the first occurrence of an item from the current collection.

Parameters
valueValue.
210  {
211  T key;
212  if (_reverse.TryGetValue(value, out key))
213  {
214  _forward.Remove(key);
215  return _reverse.Remove(value);
216  }
217  return false;
218  }
Dictionary<T,Q> pluginbase.Helpers.Collections.BiDictionary< T, Q >.ToDict ( )

Convert the BiDictionary into a Dictionary

Returns
The dict.
39  {
40  return new Dictionary<T, Q>(_forward);
41  }
bool pluginbase.Helpers.Collections.BiDictionary< T, Q >.TryGetValue ( key,
out Q  value 
)

Try to get a value by a given key

To be added.

Returns
true, if get value was tryed, false otherwise.
Parameters
keyKey.
valueValue.
228  {
229  return _forward.TryGetValue(key, out value);
230  }

Property Documentation

int pluginbase.Helpers.Collections.BiDictionary< T, Q >.Count
get

Gets the count.

The count.

bool pluginbase.Helpers.Collections.BiDictionary< T, Q >.IsReadOnly
get

Gets a value indicating whether this instance is read only.

true if this instance is read only; otherwise, false.


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