NetTopologySuite
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
Wintellect.PowerCollections.DictionaryBase< TKey, TValue > Class Template Referenceabstract

DictionaryBase is a base class that can be used to more easily implement the generic IDictionary<T> and non-generic IDictionary interfaces. More...

Inheritance diagram for Wintellect.PowerCollections.DictionaryBase< TKey, TValue >:
Wintellect.PowerCollections.CollectionBase< T > Wintellect.PowerCollections.OrderedDictionary< TKey, TValue > Wintellect.PowerCollections.OrderedDictionary< TKey, TValue >.View

Public Member Functions

abstract override void Clear ()
 Clears the dictionary. This method must be overridden in the derived class. More...
 
abstract bool Remove (TKey key)
 Removes a key from the dictionary. This method must be overridden in the derived class. More...
 
abstract bool TryGetValue (TKey key, out TValue value)
 Determines if this dictionary contains a key equal to key . If so, the value associated with that key is returned through the value parameter. This method must be overridden by the derived class. More...
 
virtual void Add (TKey key, TValue value)
 Adds a new key-value pair to the dictionary. More...
 
virtual bool ContainsKey (TKey key)
 Determines whether a given key is found in the dictionary. More...
 
override string ToString ()
 Shows the string representation of the dictionary. The string representation contains a list of the mappings in the dictionary. More...
 
virtual new IDictionary< TKey,
TValue > 
AsReadOnly ()
 Provides a read-only view of this dictionary. The returned IDictionary<TKey,TValue> provides a view of the dictionary that prevents modifications to the dictionary. Use the method to provide access to the dictionary without allowing changes. Since the returned object is just a view, changes to the dictionary will be reflected in the view. More...
 
override void Add (KeyValuePair< TKey, TValue > item)
 Adds a key-value pair to the collection. This implementation calls the Add method with the Key and Value from the item. More...
 
override bool Contains (KeyValuePair< TKey, TValue > item)
 Determines if a dictionary contains a given KeyValuePair. This implementation checks to see if the dictionary contains the given key, and if the value associated with the key is equal to (via object.Equals) the value. More...
 
override bool Remove (KeyValuePair< TKey, TValue > item)
 Determines if a dictionary contains a given KeyValuePair, and if so, removes it. This implementation checks to see if the dictionary contains the given key, and if the value associated with the key is equal to (via object.Equals) the value. If so, the key-value pair is removed. More...
 
- Public Member Functions inherited from Wintellect.PowerCollections.CollectionBase< T >
override string ToString ()
 Shows the string representation of the collection. The string representation contains a list of the items in the collection. Contained collections (except string) are expanded recursively. More...
 

Protected Member Functions

 DictionaryBase ()
 Creates a new DictionaryBase. More...
 
- Protected Member Functions inherited from Wintellect.PowerCollections.CollectionBase< T >
 CollectionBase ()
 Creates a new CollectionBase. More...
 

Properties

virtual TValue this[TKey key] [get, set]
 The indexer of the dictionary. This is used to store keys and values and retrieve values from the dictionary. The setter accessor must be overridden in the derived class. More...
 
virtual ICollection< TKey > Keys [get]
 Returns a collection of the keys in this dictionary. More...
 
virtual ICollection< TValue > Values [get]
 Returns a collection of the values in this dictionary. The ordering of values in this collection is the same as that in the Keys collection. More...
 

Detailed Description

DictionaryBase is a base class that can be used to more easily implement the generic IDictionary<T> and non-generic IDictionary interfaces.

To use DictionaryBase as a base class, the derived class must override Count, GetEnumerator, TryGetValue, Clear, Remove, and the indexer set accessor.

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

Constructor & Destructor Documentation

Wintellect.PowerCollections.DictionaryBase< TKey, TValue >.DictionaryBase ( )
protected

Creates a new DictionaryBase.

Member Function Documentation

virtual void Wintellect.PowerCollections.DictionaryBase< TKey, TValue >.Add ( TKey  key,
TValue  value 
)
virtual

Adds a new key-value pair to the dictionary.

The default implementation of this method checks to see if the key already exists using ContainsKey, then calls the indexer setter if the key doesn't already exist.

Parameters
keyKey to add.
valueValue to associated with the key.
Exceptions
ArgumentExceptionkey is already present in the dictionary

Reimplemented in Wintellect.PowerCollections.OrderedDictionary< TKey, TValue >.

override void Wintellect.PowerCollections.DictionaryBase< TKey, TValue >.Add ( KeyValuePair< TKey, TValue >  item)

Adds a key-value pair to the collection. This implementation calls the Add method with the Key and Value from the item.

