CVB.Net 14.0
ReadOnlyDictionaryBase< TKey, TValue > Class Template Reference

Base class for read-only, generic collection of key/value pairs. More...

Inherits IDictionary< TKey, TValue >.

Inherited by ReadOnlyDictionary< TKey, TValue >.

Public Member Functions

virtual bool ContainsKey (TKey key)
 Determines whether the key is in this collection. More...
 
virtual bool TryGetValue (TKey key, out TValue value)
 Retrieves the value that is associated with the specific key . More...
 

Protected Member Functions

 ReadOnlyDictionaryBase (IDictionary< TKey, TValue > dictionary)
 Creates a new ReadOnlyDictionary wrapping the given dictionary . More...
 
virtual bool Contains (KeyValuePair< TKey, TValue > item)
 Determines whether the item is in this collection. More...
 
virtual void CopyTo (KeyValuePair< TKey, TValue >[] array, int arrayIndex)
 Copies the entire collection to a compatible one-dimensional array , starting at the specified arrayIndex . More...
 
virtual IEnumerator< KeyValuePair< TKey, TValue > > GetEnumerator ()
 Returns an enumerator that iterates through this collection. More...
 

Properties

IDictionary< TKey, TValue > Dictionary [get]
 Gets the wrapped dictionary.
 
virtual TValue this[TKey key] [get]
 Gets the element that has the specified key . More...
 
int Count [get]
 Gets the number of items in the dictionary.
 
virtual ICollection< TKey > Keys [get]
 Gets a read-only collection of all keys in this dictionary.
 
virtual ICollection< TValue > Values [get]
 Gets a read-only collection of all values in this dictionary.
 

Detailed Description

Base class for read-only, generic collection of key/value pairs.

This class wraps another dictionary as a read-only view on it.

Template Parameters
TKeyType of keys in the dictionary.
TValueType of values in the dictionary.

Constructor & Destructor Documentation

◆ ReadOnlyDictionaryBase()

ReadOnlyDictionaryBase ( IDictionary< TKey, TValue >  dictionary)
protected

Creates a new ReadOnlyDictionary wrapping the given dictionary .

Parameters
dictionaryDictionary to wrap.
Exceptions
ArgumentNullExceptiondictionary is null.

Member Function Documentation

◆ Contains()

virtual bool Contains ( KeyValuePair< TKey, TValue >  item)
protectedvirtual

Determines whether the item is in this collection.

Parameters
itemKey/value pair to locate.
Returns
true if item could be located; false if not.

◆ ContainsKey()

virtual bool ContainsKey ( TKey  key)
virtual

Determines whether the key is in this collection.

Parameters
keyKey of element to locate.
Returns
true if key could be located; false if not.

◆ CopyTo()

virtual void CopyTo ( KeyValuePair< TKey, TValue >[]  array,
int  arrayIndex 
)
protectedvirtual

Copies the entire collection to a compatible one-dimensional array , starting at the specified arrayIndex .

Parameters
arrayDestination array.
arrayIndexZero-based index at which copying begins.
Exceptions
ArgumentNullExceptionarray is null.
ArgumentOutOfRangeExceptionarrayIndex is less than zero.
ArgumentExceptionThe number of elements in this collection is greater than the available space in array .

◆ GetEnumerator()

virtual IEnumerator< KeyValuePair< TKey, TValue > > GetEnumerator ( )
protectedvirtual

Returns an enumerator that iterates through this collection.

Returns
Enumerator object.

Reimplemented in NodeMapDictionary, and NodeMap.

◆ TryGetValue()

virtual bool TryGetValue ( TKey  key,
out TValue  value 
)
virtual

Retrieves the value that is associated with the specific key .

Parameters
keyKey whose value will be retrieved.
valueVariable to be assigned with the object of the specified key , if the key is found. Otherwise the default value of TValue is assigned.
Returns
true if this collection contains the specified key ; false otherwise.

Property Documentation

◆ this[TKey key]

virtual TValue this[TKey key]
get

Gets the element that has the specified key .

Parameters
keyKey of element to get.
Returns
Element that has the specified key .
Exceptions
ArgumentNullExceptionkey is null.
KeyNotFoundExceptionkey is not found.