PBL - The program base library
C# AvlDictionary and Priority Queue implementation
 All Classes Namespaces Files Functions Properties
Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue > Class Template Reference

AvlDictionary<TKey,TValue> is an implementation of the generic IDictionary<TKey,TValue> interface based on an AVL-tree. The AvlDictionary<TKey,TValue> represents a collection of key/value pairs that are sorted on the key. More...

Inheritance diagram for Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >:
Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.Enumerator Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.Enumerator Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.KeyCollection Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.KeyCollection Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.KeyCollection.CollectionEnumerator Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.KeyCollection.CollectionEnumerator Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.ValueCollection Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.ValueCollection Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.ValueCollection.CollectionEnumerator Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.ValueCollection.CollectionEnumerator

Classes

class  AvlDictionaryBaseEnumerator
 Provides the common base functionality of all Enumerators used with an AvlDictionary<TKey,TValue>. More...
 
class  Enumerator
 Enumerates the elements of an AvlDictionary<TKey,TValue>. More...
 
class  KeyCollection
 Represents the collection of keys in an AvlDictionary<TKey,TValue>. This class cannot be inherited. More...
 
class  ValueCollection
 Represents the collection of values in an AvlDictionary<TKey,TValue>. This class cannot be inherited. More...
 

Public Member Functions

 AvlDictionary ()
 Initializes a new instance of the AvlDictionary<TKey,TValue> class that is empty.
 
 AvlDictionary (IEnumerable< KeyValuePair< TKey, TValue >> dictionary)
 Initializes a new instance of the AvlDictionary<TKey,TValue> class that contains elements copied from the specified System.Collections.Generic.IDictionary<TKey,TValue>.
 
void Add (TKey key, TValue value)
 Adds the specified key and value to the AvlDictionary.
 
bool ContainsKey (TKey key)
 Determines whether the AvlDictionary contains the specified key.
 
bool Remove (TKey key)
 Removes the value with the specified key from the AvlDictionary.
 
bool TryGetValue (TKey key, out TValue value)
 Gets the value associated with the specified key.
 
void Add (KeyValuePair< TKey, TValue > item)
 Adds a KeyValuePair<TKey,TValue> to the AvlDictionary.
 
void Clear ()
 Removes all keys and values from the AvlDictionary.
 
bool Contains (KeyValuePair< TKey, TValue > item)
 Determines whether the AvlDictionary contains a specific KeyValuePair<TKey,TValue>.
 
void CopyTo (KeyValuePair< TKey, TValue >[] array, int index)
 Copies the elements of the AvlDictionary to an existing one-dimensional KeyValuePair<TKey,TValue>[], starting at the specified array index.
 
bool Remove (KeyValuePair< TKey, TValue > item)
 Removes the first occurrence of a specific KeyValuePair<TKey,TValue> from the AvlDictionary.
 
IEnumerator< KeyValuePair
< TKey, TValue > > 
GetEnumerator ()
 Returns an enumerator that iterates through the AvlDictionary.
 
void CopyTo (Array array, int index)
 Copies the elements of the elements of the AvlDictionary to an System.Array, starting at a particular System.Array index.
 

Properties

ICollection< TKey > Keys [get]
 Gets a collection containing the keys in the AvlDictionary.
 
ICollection< TValue > Values [get]
 Gets a collection containing the values in the AvlDictionary.
 
TValue this[TKey key] [get, set]
 Gets or sets the value associated with the specified key.
 
int Count [get]
 Gets the number of elements contained in the AvlDictionary.
 
bool IsReadOnly [get]
 Gets a value indicating whether the AvlDictionary is read-only.
 
bool IsSynchronized [get]
 Gets a value indicating whether access to the AvlDictionary is synchronized (thread safe).
 
object SyncRoot [get]
 Gets an object that can be used to synchronize access to the AvlDictionary.
 

Detailed Description

AvlDictionary<TKey,TValue> is an implementation of the generic IDictionary<TKey,TValue> interface based on an AVL-tree. The AvlDictionary<TKey,TValue> represents a collection of key/value pairs that are sorted on the key.

Template Parameters
TKeyThe type of keys in the dictionary.
TValueThe type of values in the dictionary.
Type Constraints
TKey :IComparable<TKey> 

Definition at line 57 of file AvlDictionary.cs.

