Click or drag to resize
OrderedDictionaryTKey, TValue Class
OrderedDictionary<TKey, TValue> is a collection that maps keys of type TKey to values of type TValue. The keys are maintained in a sorted order, and at most one value is permitted for each key.
Inheritance Hierarchy
SystemObject
  X3Platform.CollectionsCollectionBaseKeyValuePairTKey, TValue
    X3Platform.CollectionsDictionaryBaseTKey, TValue
      X3Platform.CollectionsOrderedDictionaryTKey, TValue

Namespace: X3Platform.Collections
Assembly: X3Platform.Support (in X3Platform.Support.dll) Version: 1.0.0.0 (2.0.0.0)
Syntax
[SerializableAttribute]
public class OrderedDictionary<TKey, TValue> : DictionaryBase<TKey, TValue>, 
	ICloneable

Type Parameters

TKey

[Missing <typeparam name="TKey"/> documentation for "T:X3Platform.Collections.OrderedDictionary`2"]

TValue

[Missing <typeparam name="TValue"/> documentation for "T:X3Platform.Collections.OrderedDictionary`2"]

The OrderedDictionaryTKey, TValue type exposes the following members.

Constructors
  NameDescription
Public methodOrderedDictionaryTKey, TValue
Creates a new OrderedDictionary. The TKey must implemented IComparable<TKey> or IComparable. The CompareTo method of this interface will be used to compare keys in this dictionary.
Public methodOrderedDictionaryTKey, TValue(IComparerTKey)
Creates a new OrderedDictionary. The Compare method of the passed comparison object will be used to compare keys in this dictionary.
Public methodOrderedDictionaryTKey, TValue(IEnumerableKeyValuePairTKey, TValue)

Creates a new OrderedDictionary. The TKey must implemented IComparable<TKey> or IComparable. The CompareTo method of this interface will be used to compare keys in this dictionary.

A collection and keys and values (typically another dictionary) is used to initialized the contents of the dictionary.

Public methodOrderedDictionaryTKey, TValue(ComparisonTKey)
Creates a new OrderedDictionary. The passed delegate will be used to compare keys in this dictionary.
Public methodOrderedDictionaryTKey, TValue(IEnumerableKeyValuePairTKey, TValue, IComparerTKey)

Creates a new OrderedDictionary. The Compare method of the passed comparison object will be used to compare keys in this dictionary.

A collection and keys and values (typically another dictionary) is used to initialized the contents of the dictionary.

Public methodOrderedDictionaryTKey, TValue(IEnumerableKeyValuePairTKey, TValue, ComparisonTKey)

Creates a new OrderedDictionary. The passed delegate will be used to compare keys in this dictionary.

A collection and keys and values (typically another dictionary) is used to initialized the contents of the dictionary.

Top
Methods
  NameDescription