Parameters
itemA KeyValuePair contains the Key and Value to add.
virtual new IDictionary<TKey,TValue> Wintellect.PowerCollections.DictionaryBase< TKey, TValue >.AsReadOnly ( )
virtual

Provides a read-only view of this dictionary. The returned IDictionary<TKey,TValue> provides a view of the dictionary that prevents modifications to the dictionary. Use the method to provide access to the dictionary without allowing changes. Since the returned object is just a view, changes to the dictionary will be reflected in the view.

Returns
An IIDictionary<TKey,TValue> that provides read-only access to the dictionary.
abstract override void Wintellect.PowerCollections.DictionaryBase< TKey, TValue >.Clear ( )
pure virtual

Clears the dictionary. This method must be overridden in the derived class.

Implemented in Wintellect.PowerCollections.OrderedDictionary< TKey, TValue >.View, and Wintellect.PowerCollections.OrderedDictionary< TKey, TValue >.

override bool Wintellect.PowerCollections.DictionaryBase< TKey, TValue >.Contains ( KeyValuePair< TKey, TValue >  item)

Determines if a dictionary contains a given KeyValuePair. This implementation checks to see if the dictionary contains the given key, and if the value associated with the key is equal to (via object.Equals) the value.

Parameters
itemA KeyValuePair containing the Key and Value to check for.
Returns
virtual bool Wintellect.PowerCollections.DictionaryBase< TKey, TValue >.ContainsKey ( TKey  key)
virtual

Determines whether a given key is found in the dictionary.

The default implementation simply calls TryGetValue and returns what it returns.

Parameters
keyKey to look for in the dictionary.
Returns
True if the key is present in the dictionary.

Reimplemented in Wintellect.PowerCollections.OrderedDictionary< TKey, TValue >.View, and Wintellect.PowerCollections.OrderedDictionary< TKey, TValue >.

abstract bool Wintellect.PowerCollections.DictionaryBase< TKey, TValue >.Remove ( TKey  key)
pure virtual

Removes a key from the dictionary. This method must be overridden in the derived class.

Parameters
keyKey to remove from the dictionary.
Returns
True if the key was found, false otherwise.

Implemented in Wintellect.PowerCollections.OrderedDictionary< TKey, TValue >.View, and Wintellect.PowerCollections.OrderedDictionary< TKey, TValue >.

override bool Wintellect.PowerCollections.DictionaryBase< TKey, TValue >.Remove ( KeyValuePair< TKey, TValue >  item)

Determines if a dictionary contains a given KeyValuePair, and if so, removes it. This implementation checks to see if the dictionary contains the given key, and if the value associated with the key is equal to (via object.Equals) the value. If so, the key-value pair is removed.

Parameters
itemA KeyValuePair containing the Key and Value to check for.
Returns
True if the item was found and removed. False otherwise.
override string Wintellect.PowerCollections.DictionaryBase< TKey, TValue >.ToString ( )

Shows the string representation of the dictionary. The string representation contains a list of the mappings in the dictionary.

Returns
The string representation of the dictionary.
abstract bool Wintellect.PowerCollections.DictionaryBase< TKey, TValue >.TryGetValue ( TKey  key,
out TValue  value 
)
pure virtual

Determines if this dictionary contains a key equal to key . If so, the value associated with that key is returned through the value parameter. This method must be overridden by the derived class.

Parameters
keyThe key to search for.
valueReturns the value associated with key, if true was returned.
Returns
True if the dictionary contains key. False if the dictionary does not contain key.

Implemented in Wintellect.PowerCollections.OrderedDictionary< TKey, TValue >.View, and Wintellect.PowerCollections.OrderedDictionary< TKey, TValue >.

Property Documentation

virtual ICollection<TKey> Wintellect.PowerCollections.DictionaryBase< TKey, TValue >.Keys
get

Returns a collection of the keys in this dictionary.

A read-only collection of the keys in this dictionary.

virtual TValue Wintellect.PowerCollections.DictionaryBase< TKey, TValue >.this[TKey key]
getset

The indexer of the dictionary. This is used to store keys and values and retrieve values from the dictionary. The setter accessor must be overridden in the derived class.

Parameters
keyKey to find in the dictionary.
Returns
The value associated with the key.
Exceptions
KeyNotFoundExceptionThrown from the get accessor if the key was not found in the dictionary.
virtual ICollection<TValue> Wintellect.PowerCollections.DictionaryBase< TKey, TValue >.Values
get

Returns a collection of the values in this dictionary. The ordering of values in this collection is the same as that in the Keys collection.

A read-only collection of the values in this dictionary.


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