Constructor & Destructor Documentation

Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.AvlDictionary ( )

Initializes a new instance of the AvlDictionary<TKey,TValue> class that is empty.

Definition at line 1609 of file AvlDictionary.cs.

Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.AvlDictionary ( IEnumerable< KeyValuePair< TKey, TValue >>  dictionary)

Initializes a new instance of the AvlDictionary<TKey,TValue> class that contains elements copied from the specified System.Collections.Generic.IDictionary<TKey,TValue>.

Parameters
dictionaryThe System.Collections.Generic.IDictionary<TKey,TValue> whose elements are copied to the new AvlDictionary<TKey,TValue>.

This method is an O(N * log N) operation, where N is dictionary.Count.

Exceptions
System.ArgumentNullExceptiondictionary is null.
System.ArgumentExceptiondictionary contains one or more duplicate keys.

Definition at line 1634 of file AvlDictionary.cs.

Member Function Documentation

void Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.Add ( TKey  key,
TValue  value 
)

Adds the specified key and value to the AvlDictionary.

Parameters
keyThe key of the element to add.
valueThe value of the element to add. The value can be null for reference types.

This method is an O(log N) operation, where N is the number of elements in the AvlDictionary.

Exceptions
System.ArgumentNullExceptionkey is null.
System.ArgumentExceptionAn element with the same key already exists in the AvlDictionary.

Definition at line 1668 of file AvlDictionary.cs.

void Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.Add ( KeyValuePair< TKey, TValue >  item)

Adds a KeyValuePair<TKey,TValue> to the AvlDictionary.

Parameters
itemThe KeyValuePair<TKey,TValue> to add to the AvlDictionary.

This method is an O(log N) operation, where N is the number of elements in the AvlDictionary.

Exceptions
System.NotSupportedExceptionThe AvlDictionary is read-only.
System.ArgumentExceptionAn element with the same key already exists in the AvlDictionary.

Definition at line 1900 of file AvlDictionary.cs.

void Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.Clear ( )

Removes all keys and values from the AvlDictionary.

Exceptions
System.NotSupportedExceptionThe AvlDictionary is read-only.

Definition at line 1917 of file AvlDictionary.cs.

bool Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.Contains ( KeyValuePair< TKey, TValue >  item)

Determines whether the AvlDictionary contains a specific KeyValuePair<TKey,TValue>.

Parameters
itemThe KeyValuePair<TKey,TValue> to locate in the AvlDictionary.

This method is an O(log N) operation, where N is the number of elements in the AvlDictionary.

Returns
true if item is found in the AvlDictionary; otherwise, false.

Definition at line 1940 of file AvlDictionary.cs.

bool Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.ContainsKey ( TKey  key)

Determines whether the AvlDictionary contains the specified key.

Parameters
keyThe key to locate in the AvlDictionary.

This method is an O(log N) operation, where N is the number of elements in the AvlDictionary.

Returns
true if the AvlDictionary contains an element with the specified key; otherwise, false.
Exceptions
System.ArgumentNullExceptionkey is null.

Definition at line 1693 of file AvlDictionary.cs.

void Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.CopyTo ( KeyValuePair< TKey, TValue >[]  array,
int  index 
)

Copies the elements of the AvlDictionary to an existing one-dimensional KeyValuePair<TKey,TValue>[], starting at the specified array index.

Parameters
arrayThe one-dimensional KeyValuePair<TKey,TValue>[] that is the destination of the elements copied from AvlDictionary. The array must have zero-based indexing.
indexThe zero-based index in array at which copying begins.
Exceptions
System.ArgumentNullExceptionarray is null.
System.ArgumentOutOfRangeExceptionindex is less than zero.
System.ArgumentExceptionindex is equal to or greater than the length of array. -or- The number of elements in the source AvlDictionary is greater than the available space from index to the end of the destination array.

Definition at line 1974 of file AvlDictionary.cs.

void Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.CopyTo ( Array  array,
int  index 
)

Copies the elements of the elements of the AvlDictionary to an System.Array, starting at a particular System.Array index.