Public methodAdd(KeyValuePairTKey, TValue)
Adds a key-value pair to the collection. This implementation calls the Add method with the Key and Value from the item.
(Inherited from DictionaryBaseTKey, TValue.)
Public methodAdd(TKey, TValue)
Adds a new key and value to the dictionary. If the dictionary already contains a key equal to the passed key, then an ArgumentException is thrown
(Overrides DictionaryBaseTKey, TValueAdd(TKey, TValue).)
Public methodAddMany
Adds multiple key-value pairs to a dictionary. If a key exists in both the current instance and dictionaryToAdd, then the value is updated with the value from keysAndValues> (no exception is thrown). Since IDictionary<TKey,TValue> inherits from IEnumerable<KeyValuePair<TKey,TValue>>, this method can be used to merge one dictionary into another.
Public methodAsReadOnly
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.
(Inherited from DictionaryBaseTKey, TValue.)
Public methodClear
Removes all keys and values from the dictionary.
(Overrides DictionaryBaseTKey, TValueClear.)
Public methodClone
Makes a shallow clone of this dictionary; i.e., if keys or values of the dictionary are reference types, then they are not cloned. If TKey or TValue is a value type, then each element is copied as if by simple assignment.
Public methodCloneContents
Makes a deep clone of this dictionary. A new dictionary is created with a clone of each entry of this dictionary, by calling ICloneable.Clone on each element. If TKey or TValue is a value type, then each element is copied as if by simple assignment.
Public methodContains
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.
(Inherited from DictionaryBaseTKey, TValue.)
Public methodContainsKey
Determines if this dictionary contains a key equal to key. The dictionary is not changed.
(Overrides DictionaryBaseTKey, TValueContainsKey(TKey).)
Public methodConvertAllTOutput
Convert this collection of items by applying a delegate to each item in the collection. The resulting enumeration contains the result of applying converter to each item in this collection, in order.
(Inherited from CollectionBaseT.)
Public methodCopyTo
Copies all the items in the collection into an array. Implemented by using the enumerator returned from GetEnumerator to get all the items and copy them to the provided array.
(Inherited from CollectionBaseT.)
Public methodCountWhere
Counts the number of items in the collection that satisfy the condition defined by predicate.
(Inherited from CollectionBaseT.)
Public methodEquals (Inherited from Object.)
Public methodExists
Determines if the collection contains any item that satisfies the condition defined by predicate.
(Inherited from CollectionBaseT.)
Protected methodFinalize (Inherited from Object.)
Public methodFindAll
Enumerates the items in the collection that satisfy the condition defined by predicate.
(Inherited from CollectionBaseT.)
Public methodForEach
Performs the specified action on each item in this collection.
(Inherited from CollectionBaseT.)
Public methodGetEnumerator
Returns an enumerator that enumerates all the entries in the dictionary. Each entry is returned as a KeyValuePair<TKey,TValue>. The entries are enumerated in the sorted order of the keys.
(Overrides CollectionBaseTGetEnumerator.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodGetValueElseAdd
Finds a key in the dictionary. If the dictionary already contains a key equal to the passed key, then the existing value is returned via value. If the dictionary doesn't contain that key, then value is associated with that key.
Protected methodMemberwiseClone (Inherited from Object.)
Public methodRange
Returns a collection that can be used for enumerating some of the keys and values in the collection. Only keys that are greater than from and less than to are included. The keys are enumerated in sorted order. Keys equal to the end points of the range can be included or excluded depending on the fromInclusive and toInclusive parameters.
Public methodRangeFrom
Returns a collection that can be used for enumerating some of the keys and values in the collection. Only keys that are greater than (and optionally, equal to) from are included. The keys are enumerated in sorted order. Keys equal to from can be included or excluded depending on the fromInclusive parameter.
Public methodRangeTo
Returns a collection that can be used for enumerating some of the keys and values in the collection. Only items that are less than (and optionally, equal to) to are included. The items are enumerated in sorted order. Items equal to to can be included or excluded depending on the toInclusive parameter.
Public methodRemove(KeyValuePairTKey, TValue)
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.
(Inherited from DictionaryBaseTKey, TValue.)
Public methodRemove(TKey)
Removes the key (and associated value) from the collection that is equal to the passed in key. If no key in the dictionary is equal to the passed key, false is returned and the dictionary is unchanged.
(Overrides DictionaryBaseTKey, TValueRemove(TKey).)
Public methodRemoveAll
Removes all the items in the collection that satisfy the condition defined by predicate.
(Inherited from CollectionBaseT.)
Public methodRemoveMany
Removes all the keys found in another collection (such as an array or List<TKey>). Each key in keyCollectionToRemove is removed from the dictionary. Keys that are not present are ignored.
Public methodReplace
Changes the value associated with a given key. If the dictionary does not contain a key equal to the passed key, then an ArgumentException is thrown.
Public methodReversed
Returns a View collection that can be used for enumerating the keys and values in the collection in reversed order.
Public methodToArray
Creates an array of the correct size, and copies all the items in the collection into the array, by calling CopyTo.
(Inherited from CollectionBaseT.)
Public methodToString
Shows the string representation of the dictionary. The string representation contains a list of the mappings in the dictionary.
(Inherited from DictionaryBaseTKey, TValue.)
Public methodTrueForAll
Determines if all of the items in the collection satisfy the condition defined by predicate.
(Inherited from CollectionBaseT.)
Public methodTryGetValue
Determines if this dictionary contains a key equal to key. If so, the value associated with that key is returned through the value parameter.
(Overrides DictionaryBaseTKey, TValueTryGetValue(TKey, TValue).)
Top
Properties
  NameDescription
Public propertyComparer
Returns the IComparer<T> used to compare keys in this dictionary.
Public propertyCount
Returns the number of keys in the dictionary.
(Overrides CollectionBaseTCount.)
Public propertyItem
Gets or sets the value associated with a given key. When getting a value, if this key is not found in the collection, then an ArgumentException is thrown. When setting a value, the value replaces any existing value in the dictionary.
(Overrides DictionaryBaseTKey, TValueItemTKey.)
Public propertyKeys
Returns a collection of the keys in this dictionary.
(Inherited from DictionaryBaseTKey, TValue.)
Public propertyValues
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.
(Inherited from DictionaryBaseTKey, TValue.)
Top
Remarks

The keys are compared in one of three ways. If TKey implements IComparable<TKey> or IComparable, then the CompareTo method of that interface will be used to compare elements. Alternatively, a comparison function can be passed in either as a delegate, or as an instance of IComparer<TKey>.

OrderedDictionary is implemented as a balanced binary tree. Inserting, deleting, and looking up an an element all are done in log(N) type, where N is the number of keys in the tree.

DictionaryTKey, TValue is similar, but uses hashing instead of comparison, and does not maintain the keys in sorted order.

See Also