Parameters
arrayThe one-dimensional System.Array that is the destination of the elements copied from AvlDictionary. The System.Array must have zero-based indexing.
indexThe zero-based index in array at which copying begins.
Exceptions
System.ArgumentNullExceptionarray is null.
System.ArgumentOutOfRangeExceptionindex is less than zero.
System.ArgumentExceptionarray is multidimensional. -or- index is equal to or greater than the length of array. -or- The number of elements in the source AvlDictionary is greater than the available space from index to the end of the destination array.

Definition at line 2123 of file AvlDictionary.cs.

IEnumerator<KeyValuePair<TKey, TValue> > Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.GetEnumerator ( )

Returns an enumerator that iterates through the AvlDictionary.

Returns
An IEnumerator<KeyValuePair<TKey, TValue>> enumerator for the AvlDictionary.

Definition at line 2076 of file AvlDictionary.cs.

bool Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.Remove ( TKey  key)

Removes the value with the specified key from the AvlDictionary.

Parameters
keyThe key of the element to remove.

This method is an O(log N) operation, where N is the number of elements in the AvlDictionary.

Returns
true if the element is successfully found and removed; otherwise, false. This method returns false if key is not found in the AvlDictionary.
Exceptions
System.ArgumentNullExceptionkey is null.
System.NotSupportedException"The AvlDictionary is read-only."

Definition at line 1729 of file AvlDictionary.cs.

bool Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.Remove ( KeyValuePair< TKey, TValue >  item)

Removes the first occurrence of a specific KeyValuePair<TKey,TValue> from the AvlDictionary.

Parameters
itemThe KeyValuePair<TKey,TValue> to remove from the AvlDictionary.

This method is an O(log N) operation, where N is the number of elements in the AvlDictionary.

Returns
true if item was successfully removed from the AvlDictionary; otherwise, false. This method also returns false if item is not found in the original AvlDictionary.
Exceptions
System.NotSupportedExceptionThe AvlDictionary is read-only.

Definition at line 2046 of file AvlDictionary.cs.

bool Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.TryGetValue ( TKey  key,
out TValue  value 
)

Gets the value associated with the specified key.

Parameters
keyThe key of the value to get.
valueWhen this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

This method is an O(log N) operation, where N is the number of elements in the AvlDictionary.

Returns
true if the AvlDictionary contains an element with the specified key; otherwise, false.
Exceptions
System.ArgumentNullExceptionkey is null.

Definition at line 1789 of file AvlDictionary.cs.

Property Documentation

int Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.Count
get

Gets the number of elements contained in the AvlDictionary.

Returns
The number of elements contained in the AvlDictionary. Retrieving the value of this property is an O(1) operation.

Definition at line 2014 of file AvlDictionary.cs.

bool Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.IsReadOnly
get

Gets a value indicating whether the AvlDictionary is read-only.

Returns
false.

Definition at line 2025 of file AvlDictionary.cs.

bool Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.IsSynchronized
get

Gets a value indicating whether access to the AvlDictionary is synchronized (thread safe).

Returns
false.

Definition at line 2162 of file AvlDictionary.cs.

ICollection<TKey> Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.Keys
get

Gets a collection containing the keys in the AvlDictionary.

Returns
An ICollection<TKey> containing the keys in the AvlDictionary.

Definition at line 1706 of file AvlDictionary.cs.

object Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.SyncRoot
get

Gets an object that can be used to synchronize access to the AvlDictionary.

Returns
An object that can be used to synchronize access to the AvlDictionary.

Definition at line 2173 of file AvlDictionary.cs.

TValue Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.this[TKey key]
getset

Gets or sets the value associated with the specified key.

Parameters
keyThe key of the value to get or set.

This method is an O(log N) operation, where N is the number of elements in the AvlDictionary.

Returns
The value associated with the specified key. If the specified key is not found, a get operation throws a System.Collections.Generic.KeyNotFoundException, and a set operation creates a new element with the specified key.
Exceptions
System.ArgumentNullExceptionkey is null.
System.Collections.Generic.KeyNotFoundExceptionThe property is retrieved and key does not exist in the collection.
NotSupportedExceptionThe property is set and the AvlDictionary is read-only.

Definition at line 1842 of file AvlDictionary.cs.

ICollection<TValue> Com.Mission_Base.Pbl.AvlDictionary< TKey, TValue >.Values
get

Gets a collection containing the values in the AvlDictionary.

Returns
An ICollection<TValue> containing the values in the AvlDictionary.

Definition at line 1814 of file AvlDictionary.cs.


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