SoftUni.Wintellect.PowerCollections The BinaryPredicate delegate type encapsulates a method that takes two items of the same type, and returns a boolean value representating some relationship between them. For example, checking whether two items are equal or equivalent is one kind of binary predicate. The first item. The second item. Whether item1 and item2 satisfy the relationship that the BinaryPredicate defines. Algorithms contains a number of static methods that implement algorithms that work on collections. Most of the methods deal with the standard generic collection interfaces such as IEnumerable<T>, ICollection<T> and IList<T>. The class that is used to implement IList<T> to view a sub-range of a list. The object stores a wrapped list, and a start/count indicating a sub-range of the list. Insertion/deletions through the sub-range view cause the count to change also; insertions and deletions directly on the wrapped list do not. Create a sub-range view object on the indicate part of the list. List to wrap. The start index of the view in the wrapped list. The number of items in the view. Returns a view onto a sub-range of a list. Items from are not copied; the returned IList<T> is simply a different view onto the same underlying items. Changes to are reflected in the view, and vice versa. Insertions and deletions in the view change the size of the view, but insertions and deletions in the underlying list do not. This method can be used to apply an algorithm to a portion of a list. For example: Algorithms.ReverseInPlace(Algorithms.Range(list, 3, 6)) will reverse the 6 items beginning at index 3. The type of the items in the list. The list to view. The starting index of the view. The number of items in the view. A list that is a view onto the given sub-list. is null. or is negative. + is greater than the size of . The class that is used to implement IList<T> to view a sub-range of an array. The object stores a wrapped array, and a start/count indicating a sub-range of the array. Insertion/deletions through the sub-range view cause the count to change up to the size of the underlying array. Elements fall off the end of the underlying array. Create a sub-range view object on the indicate part of the array. Array to wrap. The start index of the view in the wrapped list. The number of items in the view. Returns a view onto a sub-range of an array. Items from are not copied; the returned IList<T> is simply a different view onto the same underlying items. Changes to are reflected in the view, and vice versa. Insertions and deletions in the view change the size of the view. After an insertion, the last item in "falls off the end". After a deletion, the last item in array becomes the default value (0 or null). This method can be used to apply an algorithm to a portion of a array. For example: Algorithms.ReverseInPlace(Algorithms.Range(array, 3, 6)) will reverse the 6 items beginning at index 3. The array to view. The starting index of the view. The number of items in the view. A list that is a view onto the given sub-array. is null. or is negative. + is greater than the size of . The read-only ICollection<T> implementation that is used by the ReadOnly method. Methods that modify the collection throw a NotSupportedException, methods that don't modify are fowarded through to the wrapped collection. Create a ReadOnlyCollection wrapped around the given collection. Collection to wrap. Throws an NotSupportedException stating that this collection cannot be modified. Returns a read-only view onto a collection. The returned ICollection<T> interface only allows operations that do not change the collection: GetEnumerator, Contains, CopyTo, Count. The ReadOnly property returns false, indicating that the collection is read-only. All other methods on the interface throw a NotSupportedException. The data in the underlying collection is not copied. If the underlying collection is changed, then the read-only view also changes accordingly. The type of items in the collection. The collection to wrap. A read-only view onto . If is null, then null is returned. The read-only IList<T> implementation that is used by the ReadOnly method. Methods that modify the list throw a NotSupportedException, methods that don't modify are fowarded through to the wrapped list. Create a ReadOnlyList wrapped around the given list. List to wrap. Throws an NotSupportedException stating that this collection cannot be modified. Returns a read-only view onto a list. The returned IList<T> interface only allows operations that do not change the list: GetEnumerator, Contains, CopyTo, Count, IndexOf, and the get accessor of the indexer. The IsReadOnly property returns true, indicating that the list is read-only. All other methods on the interface throw a NotSupportedException. The data in the underlying list is not copied. If the underlying list is changed, then the read-only view also changes accordingly. The type of items in the list. The list to wrap. A read-only view onto . Returns null if is null. If is already read-only, returns . The private class that implements a read-only wrapped for IDictionary <TKey,TValue>. Create a read-only dictionary wrapped around the given dictionary. The IDictionary<TKey,TValue> to wrap. Throws an NotSupportedException stating that this collection cannot be modified. Returns a read-only view onto a dictionary. The returned IDictionary<TKey,TValue> interface only allows operations that do not change the dictionary. The IsReadOnly property returns true, indicating that the dictionary is read-only. All other methods on the interface throw a NotSupportedException. The data in the underlying dictionary is not copied. If the underlying dictionary is changed, then the read-only view also changes accordingly. The dictionary to wrap. A read-only view onto . Returns null if is null. If is already read-only, returns . The class that provides a typed IEnumerator<T> view onto an untyped IEnumerator interface. Create a typed IEnumerator<T> view onto an untyped IEnumerator interface IEnumerator to wrap. The class that provides a typed IEnumerable<T> view onto an untyped IEnumerable interface. Create a typed IEnumerable<T> view onto an untyped IEnumerable interface. IEnumerable interface to wrap. Given a non-generic IEnumerable interface, wrap a generic IEnumerable<T> interface around it. The generic interface will enumerate the same objects as the underlying non-generic collection, but can be used in places that require a generic interface. The underlying non-generic collection must contain only items that are of type or a type derived from it. This method is useful when interfacing older, non-generic collections to newer code that uses generic interfaces. Some collections implement both generic and non-generic interfaces. For efficiency, this method will first attempt to cast to IEnumerable<T>. If that succeeds, it is returned; otherwise, a wrapper object is created. The item type of the wrapper collection. An untyped collection. This collection should only contain items of type or a type derived from it. A generic IEnumerable<T> wrapper around . If is null, then null is returned. The class that provides a typed ICollection<T> view onto an untyped ICollection interface. The ICollection<T> is read-only. Create a typed ICollection<T> view onto an untyped ICollection interface. ICollection interface to wrap. Throws an NotSupportedException stating that this collection cannot be modified. Given a non-generic ICollection interface, wrap a generic ICollection<T> interface around it. The generic interface will enumerate the same objects as the underlying non-generic collection, but can be used in places that require a generic interface. The underlying non-generic collection must contain only items that are of type or a type derived from it. This method is useful when interfacing older, non-generic collections to newer code that uses generic interfaces. Some collections implement both generic and non-generic interfaces. For efficiency, this method will first attempt to cast to ICollection<T>. If that succeeds, it is returned; otherwise, a wrapper object is created. Unlike the generic interface, the non-generic ICollection interfaces does not contain methods for adding or removing items from the collection. For this reason, the returned ICollection<T> will be read-only. The item type of the wrapper collection. An untyped collection. This collection should only contain items of type or a type derived from it. A generic ICollection<T> wrapper around . If is null, then null is returned. The class used to create a typed IList<T> view onto an untype IList interface. Create a typed IList<T> view onto an untype IList interface. The IList to wrap. Given a non-generic IList interface, wrap a generic IList<T> interface around it. The generic interface will enumerate the same objects as the underlying non-generic list, but can be used in places that require a generic interface. The underlying non-generic list must contain only items that are of type or a type derived from it. This method is useful when interfacing older, non-generic lists to newer code that uses generic interfaces. Some collections implement both generic and non-generic interfaces. For efficiency, this method will first attempt to cast to IList<T>. If that succeeds, it is returned; otherwise, a wrapper object is created. The item type of the wrapper list. An untyped list. This list should only contain items of type or a type derived from it. A generic IList<T> wrapper around . If is null, then null is returned. The class that is used to provide an untyped ICollection view onto a typed ICollection<T> interface. Create an untyped ICollection view onto a typed ICollection<T> interface. The ICollection<T> to wrap. Given a generic ICollection<T> interface, wrap a non-generic (untyped) ICollection interface around it. The non-generic interface will contain the same objects as the underlying generic collection, but can be used in places that require a non-generic interface. This method is useful when interfacing generic interfaces with older code that uses non-generic interfaces. Many generic collections already implement the non-generic interfaces directly. This method will first attempt to simply cast to ICollection. If that succeeds, it is returned; if it fails, then a wrapper object is created. The item type of the underlying collection. A typed collection to wrap. A non-generic ICollection wrapper around . If is null, then null is returned. The class that implements a non-generic IList wrapper around a generic IList<T> interface. Create a non-generic IList wrapper around a generic IList<T> interface. The IList<T> interface to wrap. Convert the given parameter to T. Throw an ArgumentException if it isn't. parameter name parameter value Given a generic IList<T> interface, wrap a non-generic (untyped) IList interface around it. The non-generic interface will contain the same objects as the underlying generic list, but can be used in places that require a non-generic interface. This method is useful when interfacing generic interfaces with older code that uses non-generic interfaces. Many generic collections already implement the non-generic interfaces directly. This method will first attempt to simply cast to IList. If that succeeds, it is returned; if it fails, then a wrapper object is created. The item type of the underlying list. A typed list to wrap. A non-generic IList wrapper around . If is null, then null is returned. The class that is used to implement IList<T> to view an array in a read-write way. Insertions cause the last item in the array to fall off, deletions replace the last item with the default value. Create a list wrapper object on an array. Array to wrap. Return true, to indicate that the list is fixed size. Creates a read-write IList<T> wrapper around an array. When an array is implicitely converted to an IList<T>, changes to the items in the array cannot be made through the interface. This method creates a read-write IList<T> wrapper on an array that can be used to make changes to the array. Use this method when you need to pass an array to an algorithms that takes an IList<T> and that tries to modify items in the list. Algorithms in this class generally do not need this method, since they have been design to operate on arrays even when they are passed as an IList<T>. Since arrays cannot be resized, inserting an item causes the last item in the array to be automatically removed. Removing an item causes the last item in the array to be replaced with a default value (0 or null). Clearing the list causes all the items to be replaced with a default value. The array to wrap. An IList<T> wrapper onto . Replace all items in a collection equal to a particular value with another values, yielding another collection. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. The collection to process. The value to find and replace within . The new value to replace with. An new collection with the items from , in the same order, with the appropriate replacements made. Replace all items in a collection equal to a particular value with another values, yielding another collection. A passed IEqualityComparer is used to determine equality. The collection to process. The value to find and replace within . The new value to replace with. The IEqualityComparer<T> used to compare items for equality. Only the Equals method will be called. An new collection with the items from , in the same order, with the appropriate replacements made. Replace all items in a collection that a predicate evalues at true with a value, yielding another collection. . The collection to process. The predicate used to evaluate items with the collection. If the predicate returns true for a particular item, the item is replaces with . The new value to replace with. An new collection with the items from , in the same order, with the appropriate replacements made. Replace all items in a list or array equal to a particular value with another value. The replacement is done in-place, changing the list. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to process. The value to find and replace within . The new value to replace with. Replace all items in a list or array equal to a particular value with another values. The replacement is done in-place, changing the list. A passed IEqualityComparer is used to determine equality. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to process. The value to find and replace within . The new value to replace with. The IEqualityComparer<T> used to compare items for equality. Only the Equals method will be called. Replace all items in a list or array that a predicate evaluates at true with a value. The replacement is done in-place, changing the list. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to process. The predicate used to evaluate items with the collection. If the predicate returns true for a particular item, the item is replaces with . The new value to replace with. Remove consecutive equal items from a collection, yielding another collection. In each run of consecutive equal items in the collection, all items after the first item in the run are removed. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. The collection to process. An new collection with the items from , in the same order, with consecutive duplicates removed. is null. Remove consecutive equal items from a collection, yielding another collection. In each run of consecutive equal items in the collection, all items after the first item in the run are removed. A passed IEqualityComparer is used to determine equality. The collection to process. The IEqualityComparer<T> used to compare items for equality. Only the Equals method will be called. An new collection with the items from , in the same order, with consecutive duplicates removed. or is null. Remove consecutive "equal" items from a collection, yielding another collection. In each run of consecutive equal items in the collection, all items after the first item in the run are removed. The passed BinaryPredicate is used to determine if two items are "equal". Since an arbitrary BinaryPredicate is passed to this function, what is being removed need not be true equality. The collection to process. The BinaryPredicate used to compare items for "equality". An item current is removed if predicate(first, current)==true, where first is the first item in the group of "duplicate" items. An new collection with the items from , in the same order, with consecutive "duplicates" removed. Remove consecutive equal items from a list or array. In each run of consecutive equal items in the list, all items after the first item in the run are removed. The removal is done in-place, changing the list. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to process. Remove subsequent consecutive equal items from a list or array. In each run of consecutive equal items in the list, all items after the first item in the run are removed. The replacement is done in-place, changing the list. A passed IEqualityComparer is used to determine equality. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to process. The IEqualityComparer<T> used to compare items for equality. Only the Equals method will be called. Remove consecutive "equal" items from a list or array. In each run of consecutive equal items in the list, all items after the first item in the run are removed. The replacement is done in-place, changing the list. The passed BinaryPredicate is used to determine if two items are "equal". Since an arbitrary BinaryPredicate is passed to this function, what is being tested for need not be true equality. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to process. The BinaryPredicate used to compare items for "equality". Finds the first occurence of consecutive equal items in the list. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. The list to examine. The number of consecutive equal items to look for. The count must be at least 1. The index of the first item in the first run of consecutive equal items, or -1 if no such run exists.. Finds the first occurence of consecutive equal items in the list. A passed IEqualityComparer is used to determine equality. The list to examine. The number of consecutive equal items to look for. The count must be at least 1. The IEqualityComparer<T> used to compare items for equality. Only the Equals method will be called. The index of the first item in the first run of consecutive equal items, or -1 if no such run exists. Finds the first occurence of consecutive "equal" items in the list. The passed BinaryPredicate is used to determine if two items are "equal". Since an arbitrary BinaryPredicate is passed to this function, what is being tested for need not be true equality. The list to examine. The number of consecutive equal items to look for. The count must be at least 1. The BinaryPredicate used to compare items for "equality". The index of the first item in the first run of consecutive equal items, or -1 if no such run exists. Finds the first occurence of consecutive items in the list for which a given predicate returns true. The list to examine. The number of consecutive items to look for. The count must be at least 1. The predicate used to test each item. The index of the first item in the first run of items where returns true for all items in the run, or -1 if no such run exists. Finds the first item in a collection that satisfies the condition defined by . If the default value for T could be present in the collection, and would be matched by the predicate, then this method is inappropriate, because you cannot disguish whether the default value for T was actually present in the collection, or no items matched the predicate. In this case, use TryFindFirstWhere. The collection to search. A delegate that defined the condition to check for. The first item in the collection that matches the condition, or the default value for T (0 or null) if no item that matches the condition is found. Finds the first item in a collection that satisfies the condition defined by . The collection to search. A delegate that defined the condition to check for. Outputs the first item in the collection that matches the condition, if the method returns true. True if an item satisfying the condition was found. False if no such item exists in the collection. Finds the last item in a collection that satisfies the condition defined by . If the collection implements IList<T>, then the list is scanned in reverse until a matching item is found. Otherwise, the entire collection is iterated in the forward direction. If the default value for T could be present in the collection, and would be matched by the predicate, then this method is inappropriate, because you cannot disguish whether the default value for T was actually present in the collection, or no items matched the predicate. In this case, use TryFindFirstWhere. The collection to search. A delegate that defined the condition to check for. The last item in the collection that matches the condition, or the default value for T (0 or null) if no item that matches the condition is found. Finds the last item in a collection that satisfies the condition defined by . If the collection implements IList<T>, then the list is scanned in reverse until a matching item is found. Otherwise, the entire collection is iterated in the forward direction. The collection to search. A delegate that defined the condition to check for. Outputs the last item in the collection that matches the condition, if the method returns true. True if an item satisfying the condition was found. False if no such item exists in the collection. Enumerates all the items in that satisfy the condition defined by . The collection to check all the items in. A delegate that defines the condition to check for. An IEnumerable<T> that enumerates the items that satisfy the condition. Finds the index of the first item in a list that satisfies the condition defined by . The list to search. A delegate that defined the condition to check for. The index of the first item satisfying the condition. -1 if no such item exists in the list. Finds the index of the last item in a list that satisfies the condition defined by . The list to search. A delegate that defined the condition to check for. The index of the last item satisfying the condition. -1 if no such item exists in the list. Enumerates the indices of all the items in that satisfy the condition defined by . The list to check all the items in. A delegate that defines the condition to check for. An IEnumerable<T> that enumerates the indices of items that satisfy the condition. Finds the index of the first item in a list equal to a given item. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. The list to search. The item to search for. The index of the first item equal to . -1 if no such item exists in the list. Finds the index of the first item in a list equal to a given item. A passed IEqualityComparer is used to determine equality. The list to search. The item to search for. The IEqualityComparer<T> used to compare items for equality. Only the Equals method will be called. The index of the first item equal to . -1 if no such item exists in the list. Finds the index of the last item in a list equal to a given item. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. The list to search. The item to search for. The index of the last item equal to . -1 if no such item exists in the list. Finds the index of the last item in a list equal to a given item. A passed IEqualityComparer is used to determine equality. The list to search. The item to search for. The IEqualityComparer<T> used to compare items for equality. Only the Equals method will be called. The index of the last item equal to . -1 if no such item exists in the list. Enumerates the indices of all the items in a list equal to a given item. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. The list to search. The item to search for. An IEnumerable<T> that enumerates the indices of items equal to . Enumerates the indices of all the items in a list equal to a given item. A passed IEqualityComparer is used to determine equality. The list to search. The item to search for. The IEqualityComparer<T> used to compare items for equality. Only the Equals method will be called. An IEnumerable<T> that enumerates the indices of items equal to . Finds the index of the first item in a list equal to one of several given items. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. The list to search. The items to search for. The index of the first item equal to any of the items in the collection . -1 if no such item exists in the list. Finds the index of the first item in a list equal to one of several given items. A passed IEqualityComparer is used to determine equality. The list to search. The items to search for. The IEqualityComparer<T> used to compare items for equality. Only the Equals and GetHashCode methods will be called. The index of the first item equal to any of the items in the collection . -1 if no such item exists in the list. Finds the index of the first item in a list "equal" to one of several given items. The passed BinaryPredicate is used to determine if two items are "equal". Since an arbitrary BinaryPredicate is passed to this function, what is being removed need not be true equality. This methods finds first item X which satisfies BinaryPredicate(X,Y), where Y is one of the items in The list to search. The items to search for. The BinaryPredicate used to compare items for "equality". The index of the first item "equal" to any of the items in the collection , using as the test for equality. -1 if no such item exists in the list. Finds the index of the last item in a list equal to one of several given items. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. The list to search. The items to search for. The index of the last item equal to any of the items in the collection . -1 if no such item exists in the list. Finds the index of the last item in a list equal to one of several given items. A passed IEqualityComparer is used to determine equality. The list to search. The items to search for. The IEqualityComparer<T> used to compare items for equality. The index of the last item equal to any of the items in the collection . -1 if no such item exists in the list. Finds the index of the last item in a list "equal" to one of several given items. The passed BinaryPredicate is used to determine if two items are "equal". Since an arbitrary BinaryPredicate is passed to this function, what is being removed need not be true equality. This methods finds last item X which satisfies BinaryPredicate(X,Y), where Y is one of the items in The list to search. The items to search for. The BinaryPredicate used to compare items for "equality". The index of the last item "equal" to any of the items in the collection , using as the test for equality. -1 if no such item exists in the list. Enumerates the indices of all the items in a list equal to one of several given items. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. The list to search. A collection of items to search for. An IEnumerable<T> that enumerates the indices of items equal to any of the items in the collection . Enumerates the indices of all the items in a list equal to one of several given items. A passed IEqualityComparer is used to determine equality. The list to search. A collection of items to search for. The IEqualityComparer<T> used to compare items for equality. An IEnumerable<T> that enumerates the indices of items equal to any of the items in the collection . Enumerates the indices of all the items in a list equal to one of several given items. The passed BinaryPredicate is used to determine if two items are "equal". Since an arbitrary BinaryPredicate is passed to this function, what is being removed need not be true equality. This methods finds last item X which satisfies BinaryPredicate(X,Y), where Y is one of the items in The list to search. A collection of items to search for. The BinaryPredicate used to compare items for "equality". An IEnumerable<T> that enumerates the indices of items "equal" to any of the items in the collection , using as the test for equality. Searchs a list for a sub-sequence of items that match a particular pattern. A subsequence of matches pattern at index i if list[i] is equal to the first item in , list[i+1] is equal to the second item in , and so forth for all the items in . The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. The type of items in the list. The list to search. The sequence of items to search for. The first index with that matches the items in . Searchs a list for a sub-sequence of items that match a particular pattern. A subsequence of matches pattern at index i if list[i] is "equal" to the first item in , list[i+1] is "equal" to the second item in , and so forth for all the items in . The passed BinaryPredicate is used to determine if two items are "equal". Since an arbitrary BinaryPredicate is passed to this function, what is being tested for in the pattern need not be equality. The type of items in the list. The list to search. The sequence of items to search for. The BinaryPredicate used to compare items for "equality". The first index with that matches the items in . Searchs a list for a sub-sequence of items that match a particular pattern. A subsequence of matches pattern at index i if list[i] is equal to the first item in , list[i+1] is equal to the second item in , and so forth for all the items in . The passed instance of IEqualityComparer<T> is used for determining if two items are equal. The type of items in the list. The list to search. The sequence of items to search for. The IEqualityComparer<T> used to compare items for equality. Only the Equals method will be called. The first index with that matches the items in . Determines if one collection is a subset of another, considered as sets. The first set is a subset of the second set if every item in the first set also occurs in the second set. If an item appears X times in the first set, it must appear at least X times in the second set. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the IsSubsetOf method on that class. The first collection. The second collection. True if is a subset of , considered as sets. or is null. Determines if one collection is a subset of another, considered as sets. The first set is a subset of the second set if every item in the first set also occurs in the second set. If an item appears X times in the first set, it must appear at least X times in the second set. If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the IsSubsetOf method on that class. The first collection. The second collection. The IEqualityComparer<T> used to compare items for equality. True if is a subset of , considered as sets. or is null. Determines if one collection is a proper subset of another, considered as sets. The first set is a proper subset of the second set if every item in the first set also occurs in the second set, and the first set is strictly smaller than the second set. If an item appears X times in the first set, it must appear at least X times in the second set. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the IsSubsetOf method on that class. The first collection. The second collection. True if is a subset of , considered as sets. or is null. Determines if one collection is a proper subset of another, considered as sets. The first set is a proper subset of the second set if every item in the first set also occurs in the second set, and the first set is strictly smaller than the second set. If an item appears X times in the first set, it must appear at least X times in the second set. If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the IsSubsetOf method on that class. The first collection. The second collection. The IEqualityComparer<T> used to compare items for equality. Only the Equals and GetHashCode member functions of this interface are called. True if is a proper subset of , considered as sets. or is null. Determines if two collections are disjoint, considered as sets. Two sets are disjoint if they have no common items. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the IsDisjoint method on that class. The first collection. The second collection. True if are are disjoint, considered as sets. or is null. Determines if two collections are disjoint, considered as sets. Two sets are disjoint if they have no common items. If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the IsDisjoint method on that class. The first collection. The second collection. The IEqualityComparerComparer<T> used to compare items for equality. Only the Equals and GetHashCode member functions of this interface are called. True if are are disjoint, considered as sets. or is null. Determines if two collections are equal, considered as sets. Two sets are equal if they have have the same items, with order not being significant. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the EqualTo method on that class. The first collection. The second collection. True if are are equal, considered as sets. or is null. Determines if two collections are equal, considered as sets. Two sets are equal if they have have the same items, with order not being significant. If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the EqualTo method on that class. The first collection. The second collection. The IEqualityComparer<T> used to compare items for equality. Only the Equals and GetHashCode member functions of this interface are called. True if are are equal, considered as sets. or is null. Computes the set-theoretic intersection of two collections. The intersection of two sets is all items that appear in both of the sets. If an item appears X times in one set, and Y times in the other set, the intersection contains the item Minimum(X,Y) times. The source collections are not changed. A new collection is created with the intersection of the collections; the order of the items in this collection is undefined. When equal items appear in both collections, the returned collection will include an arbitrary choice of one of the two equal items. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the Intersection or IntersectionWith methods on that class. The first collection to intersect. The second collection to intersect. The intersection of the two collections, considered as sets. or is null. Computes the set-theoretic intersection of two collections. The intersection of two sets is all items that appear in both of the sets. If an item appears X times in one set, and Y times in the other set, the intersection contains the item Minimum(X,Y) times. The source collections are not changed. A new collection is created with the intersection of the collections; the order of the items in this collection is undefined. When equal items appear in both collections, the returned collection will include an arbitrary choice of one of the two equal items. If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the Intersection or IntersectionWith methods on that class. The first collection to intersect. The second collection to intersect. The IEqualityComparer<T> used to compare items for equality. Only the Equals and GetHashCode member functions of this interface are called. The intersection of the two collections, considered as sets. or is null. Computes the set-theoretic union of two collections. The union of two sets is all items that appear in either of the sets. If an item appears X times in one set, and Y times in the other set, the union contains the item Maximum(X,Y) times. The source collections are not changed. A new collection is created with the union of the collections; the order of the items in this collection is undefined. When equal items appear in both collections, the returned collection will include an arbitrary choice of one of the two equal items. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the Union or UnionWith methods on that class. The first collection to union. The second collection to union. The union of the two collections, considered as sets. or is null. Computes the set-theoretic union of two collections. The union of two sets is all items that appear in either of the sets. If an item appears X times in one set, and Y times in the other set, the union contains the item Maximum(X,Y) times. The source collections are not changed. A new collection is created with the union of the collections; the order of the items in this collection is undefined. When equal items appear in both collections, the returned collection will include an arbitrary choice of one of the two equal items. If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the union or unionWith methods on that class. The first collection to union. The second collection to union. The IEqualityComparer<T> used to compare items for equality. Only the Equals and GetHashCode member functions of this interface are called. The union of the two collections, considered as sets. or is null. Computes the set-theoretic difference of two collections. The difference of two sets is all items that appear in the first set, but not in the second. If an item appears X times in the first set, and Y times in the second set, the difference contains the item X - Y times (0 times if X < Y). The source collections are not changed. A new collection is created with the difference of the collections; the order of the items in this collection is undefined. When equal items appear in both collections, the returned collection will include an arbitrary choice of one of the two equal items. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the Difference or DifferenceWith methods on that class. The first collection to difference. The second collection to difference. The difference of and , considered as sets. or is null. Computes the set-theoretic difference of two collections. The difference of two sets is all items that appear in the first set, but not in the second. If an item appears X times in the first set, and Y times in the second set, the difference contains the item X - Y times (0 times if X < Y). The source collections are not changed. A new collection is created with the difference of the collections; the order of the items in this collection is undefined. When equal items appear in both collections, the returned collection will include an arbitrary choice of one of the two equal items. If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the difference or differenceWith methods on that class. The first collection to difference. The second collection to difference. The IEqualityComparer<T> used to compare items for equality. Only the Equals and GetHashCode member functions of this interface are called. The difference of and , considered as sets. or is null. Computes the set-theoretic symmetric difference of two collections. The symmetric difference of two sets is all items that appear in the one of the sets, but not in the other. If an item appears X times in the one set, and Y times in the other set, the symmetric difference contains the item AbsoluteValue(X - Y) times. The source collections are not changed. A new collection is created with the symmetric difference of the collections; the order of the items in this collection is undefined. When equal items appear in both collections, the returned collection will include an arbitrary choice of one of the two equal items. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the SymmetricDifference or SymmetricDifferenceWith methods on that class. The first collection to symmetric difference. The second collection to symmetric difference. The symmetric difference of and , considered as sets. or is null. Computes the set-theoretic symmetric difference of two collections. The symmetric difference of two sets is all items that appear in the one of the sets, but not in the other. If an item appears X times in the one set, and Y times in the other set, the symmetric difference contains the item AbsoluteValue(X - Y) times. The source collections are not changed. A new collection is created with the symmetric difference of the collections; the order of the items in this collection is undefined. When equal items appear in both collections, the returned collection will include an arbitrary choice of one of the two equal items. If both collections are Set, Bag, OrderedSet, or OrderedBag collections, it is more efficient to use the symmetric difference or symmetric differenceWith methods on that class. The first collection to symmetric difference. The second collection to symmetric difference. The IEqualityComparer<T> used to compare items for equality. Only the Equals and GetHashCode member functions of this interface are called. The symmetric difference of and , considered as sets. or is null. Computes the cartestian product of two collections: all possible pairs of items, with the first item taken from the first collection and the second item taken from the second collection. If the first collection has N items, and the second collection has M items, the cartesian product will have N * M pairs. The type of items in the first collection. The type of items in the second collection. The first collection. The second collection. An IEnumerable<Pair<TFirst, TSecond>> that enumerates the cartesian product of the two collections. Gets a string representation of the elements in the collection. The string representation starts with "{", has a list of items separated by commas (","), and ends with "}". Each item in the collection is converted to a string by calling its ToString method (null is represented by "null"). Contained collections (except strings) are recursively converted to strings by this method. A collection to get the string representation of. The string representation of the collection. If is null, then the string "null" is returned. Gets a string representation of the elements in the collection. The string to used at the beginning and end, and to separate items, and supplied by parameters. Each item in the collection is converted to a string by calling its ToString method (null is represented by "null"). A collection to get the string representation of. If true, contained collections (except strings) are converted to strings by a recursive call to this method, instead of by calling ToString. The string to appear at the beginning of the output string. The string to appear between each item in the string. The string to appear at the end of the output string. The string representation of the collection. If is null, then the string "null" is returned. , , or is null. Gets a string representation of the mappings in a dictionary. The string representation starts with "{", has a list of mappings separated by commas (", "), and ends with "}". Each mapping is represented by "key->value". Each key and value in the dictionary is converted to a string by calling its ToString method (null is represented by "null"). Contained collections (except strings) are recursively converted to strings by this method. A dictionary to get the string representation of. The string representation of the collection, or "null" if is null. Return a private random number generator to use if the user doesn't supply one. The private random number generator. Only one is ever created and is always returned. Randomly shuffles the items in a collection, yielding a new collection. The type of the items in the collection. The collection to shuffle. An array with the same size and items as , but the items in a randomly chosen order. Randomly shuffles the items in a collection, yielding a new collection. The type of the items in the collection. The collection to shuffle. The random number generator to use to select the random order. An array with the same size and items as , but the items in a randomly chosen order. Randomly shuffles the items in a list or array, in place. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to shuffle. Randomly shuffles the items in a list or array, in place. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to shuffle. The random number generator to use to select the random order. Picks a random subset of items from , and places those items into a random order. No item is selected more than once. If the collection implements IList<T>, then this method takes time O(). Otherwise, this method takes time O(N), where N is the number of items in the collection. The type of items in the collection. The collection of items to select from. This collection is not changed. The number of items in the subset to choose. An array of items, selected at random from . is negative or greater than .Count. Picks a random subset of items from , and places those items into a random order. No item is selected more than once. If the collection implements IList<T>, then this method takes time O(). Otherwise, this method takes time O(N), where N is the number of items in the collection. The type of items in the collection. The collection of items to select from. This collection is not changed. The number of items in the subset to choose. The random number generates used to make the selection. An array of items, selected at random from . is negative or greater than .Count. is null. Generates all the possible permutations of the items in . If has N items, then N factorial permutations will be generated. This method does not compare the items to determine if any of them are equal. If some items are equal, the same permutation may be generated more than once. For example, if the collections contains the three items A, A, and B, then this method will generate the six permutations, AAB, AAB, ABA, ABA, BAA, BAA (not necessarily in that order). To take equal items into account, use the GenerateSortedPermutations method. The type of items to permute. The collection of items to permute. An IEnumerable<T[]> that enumerations all the possible permutations of the items in . Each permutations is returned as an array. The items in the array should be copied if they need to be used after the next permutation is generated; each permutation may reuse the same array instance. Generates all the possible permutations of the items in , in lexicographical order. Even if some items are equal, the same permutation will not be generated more than once. For example, if the collections contains the three items A, A, and B, then this method will generate only the three permutations, AAB, ABA, BAA. The type of items to permute. The collection of items to permute. An IEnumerable<T[]> that enumerations all the possible permutations of the items in . Each permutations is returned as an array. The items in the array should be copied if they need to be used after the next permutation is generated; each permutation may reuse the same array instance. Generates all the possible permutations of the items in , in lexicographical order. A supplied IComparer<T> instance is used to compare the items. Even if some items are equal, the same permutation will not be generated more than once. For example, if the collections contains the three items A, A, and B, then this method will generate only the three permutations, AAB, ABA, BAA. The type of items to permute. The collection of items to permute. The IComparer<T> used to compare the items. An IEnumerable<T[]> that enumerations all the possible permutations of the items in . Each permutations is returned as an array. The items in the array should be copied if they need to be used after the next permutation is generated; each permutation may reuse the same array instance. Generates all the possible permutations of the items in , in lexicographical order. A supplied Comparison<T> delegate is used to compare the items. Even if some items are equal, the same permutation will not be generated more than once. For example, if the collections contains the three items A, A, and B, then this method will generate only the three permutations, AAB, ABA, BAA. The type of items to permute. The collection of items to permute. The Comparison<T> delegate used to compare the items. An IEnumerable<T[]> that enumerations all the possible permutations of the items in . Each permutations is returned as an array. The items in the array should be copied if they need to be used after the next permutation is generated; each permutation may reuse the same array instance. Finds the maximum value in a collection. Values in the collection are compared by using the IComparable<T> interfaces implementation on the type T. The type of items in the collection. The collection to search. The largest item in the collection. The collection is empty. is null. Finds the maximum value in a collection. A supplied IComparer<T> is used to compare the items in the collection. The type of items in the collection. The collection to search. The comparer instance used to compare items in the collection. The largest item in the collection. The collection is empty. or is null. Finds the maximum value in a collection. A supplied Comparison<T> delegate is used to compare the items in the collection. The type of items in the collection. The collection to search. The comparison used to compare items in the collection. The largest item in the collection. The collection is empty. or is null. Finds the minimum value in a collection. Values in the collection are compared by using the IComparable<T> interfaces implementation on the type T. The type of items in the collection. The collection to search. The smallest item in the collection. The collection is empty. is null. Finds the minimum value in a collection. A supplied IComparer<T> is used to compare the items in the collection. The type of items in the collection. The collection to search. The comparer instance used to compare items in the collection. The smallest item in the collection. The collection is empty. or is null. Finds the minimum value in a collection. A supplied Comparison<T> delegate is used to compare the items in the collection. The type of items in the collection. The collection to search. The comparison used to compare items in the collection. The smallest item in the collection. The collection is empty. or is null. Finds the index of the maximum value in a list. Values in the list are compared by using the IComparable<T> interfaces implementation on the type T. The type of items in the list. The list to search. The index of the largest item in the list. If the maximum value appears multiple times, the index of the first appearance is used. If the list is empty, -1 is returned. is null. Finds the index of the maximum value in a list. A supplied IComparer<T> is used to compare the items in the collection. The type of items in the list. The list to search. The comparer instance used to compare items in the collection. The index of the largest item in the list. If the maximum value appears multiple times, the index of the first appearance is used. If the list is empty, -1 is returned. or is null. Finds the index of the maximum value in a list. A supplied Comparison<T> delegate is used to compare the items in the collection. The type of items in the list. The list to search. The comparison used to compare items in the collection. The index of the largest item in the list. If the maximum value appears multiple times, the index of the first appearance is used. If the list is empty, -1 is returned. or is null. Finds the index of the minimum value in a list. Values in the list are compared by using the IComparable<T> interfaces implementation on the type T. The type of items in the list. The list to search. The index of the smallest item in the list. If the minimum value appears multiple times, the index of the first appearance is used. The collection is empty. is null. Finds the index of the minimum value in a list. A supplied IComparer<T> is used to compare the items in the collection. The type of items in the list. The list to search. The comparer instance used to compare items in the collection. The index of the smallest item in the list. If the minimum value appears multiple times, the index of the first appearance is used. The collection is empty. or is null. Finds the index of the minimum value in a list. A supplied Comparison<T> delegate is used to compare the items in the collection. The type of items in the list. The list to search. The comparison delegate used to compare items in the collection. The index of the smallest item in the list. If the minimum value appears multiple times, the index of the first appearance is used. The collection is empty. or is null. Creates a sorted version of a collection. Values are compared by using the IComparable<T> interfaces implementation on the type T. The collection to sort. An array containing the sorted version of the collection. Creates a sorted version of a collection. A supplied IComparer<T> is used to compare the items in the collection. The collection to sort. The comparer instance used to compare items in the collection. Only the Compare method is used. An array containing the sorted version of the collection. Creates a sorted version of a collection. A supplied Comparison<T> delegate is used to compare the items in the collection. The collection to sort. The comparison delegate used to compare items in the collection. An array containing the sorted version of the collection. Sorts a list or array in place. The Quicksort algorithms is used to sort the items. In virtually all cases, this takes time O(N log N), where N is the number of items in the list. Values are compared by using the IComparable<T> interfaces implementation on the type T. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to sort. Sorts a list or array in place. A supplied IComparer<T> is used to compare the items in the list. The Quicksort algorithms is used to sort the items. In virtually all cases, this takes time O(N log N), where N is the number of items in the list. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to sort. The comparer instance used to compare items in the collection. Only the Compare method is used. Sorts a list or array in place. A supplied Comparison<T> delegate is used to compare the items in the list. The Quicksort algorithms is used to sort the items. In virtually all cases, this takes time O(N log N), where N is the number of items in the list. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to sort. The comparison delegate used to compare items in the collection. Creates a sorted version of a collection. The sort is stable, which means that if items X and Y are equal, and X precedes Y in the unsorted collection, X will precede Y is the sorted collection. Values are compared by using the IComparable<T> interfaces implementation on the type T. The collection to sort. An array containing the sorted version of the collection. Creates a sorted version of a collection. The sort is stable, which means that if items X and Y are equal, and X precedes Y in the unsorted collection, X will precede Y is the sorted collection. A supplied IComparer<T> is used to compare the items in the collection. The collection to sort. The comparer instance used to compare items in the collection. Only the Compare method is used. An array containing the sorted version of the collection. Creates a sorted version of a collection. The sort is stable, which means that if items X and Y are equal, and X precedes Y in the unsorted collection, X will precede Y is the sorted collection. A supplied Comparison<T> delegate is used to compare the items in the collection. Values are compared by using the IComparable<T> interfaces implementation on the type T. The collection to sort. The comparison delegate used to compare items in the collection. An array containing the sorted version of the collection. Sorts a list or array in place. The sort is stable, which means that if items X and Y are equal, and X precedes Y in the unsorted collection, X will precede Y is the sorted collection. Values are compared by using the IComparable<T> interfaces implementation on the type T. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to sort. Sorts a list or array in place. The sort is stable, which means that if items X and Y are equal, and X precedes Y in the unsorted collection, X will precede Y is the sorted collection. A supplied IComparer<T> is used to compare the items in the list. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to sort. The comparer instance used to compare items in the collection. Only the Compare method is used. Sorts a list or array in place. The sort is stable, which means that if items X and Y are equal, and X precedes Y in the unsorted collection, X will precede Y is the sorted collection. A supplied Comparison<T> delegate is used to compare the items in the list. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to sort. The comparison delegate used to compare items in the collection. Searches a sorted list for an item via binary search. The list must be sorted by the natural ordering of the type (it's implementation of IComparable<T>). The sorted list to search. The item to search for. Returns the first index at which the item can be found. If the return value is zero, indicating that was not present in the list, then this returns the index at which could be inserted to maintain the sorted order of the list. The number of items equal to that appear in the list. Searches a sorted list for an item via binary search. The list must be sorted by the ordering in the passed instance of IComparer<T>. The sorted list to search. The item to search for. The comparer instance used to sort the list. Only the Compare method is used. Returns the first index at which the item can be found. If the return value is zero, indicating that was not present in the list, then this returns the index at which could be inserted to maintain the sorted order of the list. The number of items equal to that appear in the list. Searches a sorted list for an item via binary search. The list must be sorted by the ordering in the passed Comparison<T> delegate. The sorted list to search. The item to search for. The comparison delegate used to sort the list. Returns the first index at which the item can be found. If the return value is zero, indicating that was not present in the list, then this returns the index at which could be inserted to maintain the sorted order of the list. The number of items equal to that appear in the list. Merge several sorted collections into a single sorted collection. Each input collection must be sorted by the natural ordering of the type (it's implementation of IComparable<T>). The merging is stable; equal items maintain their ordering, and equal items in different collections are placed in the order of the collections. The set of collections to merge. In many languages, this parameter can be specified as several individual parameters. An IEnumerable<T> that enumerates all the items in all the collections in sorted order. Merge several sorted collections into a single sorted collection. Each input collection must be sorted by the ordering in the passed instance of IComparer<T>. The merging is stable; equal items maintain their ordering, and equal items in different collections are placed in the order of the collections. The set of collections to merge. In many languages, this parameter can be specified as several individual parameters. The comparer instance used to sort the list. Only the Compare method is used. An IEnumerable<T> that enumerates all the items in all the collections in sorted order. Merge several sorted collections into a single sorted collection. Each input collection must be sorted by the ordering in the passed Comparison<T> delegate. The merging is stable; equal items maintain their ordering, and equal items in different collections are placed in the order of the collections. The set of collections to merge. In many languages, this parameter can be specified as several individual parameters. The comparison delegate used to sort the collections. An IEnumerable<T> that enumerates all the items in all the collections in sorted order. Performs a lexicographical comparison of two sequences of values. A lexicographical comparison compares corresponding pairs of elements from two sequences in order. If the first element of sequence1 is less than the first element of sequence2, then the comparison ends and the first sequence is lexicographically less than the second. If the first elements of each sequence are equal, then the comparison proceeds to the second element of each sequence. If one sequence is shorter than the other, but corresponding elements are all equal, then the shorter sequence is considered less than the longer one. T must implement either IComparable<T> and this implementation is used to compare the items. Types of items to compare. This type must implement IComparable<T> to allow items to be compared. The first sequence to compare. The second sequence to compare. Less than zero if is lexicographically less than . Greater than zero if is lexicographically greater than . Zero if is equal to . T does not implement IComparable<T> or IComparable. Performs a lexicographical comparison of two sequences of values, using a supplied comparison delegate. A lexicographical comparison compares corresponding pairs of elements from two sequences in order. If the first element of sequence1 is less than the first element of sequence2, then the comparison ends and the first sequence is lexicographically less than the second. If the first elements of each sequence are equal, then the comparison proceeds to the second element of each sequence. If one sequence is shorter than the other, but corresponding elements are all equal, then the shorter sequence is considered less than the longer one. Types of items to compare. The first sequence to compare. The second sequence to compare. The IComparison<T> delegate to compare items. Only the Compare member function of this interface is called. Less than zero if is lexicographically less than . Greater than zero if is lexicographically greater than . Zero if is equal to . Performs a lexicographical comparison of two sequences of values, using a supplied comparer interface. A lexicographical comparison compares corresponding pairs of elements from two sequences in order. If the first element of sequence1 is less than the first element of sequence2, then the comparison ends and the first sequence is lexicographically less than the second. If the first elements of each sequence are equal, then the comparison proceeds to the second element of each sequence. If one sequence is shorter than the other, but corresponding elements are all equal, then the shorter sequence is considered less than the longer one. Types of items to compare. The first sequence to compare. The second sequence to compare. The IComparer<T> used to compare items. Only the Compare member function of this interface is called. Less than zero if is lexicographically less than . Greater than zero if is lexicographically greater than . Zero if is equal to . , , or is null. A private class used by the LexicographicalComparer method to compare sequences (IEnumerable) of T by there Lexicographical ordering. Creates a new instance that comparer sequences of T by their lexicographical ordered. The IComparer used to compare individual items of type T. Creates an IComparer instance that can be used for comparing ordered sequences of type T; that is IEnumerable<Tgt;. This comparer can be used for collections or algorithms that use sequences of T as an item type. The Lexicographical ordered of sequences is for comparison. T must implement either IComparable<T> and this implementation is used to compare the items. At IComparer<IEnumerable<T>> that compares sequences of T. Creates an IComparer instance that can be used for comparing ordered sequences of type T; that is IEnumerable<Tgt;. This comparer can be uses for collections or algorithms that use sequences of T as an item type. The Lexicographics ordered of sequences is for comparison. A comparer instance used to compare individual items of type T. At IComparer<IEnumerable<T>> that compares sequences of T. Creates an IComparer instance that can be used for comparing ordered sequences of type T; that is IEnumerable<Tgt;. This comparer can be uses for collections or algorithms that use sequences of T as an item type. The Lexicographics ordered of sequences is for comparison. A comparison delegate used to compare individual items of type T. At IComparer<IEnumerable<T>> that compares sequences of T. An IComparer instance that can be used to reverse the sense of a wrapped IComparer instance. The comparer to reverse. Reverses the order of comparison of an IComparer<T>. The resulting comparer can be used, for example, to sort a collection in descending order. Equality and hash codes are unchanged. The type of items thta are being compared. The comparer to reverse. An IComparer<T> that compares items in the reverse order of . is null. A class, implementing IEqualityComparer<T>, that compares objects for object identity only. Only Equals and GetHashCode can be used; this implementation is not appropriate for ordering. Gets an IEqualityComparer<T> instance that can be used to compare objects of type T for object identity only. Two objects compare equal only if they are references to the same object. An IEqualityComparer<T> instance for identity comparison. Reverses the order of comparison of an Comparison<T>. The resulting comparison can be used, for example, to sort a collection in descending order. The type of items that are being compared. The comparison to reverse. A Comparison<T> that compares items in the reverse order of . is null. Given a comparison delegate that compares two items of type T, gets an IComparer<T> instance that performs the same comparison. The comparison delegate to use. An IComparer<T> that performs the same comparing operation as . Given in IComparer<T> instenace that comparers two items from type T, gets a Comparison delegate that performs the same comparison. The IComparer<T> instance to use. A Comparison<T> delegate that performans the same comparing operation as . A private class used to implement GetCollectionEqualityComparer(). This class implements IEqualityComparer<IEnumerable<T>gt; to compare two enumerables for equality, where order is significant. Gets an IEqualityComparer<IEnumerable<T>> implementation that can be used to compare collections of elements (of type T). Two collections of T's are equal if they have the same number of items, and corresponding items are equal, considered in order. This is the same notion of equality as in Algorithms.EqualCollections, but encapsulated in an IEqualityComparer<IEnumerable<T>> implementation. The following code creates a Dictionary where the keys are a collection of strings. Dictionary<IEnumerable<string>, int> = new Dictionary<IEnumerable<string>, int>(Algorithms.GetCollectionEqualityComparer<string>()); IEqualityComparer<IEnumerable<T>> implementation suitable for comparing collections of T for equality. Gets an IEqualityComparer<IEnumerable<T>> implementation that can be used to compare collections of elements (of type T). Two collections of T's are equal if they have the same number of items, and corresponding items are equal, considered in order. This is the same notion of equality as in Algorithms.EqualCollections, but encapsulated in an IEqualityComparer<IEnumerable<T>> implementation. An IEqualityComparer<T> is used to determine if individual T's are equal The following code creates a Dictionary where the keys are a collection of strings, compared in a case-insensitive way Dictionary<IEnumerable<string>, int> = new Dictionary<IEnumerable<string>, int>(Algorithms.GetCollectionEqualityComparer<string>(StringComparer.CurrentCultureIgnoreCase)); An IEqualityComparer<T> implementation used to compare individual T's. IEqualityComparer<IEnumerable<T>> implementation suitable for comparing collections of T for equality. A private class used to implement GetSetEqualityComparer(). This class implements IEqualityComparer<IEnumerable<T>gt; to compare two enumerables for equality, where order is not significant. Gets an IEqualityComparer<IEnumerable<T>> implementation that can be used to compare collections of elements (of type T). Two collections of T's are equal if they have the same number of items, and corresponding items are equal, without regard to order. This is the same notion of equality as in Algorithms.EqualSets, but encapsulated in an IEqualityComparer<IEnumerable<T>> implementation. An IEqualityComparer<T> is used to determine if individual T's are equal The following code creates a Dictionary where the keys are a set of strings, without regard to order Dictionary<IEnumerable<string>, int> = new Dictionary<IEnumerable<string>, int>(Algorithms.GetSetEqualityComparer<string>(StringComparer.CurrentCultureIgnoreCase)); IEqualityComparer<IEnumerable<T>> implementation suitable for comparing collections of T for equality, without regard to order. Gets an IEqualityComparer<IEnumerable<T>> implementation that can be used to compare collections of elements (of type T). Two collections of T's are equal if they have the same number of items, and corresponding items are equal, without regard to order. This is the same notion of equality as in Algorithms.EqualSets, but encapsulated in an IEqualityComparer<IEnumerable<T>> implementation. The following code creates a Dictionary where the keys are a set of strings, without regard to order Dictionary<IEnumerable<string>, int> = new Dictionary<IEnumerable<string>, int>(Algorithms.GetSetEqualityComparer<string>()); An IEqualityComparer<T> implementation used to compare individual T's. IEqualityComparer<IEnumerable<T>> implementation suitable for comparing collections of T for equality, without regard to order. Determines if a collection contains any item that satisfies the condition defined by . The collection to check all the items in. A delegate that defines the condition to check for. True if the collection contains one or more items that satisfy the condition defined by . False if the collection does not contain an item that satisfies . Determines if all of the items in the collection satisfy the condition defined by . The collection to check all the items in. A delegate that defines the condition to check for. True if all of the items in the collection satisfy the condition defined by , or if the collection is empty. False if one or more items in the collection do not satisfy . Counts the number of items in the collection that satisfy the condition defined by . The collection to count items in. A delegate that defines the condition to check for. The number of items in the collection that satisfy . Removes all the items in the collection that satisfy the condition defined by . If the collection if an array or implements IList<T>, an efficient algorithm that compacts items is used. If not, then ICollection<T>.Remove is used to remove items from the collection. If the collection is an array or fixed-size list, the non-removed elements are placed, in order, at the beginning of the list, and the remaining list items are filled with a default value (0 or null). The collection to check all the items in. A delegate that defines the condition to check for. Returns a collection of the items that were removed. This collection contains the items in the same order that they orginally appeared in . Convert a collection of items by applying a delegate to each item in the collection. The resulting collection contains the result of applying to each item in , in order. The type of items in the collection to convert. The type each item is being converted to. The collection of item being converted. A delegate to the method to call, passing each item in . The resulting collection from applying to each item in , in order. or is null. Creates a delegate that converts keys to values by used a dictionary to map values. Keys that a not present in the dictionary are converted to the default value (zero or null). This delegate can be used as a parameter in Convert or ConvertAll methods to convert entire collections. The dictionary used to perform the conversion. A delegate to a method that converts keys to values. Creates a delegate that converts keys to values by used a dictionary to map values. Keys that a not present in the dictionary are converted to a supplied default value. This delegate can be used as a parameter in Convert or ConvertAll methods to convert entire collections. The dictionary used to perform the conversion. The result of the conversion for keys that are not present in the dictionary. A delegate to a method that converts keys to values. is null. Performs the specified action on each item in a collection. The collection to process. An Action delegate which is invoked for each item in . Partition a list or array based on a predicate. After partitioning, all items for which the predicate returned true precede all items for which the predicate returned false. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to partition. A delegate that defines the partitioning condition. The index of the first item in the second half of the partition; i.e., the first item for which returned false. If the predicate was true for all items in the list, list.Count is returned. Partition a list or array based on a predicate. After partitioning, all items for which the predicate returned true precede all items for which the predicate returned false. The partition is stable, which means that if items X and Y have the same result from the predicate, and X precedes Y in the original list, X will precede Y in the partitioned list. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to partition. A delegate that defines the partitioning condition. The index of the first item in the second half of the partition; i.e., the first item for which returned false. If the predicate was true for all items in the list, list.Count is returned. Concatenates all the items from several collections. The collections need not be of the same type, but must have the same item type. The set of collections to concatenate. In many languages, this parameter can be specified as several individual parameters. An IEnumerable that enumerates all the items in each of the collections, in order. Determines if the two collections contain equal items in the same order. The two collections do not need to be of the same type; it is permissible to compare an array and an OrderedBag, for instance. The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. The type of items in the collections. The first collection to compare. The second collection to compare. True if the collections have equal items in the same order. If both collections are empty, true is returned. Determines if the two collections contain equal items in the same order. The passed instance of IEqualityComparer<T> is used for determining if two items are equal. The type of items in the collections. The first collection to compare. The second collection to compare. The IEqualityComparer<T> used to compare items for equality. Only the Equals member function of this interface is called. True if the collections have equal items in the same order. If both collections are empty, true is returned. , , or is null. Determines if the two collections contain "equal" items in the same order. The passed BinaryPredicate is used to determine if two items are "equal". Since an arbitrary BinaryPredicate is passed to this function, what is being tested for need not be equality. For example, the following code determines if each integer in list1 is less than or equal to the corresponding integer in list2. List<int> list1, list2; if (EqualCollections(list1, list2, delegate(int x, int y) { return x <= y; }) { // the check is true... } The type of items in the collections. The first collection to compare. The second collection to compare. The BinaryPredicate used to compare items for "equality". This predicate can compute any relation between two items; it need not represent equality or an equivalence relation. True if returns true for each corresponding pair of items in the two collections. If both collections are empty, true is returned. , , or is null. Create an array with the items in a collection. If implements ICollection<T>T, then ICollection<T>.CopyTo() is used to fill the array. Otherwise, the IEnumerable<T>.GetEnumerator() is used to fill the array. Element type of the collection. Collection to create array from. An array with the items from the collection, in enumeration order. is null. Count the number of items in an IEnumerable<T> collection. If a more specific collection type is being used, it is more efficient to use the Count property, if one is provided. If the collection implements ICollection<T>, this method simply returns ICollection<T>.Count. Otherwise, it enumerates all items and counts them. The collection to count items in. The number of items in the collection. is null. Counts the number of items in the collection that are equal to . The default sense of equality for T is used, as defined by T's implementation of IComparable<T>.Equals or object.Equals. The collection to count items in. The item to compare to. The number of items in the collection that are equal to . Counts the number of items in the collection that are equal to . The collection to count items in. The item to compare to. The comparer to use to determine if two items are equal. Only the Equals member function will be called. The number of items in the collection that are equal to . or is null. Creates an IEnumerator that enumerates a given item times. The following creates a list consisting of 1000 copies of the double 1.0. List<double> list = new List<double>(Algorithms.NCopiesOf(1000, 1.0)); The number of times to enumerate the item. The item that should occur in the enumeration. An IEnumerable<T> that yields copies of . The argument is less than zero. Replaces each item in a list with a given value. The list does not change in size. The type of items in the list. The list to modify. The value to fill with. is a read-only list. is null. Replaces each item in a array with a given value. The array to modify. The value to fill with. is null. Replaces each item in a part of a list with a given value. The type of items in the list. The list to modify. The index at which to start filling. The first index in the list has index 0. The number of items to fill. The value to fill with. is a read-only list. or is negative, or + is greater than .Count. is null. Replaces each item in a part of a array with a given value. The array to modify. The index at which to start filling. The first index in the array has index 0. The number of items to fill. The value to fill with. or is negative, or + is greater than .Length. is null. Copies all of the items from the collection to the list , starting at the index . If necessary, the size of the destination list is expanded. The collection that provide the source items. The list to store the items into. The index to begin copying items to. is negative or greater than .Count. or is null. Copies all of the items from the collection to the array , starting at the index . The collection that provide the source items. The array to store the items into. The index to begin copying items to. is negative or greater than .Length. or is null. The collection has more items than will fit into the array. In this case, the array has been filled with as many items as fit before the exception is thrown. Copies at most items from the collection to the list , starting at the index . If necessary, the size of the destination list is expanded. The source collection must not be the destination list or part thereof. The collection that provide the source items. The list to store the items into. The index to begin copying items to. The maximum number of items to copy. is negative or greater than .Count is negative. or is null. Copies at most items from the collection to the array , starting at the index . The source collection must not be the destination array or part thereof. The collection that provide the source items. The array to store the items into. The index to begin copying items to. The maximum number of items to copy. The array must be large enought to fit this number of items. is negative or greater than .Length. is negative or + is greater than .Length. or is null. Copies items from the list , starting at the index , to the list , starting at the index . If necessary, the size of the destination list is expanded. The source and destination lists may be the same. The collection that provide the source items. The index within to begin copying items from. The list to store the items into. The index within to begin copying items to. The maximum number of items to copy. is negative or greater than .Count is negative or greater than .Count is negative or too large. or is null. Copies items from the list or array , starting at the index , to the array , starting at the index . The source may be the same as the destination array. The list or array that provide the source items. The index within to begin copying items from. The array to store the items into. The index within to begin copying items to. The maximum number of items to copy. The destination array must be large enough to hold this many items. is negative or greater than .Count is negative or greater than .Length is negative or too large. or is null. Reverses a list and returns the reversed list, without changing the source list. The list to reverse. A collection that contains the items from in reverse order. is null. Reverses a list or array in place. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to reverse. is null. is read only. Rotates a list and returns the rotated list, without changing the source list. The list to rotate. The number of elements to rotate. This value can be positive or negative. For example, rotating by positive 3 means that source[3] is the first item in the returned collection. Rotating by negative 3 means that source[source.Count - 3] is the first item in the returned collection. A collection that contains the items from in rotated order. is null. Rotates a list or array in place. Although arrays cast to IList<T> are normally read-only, this method will work correctly and modify an array passed as . The list or array to rotate. The number of elements to rotate. This value can be positive or negative. For example, rotating by positive 3 means that list[3] is the first item in the resulting list. Rotating by negative 3 means that list[list.Count - 3] is the first item in the resulting list. is null. Bag<T> is a collection that contains items of type T. Unlike a Set, duplicate items (items that compare equal to each other) are allowed in an Bag.

The items are compared in one of two ways. If T implements IComparable<T> then the Equals method of that interface will be used to compare items, otherwise the Equals method from Object will be used. Alternatively, an instance of IComparer<T> can be passed to the constructor to use to compare items.

Bag is implemented as a hash table. Inserting, deleting, and looking up an an element all are done in approximately constant time, regardless of the number of items in the bag.

When multiple equal items are stored in the bag, they are stored as a representative item and a count. If equal items can be distinguished, this may be noticable. For example, if a case-insensitive comparer is used with a Bag<string>, and both "hello", and "HELLO" are added to the bag, then the bag will appear to contain two copies of "hello" (the representative item).

is similar, but uses comparison instead of hashing, maintain the items in sorted order, and stores distinct copies of items that compare equal.

Helper function to create a new KeyValuePair struct with an item and a count. The item. The number of appearances. A new KeyValuePair. Helper function to create a new KeyValuePair struct with a count of zero. The item. A new KeyValuePair. Creates a new Bag. Items that are null are permitted. Creates a new Bag. The Equals and GetHashCode methods of the passed comparison object will be used to compare items in this bag for equality. An instance of IEqualityComparer<T> that will be used to compare items. Creates a new Bag. The bag is initialized with all the items in the given collection. Items that are null are permitted. A collection with items to be placed into the Bag. Creates a new Bag. The Equals and GetHashCode methods of the passed comparison object will be used to compare items in this bag. The bag is initialized with all the items in the given collection. A collection with items to be placed into the Bag. An instance of IEqualityComparer<T> that will be used to compare items. Creates a new Bag given a comparer and a hash that contains the data. Used internally for Clone. IEqualityComparer for the bag. IEqualityComparer for the key. Data for the bag. Size of the bag. Makes a shallow clone of this bag; i.e., if items of the bag are reference types, then they are not cloned. If T is a value type, then each element is copied as if by simple assignment. Cloning the bag takes time O(N), where N is the number of items in the bag. The cloned bag. Makes a shallow clone of this bag; i.e., if items of the bag are reference types, then they are not cloned. If T is a value type, then each element is copied as if by simple assignment. Cloning the bag takes time O(N), where N is the number of unquie items in the bag. The cloned bag. Makes a deep clone of this bag. A new bag is created with a clone of each element of this bag, by calling ICloneable.Clone on each element. If T is a value type, then each element is copied as if by simple assignment. If T is a reference type, it must implement ICloneable. Otherwise, an InvalidOperationException is thrown. Cloning the bag takes time O(N log N), where N is the number of items in the bag. The cloned bag. T is a reference type that does not implement ICloneable. Returns the IEqualityComparer<T> used to compare items in this bag. If the bag was created using a comparer, that comparer is returned. Otherwise the default comparer for T (EqualityComparer<T>.Default) is returned. Returns the number of items in the bag. The size of the bag is returned in constant time. The number of items in the bag. Returns the number of copies of in the bag. NumberOfCopies() takes approximately constant time, no matter how many items are stored in the bag. The item to search for in the bag. The number of items in the bag that compare equal to . Returns the representative item stored in the bag that is equal to the provided item. Also returns the number of copies of the item in the bag. Item to find in the bag. If one or more items equal to are present in the bag, returns the representative item. If no items equal to are stored in the bag, returns . The number of items equal to stored in the bag. Returns an enumerator that enumerates all the items in the bag. If an item is present multiple times in the bag, the representative item is yielded by the enumerator multiple times. The order of enumeration is haphazard and may change.

Typically, this method is not called directly. Instead the "foreach" statement is used to enumerate the items, which uses this method implicitly.

If an item is added to or deleted from the bag while it is being enumerated, then the enumeration will end with an InvalidOperationException.

Enumeration all the items in the bag takes time O(N), where N is the number of items in the bag.

An enumerator for enumerating all the items in the Bag.
Determines if this bag contains an item equal to . The bag is not changed. Searching the bag for an item takes time O(log N), where N is the number of items in the bag. The item to search for. True if the bag contains . False if the bag does not contain . Enumerates all the items in the bag, but enumerates equal items just once, even if they occur multiple times in the bag. If the bag is changed while items are being enumerated, the enumeration will terminate with an InvalidOperationException. An IEnumerable<T> that enumerates the unique items. Adds a new item to the bag. Since bags can contain duplicate items, the item is added even if the bag already contains an item equal to . In this case, the count of items for the representative item is increased by one, but the existing represetative item is unchanged. Adding an item takes approximately constant time, regardless of the number of items in the bag. The item to add to the bag. Adds a new item to the bag. Since bags can contain duplicate items, the item is added even if the bag already contains an item equal to . In this case (unlike Add), the new item becomes the representative item. Adding an item takes approximately constant time, regardless of the number of items in the bag. The item to add to the bag. Changes the number of copies of an existing item in the bag, or adds the indicated number of copies of the item to the bag. Changing the number of copies takes approximately constant time, regardless of the number of items in the bag. The item to change the number of copies of. This may or may not already be present in the bag. The new number of copies of the item. Adds all the items in to the bag. Adding the collection takes time O(M log N), where N is the number of items in the bag, and M is the number of items in . A collection of items to add to the bag. Searches the bag for one item equal to , and if found, removes it from the bag. If not found, the bag is unchanged. Equality between items is determined by the comparison instance or delegate used to create the bag. Removing an item from the bag takes approximated constant time, regardless of the number of items in the bag. The item to remove. True if was found and removed. False if was not in the bag. Searches the bag for all items equal to , and removes all of them from the bag. If not found, the bag is unchanged. Equality between items is determined by the comparer instance used to create the bag. RemoveAllCopies() takes time O(M log N), where N is the total number of items in the bag, and M is the number of items equal to . The item to remove. The number of copies of that were found and removed. Removes all the items in from the bag. Items that are not present in the bag are ignored. Equality between items is determined by the comparer instance used to create the bag. Removing the collection takes time O(M), where M is the number of items in . A collection of items to remove from the bag. The number of items removed from the bag. is null. Removes all items from the bag. Clearing the bag takes a constant amount of time, regardless of the number of items in it. Check that this bag and another bag were created with the same comparison mechanism. Throws exception if not compatible. Other bag to check comparision mechanism. If otherBag and this bag don't use the same method for comparing items. Determines if this bag is equal to another bag. This bag is equal to if they contain the same number of of copies of equal elements. IsSupersetOf is computed in time O(N), where N is the number of unique items in this bag. Bag to compare to True if this bag is equal to , false otherwise. This bag and don't use the same method for comparing items. Determines if this bag is a superset of another bag. Neither bag is modified. This bag is a superset of if every element in is also in this bag, at least the same number of times. IsSupersetOf is computed in time O(M), where M is the number of unique items in . Bag to compare to. True if this is a superset of . This bag and don't use the same method for comparing items. Determines if this bag is a proper superset of another bag. Neither bag is modified. This bag is a proper superset of if every element in is also in this bag, at least the same number of times. Additional, this bag must have strictly more items than . IsProperSupersetOf is computed in time O(M), where M is the number of unique items in . Set to compare to. True if this is a proper superset of . This bag and don't use the same method for comparing items. Determines if this bag is a subset of another ba11 items in this bag. Bag to compare to. True if this is a subset of . This bag and don't use the same method for comparing items. Determines if this bag is a proper subset of another bag. Neither bag is modified. This bag is a subset of if every element in this bag is also in , at least the same number of times. Additional, this bag must have strictly fewer items than . IsProperSubsetOf is computed in time O(N), where N is the number of unique items in this bag. Bag to compare to. True if this is a proper subset of . This bag and don't use the same method for comparing items. Determines if this bag is disjoint from another bag. Two bags are disjoint if no item from one set is equal to any item in the other bag. The answer is computed in time O(N), where N is the size of the smaller set. Bag to check disjointness with. True if the two bags are disjoint, false otherwise. This bag and don't use the same method for comparing items. Computes the union of this bag with another bag. The union of two bags is all items from both of the bags. If an item appears X times in one bag, and Y times in the other bag, the union contains the item Maximum(X,Y) times. This bag receives the union of the two bags, the other bag is unchanged. The union of two bags is computed in time O(M+N), where M and N are the size of the two bags. Bag to union with. This bag and don't use the same method for comparing items. Computes the union of this bag with another bag. The union of two bags is all items from both of the bags. If an item appears X times in one bag, and Y times in the other bag, the union contains the item Maximum(X,Y) times. A new bag is created with the union of the bags and is returned. This bag and the other bag are unchanged. The union of two bags is computed in time O(M+N), where M and N are the size of the two bags. Bag to union with. The union of the two bags. This bag and don't use the same method for comparing items. Computes the sum of this bag with another bag. The sum of two bags is all items from both of the bags. If an item appears X times in one bag, and Y times in the other bag, the sum contains the item (X+Y) times. This bag receives the sum of the two bags, the other bag is unchanged. The sum of two bags is computed in time O(M), where M is the size of the other bag.. Bag to sum with. This bag and don't use the same method for comparing items. Computes the sum of this bag with another bag. he sum of two bags is all items from both of the bags. If an item appears X times in one bag, and Y times in the other bag, the sum contains the item (X+Y) times. A new bag is created with the sum of the bags and is returned. This bag and the other bag are unchanged. The sum of two bags is computed in time O(M + N log M), where M is the size of the larger bag, and N is the size of the smaller bag. Bag to sum with. The sum of the two bags. This bag and don't use the same method for comparing items. Computes the intersection of this bag with another bag. The intersection of two bags is all items that appear in both of the bags. If an item appears X times in one bag, and Y times in the other bag, the sum contains the item Minimum(X,Y) times. This bag receives the intersection of the two bags, the other bag is unchanged. When equal items appear in both bags, the intersection will include an arbitrary choice of one of the two equal items. The intersection of two bags is computed in time O(N), where N is the size of the smaller bag. Bag to intersection with. This bag and don't use the same method for comparing items. Computes the intersection of this bag with another bag. The intersection of two bags is all items that appear in both of the bags. If an item appears X times in one bag, and Y times in the other bag, the intersection contains the item Minimum(X,Y) times. A new bag is created with the intersection of the bags and is returned. This bag and the other bag are unchanged. When equal items appear in both bags, the intersection will include an arbitrary choice of one of the two equal items. The intersection of two bags is computed in time O(N), where N is the size of the smaller bag. Bag to intersection with. The intersection of the two bags. This bag and don't use the same method for comparing items. Computes the difference of this bag with another bag. The difference of these two bags is all items that appear in this bag, but not in . If an item appears X times in this bag, and Y times in the other bag, the difference contains the item X - Y times (zero times if Y >= X). This bag receives the difference of the two bags; the other bag is unchanged. The difference of two bags is computed in time O(M), where M is the size of the other bag. Bag to difference with. This bag and don't use the same method for comparing items. Computes the difference of this bag with another bag. The difference of these two bags is all items that appear in this bag, but not in . If an item appears X times in this bag, and Y times in the other bag, the difference contains the item X - Y times (zero times if Y >= X). A new bag is created with the difference of the bags and is returned. This bag and the other bag are unchanged. The difference of two bags is computed in time O(M + N), where M and N are the size of the two bags. Bag to difference with. The difference of the two bags. This bag and don't use the same method for comparing items. Computes the symmetric difference of this bag with another bag. The symmetric difference of two bags is all items that appear in either of the bags, but not both. If an item appears X times in one bag, and Y times in the other bag, the symmetric difference contains the item AbsoluteValue(X - Y) times. This bag receives the symmetric difference of the two bags; the other bag is unchanged. The symmetric difference of two bags is computed in time O(M + N), where M is the size of the larger bag, and N is the size of the smaller bag. Bag to symmetric difference with. This bag and don't use the same method for comparing items. Computes the symmetric difference of this bag with another bag. The symmetric difference of two bags is all items that appear in either of the bags, but not both. If an item appears X times in one bag, and Y times in the other bag, the symmetric difference contains the item AbsoluteValue(X - Y) times. A new bag is created with the symmetric difference of the bags and is returned. This bag and the other bag are unchanged. The symmetric difference of two bags is computed in time O(M + N), where M is the size of the larger bag, and N is the size of the smaller bag. Bag to symmetric difference with. The symmetric difference of the two bags. This bag and don't use the same method for comparing items. CollectionBase is a base class that can be used to more easily implement the generic ICollection<T> and non-generic ICollection interfaces. To use CollectionBase as a base class, the derived class must override the Count, GetEnumerator, Add, Clear, and Remove methods. ICollection<T>.Contains need not be implemented by the derived class, but it should be strongly considered, because the CollectionBase implementation may not be very efficient. The item type of the collection. Creates a new CollectionBase. 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. The string representation of the collection. Must be overridden to allow adding items to this collection.

This method is not abstract, although derived classes should always override it. It is not abstract because some derived classes may wish to reimplement Add with a different return type (typically bool). In C#, this can be accomplished with code like the following:

public class MyCollection<T>: CollectionBase<T>, ICollection<T> { public new bool Add(T item) { /* Add the item */ } void ICollection<T>.Add(T item) { Add(item); } }
Item to be added to the collection. Always throws this exception to indicated that the method must be overridden or re-implemented in the derived class.
Must be overridden to allow clearing this collection. Must be overridden to allow removing items from this collection. True if existed in the collection and was removed. False if did not exist in the collection. Determines if the collection contains a particular item. This default implementation iterates all of the items in the collection via GetEnumerator, testing each item against using IComparable<T>.Equals or Object.Equals. You should strongly consider overriding this method to provide a more efficient implementation, or if the default equality comparison is inappropriate. The item to check for in the collection. True if the collection contains , false otherwise. 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. Array to copy to. Starting index in to copy to. Creates an array of the correct size, and copies all the items in the collection into the array, by calling CopyTo. An array containing all the elements in the collection, in order. Must be overridden to provide the number of items in the collection. The number of items in the collection. Indicates whether the collection is read-only. Always returns false. Always returns false. Provides a read-only view of this collection. The returned ICollection<T> provides a view of the collection that prevents modifications to the collection. Use the method to provide access to the collection without allowing changes. Since the returned object is just a view, changes to the collection will be reflected in the view. An ICollection<T> that provides read-only access to the collection. Determines if the collection contains any item that satisfies the condition defined by . A delegate that defines the condition to check for. True if the collection contains one or more items that satisfy the condition defined by . False if the collection does not contain an item that satisfies . Determines if all of the items in the collection satisfy the condition defined by . A delegate that defines the condition to check for. True if all of the items in the collection satisfy the condition defined by , or if the collection is empty. False if one or more items in the collection do not satisfy . Counts the number of items in the collection that satisfy the condition defined by . A delegate that defines the condition to check for. The number of items in the collection that satisfy . Enumerates the items in the collection that satisfy the condition defined by . A delegate that defines the condition to check for. An IEnumerable<T> that enumerates the items that satisfy the condition. Removes all the items in the collection that satisfy the condition defined by . A delegate that defines the condition to check for. Returns a collection of the items that were removed, in sorted order. Performs the specified action on each item in this collection. An Action delegate which is invoked for each item in this collection. Convert this collection of items by applying a delegate to each item in the collection. The resulting enumeration contains the result of applying to each item in this collection, in order. The type each item is being converted to. A delegate to the method to call, passing each item in this collection. An IEnumerable<TOutput^gt; that enumerates the resulting collection from applying to each item in this collection in order. is null. Must be overridden to enumerate all the members of the collection. A generic IEnumerator<T> that can be used to enumerate all the items in the collection. 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. Array to copy to. Starting index in to copy to. Indicates whether the collection is synchronized. Always returns false, indicating that the collection is not synchronized. Indicates the synchronization object for this collection. Always returns this. Provides an IEnumerator that can be used to iterate all the members of the collection. This implementation uses the IEnumerator<T> that was overridden by the derived classes to enumerate the members of the collection. An IEnumerator that can be used to iterate the collection. Display the contents of the collection in the debugger. This is intentionally private, it is called only from the debugger due to the presence of the DebuggerDisplay attribute. It is similar format to ToString(), but is limited to 250-300 characters or so, so as not to overload the debugger. The string representation of the items in the collection, similar in format to ToString(). The Deque class implements a type of list known as a Double Ended Queue. A Deque is quite similar to a List, in that items have indices (starting at 0), and the item at any index can be efficiently retrieved. The difference between a List and a Deque lies in the efficiency of inserting elements at the beginning. In a List, items can be efficiently added to the end, but inserting an item at the beginning of the List is slow, taking time proportional to the size of the List. In a Deque, items can be added to the beginning or end equally efficiently, regardless of the number of items in the Deque. As a trade-off for this increased flexibility, Deque is somewhat slower than List (but still constant time) when being indexed to get or retrieve elements. The Deque class can also be used as a more flexible alternative to the Queue and Stack classes. Deque is as efficient as Queue and Stack for adding or removing items, but is more flexible: it allows access to all items in the queue, and allows adding or removing from either end. Deque is implemented as a ring buffer, which is grown as necessary. The size of the buffer is doubled whenever the existing capacity is too small to hold all the elements. The type of items stored in the Deque. Must be called whenever there is a structural change in the tree. Causes changeStamp to be changed, which causes any in-progress enumerations to throw exceptions. Checks the given stamp against the current change stamp. If different, the collection has changed during enumeration and an InvalidOperationException must be thrown changeStamp at the start of the enumeration. Create a new Deque that is initially empty. Create a new Deque initialized with the items from the passed collection, in order. A collection of items to initialize the Deque with. Gets the number of items currently stored in the Deque. The last item in the Deque has index Count-1. Getting the count of items in the Deque takes a small constant amount of time. The number of items stored in this Deque. Copies all the items in the Deque into an array. Array to copy to. Starting index in to copy to. Gets or sets the capacity of the Deque. The Capacity is the number of items that this Deque can hold without expanding its internal buffer. Since Deque will automatically expand its buffer when necessary, in almost all cases it is unnecessary to worry about the capacity. However, if it is known that a Deque will contain exactly 1000 items eventually, it can slightly improve efficiency to set the capacity to 1000 up front, so that the Deque does not have to expand automatically. The number of items that this Deque can hold without expanding its internal buffer. The capacity is being set to less than Count, or to too large a value. Trims the amount of memory used by the Deque by changing the Capacity to be equal to Count. If no more items will be added to the Deque, calling TrimToSize will reduce the amount of memory used by the Deque. Removes all items from the Deque. Clearing the Deque takes a small constant amount of time, regardless of how many items are currently in the Deque. Gets or sets an item at a particular index in the Deque. Getting or setting the item at a particular index takes a small constant amount of time, no matter what index is used. The index of the item to retrieve or change. The front item has index 0, and the back item has index Count-1. The value at the indicated index. The index is less than zero or greater than or equal to Count. Enumerates all of the items in the list, in order. The item at index 0 is enumerated first, then the item at index 1, and so on. If the items are added to or removed from the Deque during enumeration, the enumeration ends with an InvalidOperationException. An IEnumerator<T> that enumerates all the items in the list. The Deque has an item added or deleted during the enumeration. Creates the initial buffer and initialized the Deque to contain one initial item. First and only item for the Deque. Inserts a new item at the given index in the Deque. All items at indexes equal to or greater than move up one index in the Deque. The amount of time to insert an item in the Deque is proportional to the distance of index from the closest end of the Deque: O(Min(, Count - )). Thus, inserting an item at the front or end of the Deque is always fast; the middle of of the Deque is the slowest place to insert. The index in the Deque to insert the item at. After the insertion, the inserted item is located at this index. The front item in the Deque has index 0. The item to insert at the given index. is less than zero or greater than Count. Inserts a collection of items at the given index in the Deque. All items at indexes equal to or greater than increase their indices in the Deque by the number of items inserted. The amount of time to insert a collection in the Deque is proportional to the distance of index from the closest end of the Deque, plus the number of items inserted (M): O(M + Min(, Count - )). The index in the Deque to insert the collection at. After the insertion, the first item of the inserted collection is located at this index. The front item in the Deque has index 0. The collection of items to insert at the given index. is less than zero or greater than Count. Removes the item at the given index in the Deque. All items at indexes greater than move down one index in the Deque. The amount of time to delete an item in the Deque is proportional to the distance of index from the closest end of the Deque: O(Min(, Count - 1 - )). Thus, deleting an item at the front or end of the Deque is always fast; the middle of of the Deque is the slowest place to delete. The index in the list to remove the item at. The first item in the list has index 0. is less than zero or greater than or equal to Count. Removes a range of items at the given index in the Deque. All items at indexes greater than move down indices in the Deque. The amount of time to delete items in the Deque is proportional to the distance to the closest end of the Deque: O(Min(, Count - - )). The index in the list to remove the range at. The first item in the list has index 0. The number of items to remove. is less than zero or greater than or equal to Count, or is less than zero or too large. Increase the amount of buffer space. When calling this method, the Deque must not be empty. If start and end are equal, that indicates a completely full Deque. Adds an item to the front of the Deque. The indices of all existing items in the Deque are increased by 1. This method is equivalent to Insert(0, item) but is a little more efficient. Adding an item to the front of the Deque takes a small constant amount of time, regardless of how many items are in the Deque. The item to add. Adds a collection of items to the front of the Deque. The indices of all existing items in the Deque are increased by the number of items inserted. The first item in the added collection becomes the first item in the Deque. This method takes time O(M), where M is the number of items in the . The collection of items to add. Adds an item to the back of the Deque. The indices of all existing items in the Deque are unchanged. This method is equivalent to Insert(Count, item) but is a little more efficient. Adding an item to the back of the Deque takes a small constant amount of time, regardless of how many items are in the Deque. The item to add. Adds an item to the back of the Deque. The indices of all existing items in the Deque are unchanged. This method is equivalent to AddToBack(item). Adding an item to the back of the Deque takes a small constant amount of time, regardless of how many items are in the Deque. The item to add. Adds a collection of items to the back of the Deque. The indices of all existing items in the Deque are unchanged. The last item in the added collection becomes the last item in the Deque. This method takes time O(M), where M is the number of items in the . The collection of item to add. Removes an item from the front of the Deque. The indices of all existing items in the Deque are decreased by 1. This method is equivalent to RemoveAt(0) but is a little more efficient. Removing an item from the front of the Deque takes a small constant amount of time, regardless of how many items are in the Deque. The item that was removed. The Deque is empty. Removes an item from the back of the Deque. The indices of all existing items in the Deque are unchanged. This method is equivalent to RemoveAt(Count-1) but is a little more efficient. Removing an item from the back of the Deque takes a small constant amount of time, regardless of how many items are in the Deque. The Deque is empty. Retreives the item currently at the front of the Deque. The Deque is unchanged. This method is equivalent to deque[0] (except that a different exception is thrown). Retreiving the item at the front of the Deque takes a small constant amount of time, regardless of how many items are in the Deque. The item at the front of the Deque. The Deque is empty. Retreives the item currently at the back of the Deque. The Deque is unchanged. This method is equivalent to deque[deque.Count - 1] (except that a different exception is thrown). Retreiving the item at the back of the Deque takes a small constant amount of time, regardless of how many items are in the Deque. The item at the back of the Deque. The Deque is empty. Creates a new Deque that is a copy of this one. Copying a Deque takes O(N) time, where N is the number of items in this Deque.. A copy of the current deque. Creates a new Deque that is a copy of this one. Copying a Deque takes O(N) time, where N is the number of items in this Deque.. A copy of the current deque. Makes a deep clone of this Deque. A new Deque is created with a clone of each element of this set, by calling ICloneable.Clone on each element. If T is a value type, then each element is copied as if by simple assignment. If T is a reference type, it must implement ICloneable. Otherwise, an InvalidOperationException is thrown. Cloning the Deque takes time O(N), where N is the number of items in the Deque. The cloned Deque. T is a reference type that does not implement ICloneable. 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. The key type of the dictionary. The value type of the dictionary. Creates a new DictionaryBase. Clears the dictionary. This method must be overridden in the derived class. Removes a key from the dictionary. This method must be overridden in the derived class. Key to remove from the dictionary. True if the key was found, false otherwise. Determines if this dictionary contains a key equal to . If so, the value associated with that key is returned through the value parameter. This method must be overridden by the derived class. The key to search for. Returns the value associated with key, if true was returned. True if the dictionary contains key. False if the dictionary does not contain key. 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. Key to add. Value to associated with the key. key is already present in the dictionary Determines whether a given key is found in the dictionary. The default implementation simply calls TryGetValue and returns what it returns. Key to look for in the dictionary. True if the key is present in the dictionary. 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. Key to find in the dictionary. The value associated with the key. Thrown from the get accessor if the key was not found in the dictionary. Shows the string representation of the dictionary. The string representation contains a list of the mappings in the dictionary. The string representation of the dictionary. 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. An IIDictionary<TKey,TValue> that provides read-only access to the dictionary. Returns a collection of the keys in this dictionary. A read-only collection of the keys in this dictionary. 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. Adds a key-value pair to the collection. This implementation calls the Add method with the Key and Value from the item. A KeyValuePair contains the Key and Value to add. 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. A KeyValuePair containing the Key and Value to check for. 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. A KeyValuePair containing the Key and Value to check for. True if the item was found and removed. False otherwise. Check that the given parameter is of the expected generic type. Throw an ArgumentException if it isn't. Expected type of the parameter parameter name parameter value Adds a key-value pair to the collection. If key or value are not of the expected types, an ArgumentException is thrown. If both key and value are of the expected types, the (overridden) Add method is called with the key and value to add. Key to add to the dictionary. Value to add to the dictionary. key or value are not of the expected type for this dictionary. Clears this dictionary. Calls the (overridden) Clear method. Determines if this dictionary contains a key equal to . The dictionary is not changed. Calls the (overridden) ContainsKey method. If key is not of the correct TKey for the dictionary, false is returned. The key to search for. True if the dictionary contains key. False if the dictionary does not contain key. 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, the dictionary is unchanged. Calls the (overridden) Remove method. If key is not of the correct TKey for the dictionary, the dictionary is unchanged. The key to remove. key could not be converted to TKey. Returns an enumerator that enumerates all the entries in the dictionary. Each entry is returned as a DictionaryEntry. The entries are enumerated in the same orders as the (overridden) GetEnumerator method. An enumerator for enumerating all the elements in the OrderedDictionary. Returns an enumerator that enumerates all the entries in the dictionary. Each entry is returned as a DictionaryEntry. The entries are enumerated in the same orders as the (overridden) GetEnumerator method. An enumerator for enumerating all the elements in the OrderedDictionary. Returns whether this dictionary is fixed size. This implemented always returns false. Always returns false. Returns if this dictionary is read-only. This implementation always returns false. Always returns false. Returns a collection of all the keys in the dictionary. The values in this collection will be enumerated in the same order as the (overridden) GetEnumerator method. The collection of keys. Returns a collection of all the values in the dictionary. The values in this collection will be enumerated in the same order as the (overridden) GetEnumerator method. The collection of values. Gets or sets the value associated with a given key. When getting a value, if this key is not found in the collection, then null is returned. When setting a value, the value replaces any existing value in the dictionary. If either the key or value are not of the correct type for this dictionary, an ArgumentException is thrown. The value associated with the key, or null if the key was not present. key could not be converted to TKey, or value could not be converted to TValue. Display the contents of the dictionary in the debugger. This is intentionally private, it is called only from the debugger due to the presence of the DebuggerDisplay attribute. It is similar format to ToString(), but is limited to 250-300 characters or so, so as not to overload the debugger. The string representation of the items in the collection, similar in format to ToString(). A private class that implements ICollection<TKey> and ICollection for the Keys collection. The collection is read-only. Constructor. The dictionary this is associated with. A private class that implements ICollection<TValue> and ICollection for the Values collection. The collection is read-only. A class that wraps a IDictionaryEnumerator around an IEnumerator that enumerates KeyValuePairs. This is useful in implementing IDictionary, because IEnumerator can be implemented with an iterator, but IDictionaryEnumerator cannot. Constructor. The enumerator of KeyValuePairs that is being wrapped. The base implementation for various collections classes that use hash tables as part of their implementation. This class should not (and can not) be used directly by end users; it's only for internal use by the collections package. The Hash does not handle duplicate values. The Hash manages items of type T, and uses a IComparer<ItemTYpe> that hashes compares items to hash items into the table. The structure that has each slot in the hash table. Each slot has three parts: 1. The collision bit. Indicates whether some item visited this slot but had to keep looking because the slot was full. 2. 31-bit full hash value of the item. If zero, the slot is empty. 3. The item itself. The full hash value associated with the value in this slot, or zero if the slot is empty. Is this slot empty? Clear this slot, leaving the collision bit alone. The "Collision" bit indicates that some value hit this slot and collided, so had to try another slot. Constructor. Create a new hash table. The comparer to use to compare items. Gets the current enumeration stamp. Call CheckEnumerationStamp later with this value to throw an exception if the hash table is changed. The current enumeration stamp. Must be called whenever there is a structural change in the tree. Causes changeStamp to be changed, which causes any in-progress enumerations to throw exceptions. Checks the given stamp against the current change stamp. If different, the collection has changed during enumeration and an InvalidOperationException must be thrown changeStamp at the start of the enumeration. Gets the full hash code for an item. Item to get hash code for. The full hash code. It is never zero. Get the initial bucket number and skip amount from the full hash value. The full hash value. Returns the initial bucket. Always in the range 0..(totalSlots - 1). Returns the skip values. Always odd in the range 0..(totalSlots - 1). Gets the full hash value, initial bucket number, and skip amount for an item. Item to get hash value of. Returns the initial bucket. Always in the range 0..(totalSlots - 1). Returns the skip values. Always odd in the range 0..(totalSlots - 1). The full hash value. This is never zero. Make sure there are enough slots in the hash table that items can be inserted into the table. Number of additional items we are inserting. Check if the number of items in the table is small enough that we should shrink the table again. Given the size of a hash table, compute the "secondary shift" value -- the shift that is used to determine the skip amount for collision resolution. The new size of the table. The secondary skip amount. Resize the hash table to the given new size, moving all items into the new hash table. The new size of the hash table. Must be a power of two. Get the number of items in the hash table. The number of items stored in the hash table. Get the number of slots in the hash table. Exposed internally for testing purposes. The number of slots in the hash table. Get or change the load factor. Changing the load factor may cause the size of the table to grow or shrink accordingly. Insert a new item into the hash table. If a duplicate item exists, can replace or do nothing. The item to insert. If true, duplicate items are replaced. If false, nothing is done if a duplicate already exists. If a duplicate was found, returns it (whether replaced or not). True if no duplicate existed, false if a duplicate was found. Deletes an item from the hash table. Item to search for and delete. If true returned, the actual item stored in the hash table (must be equal to , but may not be identical. True if item was found and deleted, false if item wasn't found. Find an item in the hash table. If found, optionally replace it with the finding item. Item to find. If true, replaces the equal item in the hash table with . Returns the equal item found in the table, if true was returned. True if the item was found, false otherwise. Enumerate all of the items in the hash table. The items are enumerated in a haphazard, unpredictable order. An IEnumerator<T> that enumerates the items in the hash table. Enumerate all of the items in the hash table. The items are enumerated in a haphazard, unpredictable order. An IEnumerator that enumerates the items in the hash table. Creates a clone of this hash table. If non-null, this function is applied to each item when cloning. It must be the case that this function does not modify the hash code or equality function. A shallow clone that contains the same items. Serialize the hash table. Called from the serialization infrastructure. Called on deserialization. We cannot deserialize now, because hash codes might not be correct now. We do real deserialization in the OnDeserialization call. Deserialize the hash table. Called from the serialization infrastructure when the object graph has finished deserializing. ListBase is an abstract class that can be used as a base class for a read-write collection that needs to implement the generic IList<T> and non-generic IList collections. The derived class needs to override the following methods: Count, Clear, Insert, RemoveAt, and the indexer. The implementation of all the other methods in IList<T> and IList are handled by ListBase. Creates a new ListBase. The property must be overridden by the derived class to return the number of items in the list. The number of items in the list. This method must be overridden by the derived class to empty the list of all items. The indexer must be overridden by the derived class to get and set values of the list at a particular index. The index in the list to get or set an item at. The first item in the list has index 0, and the last has index Count-1. The item at the given index. is less than zero or greater than or equal to Count. This method must be overridden by the derived class to insert a new item at the given index. The index in the list to insert the item at. After the insertion, the inserted item is located at this index. The first item in the list has index 0. The item to insert at the given index. is less than zero or greater than Count. This method must be overridden by the derived class to remove the item at the given index. The index in the list to remove the item at. The first item in the list has index 0. is less than zero or greater than or equal to Count. Enumerates all of the items in the list, in order. The item at index 0 is enumerated first, then the item at index 1, and so on. The enumerator does not check for changes made to the structure of the list. Thus, changes to the list during enumeration may cause incorrect enumeration or out of range exceptions. Consider overriding this method and adding checks for structural changes. An IEnumerator<T> that enumerates all the items in the list. Determines if the list contains any item that compares equal to . The implementation simply checks whether IndexOf(item) returns a non-negative value. Equality in the list is determined by the default sense of equality for T. If T implements IComparable<T>, the Equals method of that interface is used to determine equality. Otherwise, Object.Equals is used to determine equality. The item to search for. True if the list contains an item that compares equal to . Adds an item to the end of the list. This method is equivalent to calling: Insert(Count, item) The item to add to the list. Searches the list for the first item that compares equal to . If one is found, it is removed. Otherwise, the list is unchanged. Equality in the list is determined by the default sense of equality for T. If T implements IComparable<T>, the Equals method of that interface is used to determine equality. Otherwise, Object.Equals is used to determine equality. The item to remove from the list. True if an item was found and removed that compared equal to . False if no such item was in the list. Copies all the items in the list, in order, to , starting at index 0. The array to copy to. This array must have a size that is greater than or equal to Count. Copies all the items in the list, in order, to , starting at . The array to copy to. This array must have a size that is greater than or equal to Count + arrayIndex. The starting index in to copy to. Copies a range of elements from the list to , starting at . The starting index in the source list of the range to copy. The array to copy to. This array must have a size that is greater than or equal to Count + arrayIndex. The starting index in to copy to. The number of items to copy. Provides a read-only view of this list. The returned IList<T> provides a view of the list that prevents modifications to the list. Use the method to provide access to the list without allowing changes. Since the returned object is just a view, changes to the list will be reflected in the view. An IList<T> that provides read-only access to the list. Finds the first item in the list that satisfies the condition defined by . If no item matches the condition, than the default value for T (null or all-zero) is returned. If the default value for T (null or all-zero) matches the condition defined by , and the list might contain the default value, then it is impossible to distinguish the different between finding the default value and not finding any item. To distinguish these cases, use . A delegate that defined the condition to check for. The first item that satisfies the condition . If no item satisfies that condition, the default value for T is returned. Finds the first item in the list that satisfies the condition defined by . A delegate that defines the condition to check for. If true is returned, this parameter receives the first item in the list that satifies the condition defined by . True if an item that satisfies the condition was found. False if no item in the list satisfies that condition. Finds the last item in the list that satisfies the condition defined by . If no item matches the condition, than the default value for T (null or all-zero) is returned. If the default value for T (null or all-zero) matches the condition defined by , and the list might contain the default value, then it is impossible to distinguish the different between finding the default value and not finding any item. To distinguish these cases, use . A delegate that defined the condition to check for. The last item that satisfies the condition . If no item satisfies that condition, the default value for T is returned. Finds the last item in the list that satisfies the condition defined by . A delegate that defines the condition to check for. If true is returned, this parameter receives the last item in the list that satifies the condition defined by . True if an item that satisfies the condition was found. False if no item in the list satisfies that condition. Finds the index of the first item in the list that satisfies the condition defined by . If no item matches the condition, -1 is returned. A delegate that defined the condition to check for. The index of the first item that satisfies the condition . If no item satisfies that condition, -1 is returned. Finds the index of the first item, in the range of items extending from to the end, that satisfies the condition defined by . If no item matches the condition, -1 is returned. A delegate that defined the condition to check for. The starting index of the range to check. The index of the first item in the given range that satisfies the condition . If no item satisfies that condition, -1 is returned. Finds the index of the first item, in the range of items starting from , that satisfies the condition defined by . If no item matches the condition, -1 is returned. A delegate that defined the condition to check for. The starting index of the range to check. The number of items in range to check. The index of the first item in the given range that satisfies the condition . If no item satisfies that condition, -1 is returned. Finds the index of the last item in the list that satisfies the condition defined by . If no item matches the condition, -1 is returned. A delegate that defined the condition to check for. The index of the last item that satisfies the condition . If no item satisfies that condition, -1 is returned. Finds the index of the last item, in the range of items extending from the beginning of the list to , that satisfies the condition defined by . If no item matches the condition, -1 is returned. A delegate that defined the condition to check for. The ending index of the range to check. The index of the last item in the given range that satisfies the condition . If no item satisfies that condition, -1 is returned. Finds the index of the last item, in the range of items ending at , that satisfies the condition defined by . If no item matches the condition, -1 is returned. A delegate that defined the condition to check for. The ending index of the range to check. The number of items in range to check. The index of the last item in the given range that satisfies the condition . If no item satisfies that condition, -1 is returned. Finds the index of the first item in the list that is equal to . The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals. The item to search fror. The index of the first item in the list that that is equal to . If no item is equal to , -1 is returned. Finds the index of the first item, in the range of items extending from to the end, that is equal to . The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals. The item to search fror. The starting index of the range to check. The index of the first item in the given range that that is equal to . If no item is equal to , -1 is returned. Finds the index of the first item, in the range of items starting from , that is equal to . The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals. The item to search fror. The starting index of the range to check. The number of items in range to check. The index of the first item in the given range that that is equal to . If no item is equal to , -1 is returned. Finds the index of the last item in the list that is equal to . The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals. The item to search fror. The index of the last item in the list that that is equal to . If no item is equal to , -1 is returned. Finds the index of the last item, in the range of items extending from the beginning of the list to , that is equal to . The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals. The item to search fror. The ending index of the range to check. The index of the last item in the given range that that is equal to . If no item is equal to , -1 is returned. Finds the index of the last item, in the range of items ending at , that is equal to . The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals. The item to search for. The ending index of the range to check. The number of items in range to check. The index of the last item in the given range that that is equal to . If no item is equal to , -1 is returned. Returns a view onto a sub-range of this list. Items are not copied; the returned IList<T> is simply a different view onto the same underlying items. Changes to this list are reflected in the view, and vice versa. Insertions and deletions in the view change the size of the view, but insertions and deletions in the underlying list do not. This method can be used to apply an algorithm to a portion of a list. For example: Algorithms.ReverseInPlace(deque.Range(3, 6)) will reverse the 6 items beginning at index 3. The starting index of the view. The number of items in the view. A list that is a view onto the given sub-part of this list. or is negative. + is greater than the size of the list. Convert the given parameter to T. Throw an ArgumentException if it isn't. parameter name parameter value Adds an item to the end of the list. This method is equivalent to calling: Insert(Count, item) The item to add to the list. cannot be converted to T. Removes all the items from the list, resulting in an empty list. Determines if the list contains any item that compares equal to . Equality in the list is determined by the default sense of equality for T. If T implements IComparable<T>, the Equals method of that interface is used to determine equality. Otherwise, Object.Equals is used to determine equality. The item to search for. Find the first occurrence of an item equal to in the list, and returns the index of that item. Equality in the list is determined by the default sense of equality for T. If T implements IComparable<T>, the Equals method of that interface is used to determine equality. Otherwise, Object.Equals is used to determine equality. The item to search for. The index of , or -1 if no item in the list compares equal to . Insert a new item at the given index. The index in the list to insert the item at. After the insertion, the inserted item is located at this index. The first item in the list has index 0. The item to insert at the given index. is less than zero or greater than Count. cannot be converted to T. Returns whether the list is a fixed size. This implementation always returns false. Alway false, indicating that the list is not fixed size. Returns whether the list is read only. This implementation returns the value from ICollection<T>.IsReadOnly, which is by default, false. By default, false, indicating that the list is not read only. Searches the list for the first item that compares equal to . If one is found, it is removed. Otherwise, the list is unchanged. Equality in the list is determined by the default sense of equality for T. If T implements IComparable<T>, the Equals method of that interface is used to determine equality. Otherwise, Object.Equals is used to determine equality. The item to remove from the list. cannot be converted to T. Removes the item at the given index. The index in the list to remove the item at. The first item in the list has index 0. is less than zero or greater than or equal to Count. Gets or sets the value at a particular index in the list. The index in the list to get or set an item at. The first item in the list has index 0, and the last has index Count-1. The item at the given index. is less than zero or greater than or equal to Count. cannot be converted to T. The MultiDictionary class that associates values with a key. Unlike an Dictionary, each key can have multiple values associated with it. When indexing an MultiDictionary, instead of a single value associated with a key, you retrieve an enumeration of values. When constructed, you can chose to allow the same value to be associated with a key multiple times, or only one time. The type of the keys. The of values associated with the keys. A structure to hold the key and the values associated with the key. The number of values must always be 1 or greater in a version that is stored, but can be zero in a dummy version used only for lookups. The key. The number of values. Always at least 1 except in a dummy version for lookups. An array of values. Create a dummy KeyAndValues with just the key, for lookups. The key to use. Make a copy of a KeyAndValues, copying the array. KeyAndValues to copy. A copied version. This class implements IEqualityComparer for KeysAndValues, allowing them to be compared by their keys. An IEqualityComparer on keys is required. Create a new MultiDictionary. The default ordering of keys and values are used. If duplicate values are allowed, multiple copies of the same value can be associated with the same key. For example, the key "foo" could have "a", "a", and "b" associated with it. If duplicate values are not allowed, only one copies of a given value can be associated with the same key, although different keys can have the same value. For example, the key "foo" could have "a" and "b" associated with it, which key "bar" has values "b" and "c" associated with it. The default ordering of keys and values will be used, as defined by TKey and TValue's implementation of IComparable<T> (or IComparable if IComparable<T> is not implemented). If a different ordering should be used, other constructors allow a custom Comparer or IComparer to be passed to changed the ordering. Can the same value be associated with a key multiple times? TKey or TValue does not implement either IComparable<T> or IComparable. Create a new MultiDictionary. If duplicate values are allowed, multiple copies of the same value can be associated with the same key. For example, the key "foo" could have "a", "a", and "b" associated with it. If duplicate values are not allowed, only one copies of a given value can be associated with the same key, although different keys can have the same value. For example, the key "foo" could have "a" and "b" associated with it, which key "bar" has values "b" and "c" associated with it. Can the same value be associated with a key multiple times? An IEqualityComparer<TKey> instance that will be used to compare keys. TValue does not implement either IComparable<TValue> or IComparable. Create a new MultiDictionary. If duplicate values are allowed, multiple copies of the same value can be associated with the same key. For example, the key "foo" could have "a", "a", and "b" associated with it. If duplicate values are not allowed, only one copies of a given value can be associated with the same key, although different keys can have the same value. For example, the key "foo" could have "a" and "b" associated with it, which key "bar" has values "b" and "c" associated with it. Can the same value be associated with a key multiple times? An IEqualityComparer<TKey> instance that will be used to compare keys. An IEqualityComparer<TValue> instance that will be used to compare values. Create a new MultiDictionary. Private constructor, for use by Clone(). Adds a new value to be associated with a key. If duplicate values are permitted, this method always adds a new key-value pair to the dictionary. If duplicate values are not permitted, and already has a value equal to associated with it, then that value is replaced with , and the number of values associate with is unchanged. The key to associate with. The value to associated with . Removes a given value from the values associated with a key. If the last value is removed from a key, the key is removed also. A key to remove a value from. The value to remove. True if was associated with (and was therefore removed). False if was not associated with . Removes a key and all associated values from the dictionary. If the key is not present in the dictionary, it is unchanged and false is returned. The key to remove. True if the key was present and was removed. Returns false if the key was not present. Removes all keys and values from the dictionary. Returns the IEqualityComparer<T> used to compare keys in this dictionary. If the dictionary was created using a comparer, that comparer is returned. Otherwise the default comparer for TKey (EqualityComparer<TKey>.Default) is returned. Returns the IEqualityComparer<T> used to compare values in this dictionary. If the dictionary was created using a comparer, that comparer is returned. Otherwise the default comparer for TValue (EqualityComparer<TValue>.Default) is returned. Determine if two values are equal. First value to compare. Second value to compare. True if the values are equal. Gets the number of key-value pairs in the dictionary. Each value associated with a given key is counted. If duplicate values are permitted, each duplicate value is included in the count. The number of key-value pairs in the dictionary. Checks to see if is associated with in the dictionary. The key to check. The value to check. True if is associated with . Checks to see if the key is present in the dictionary and has at least one value associated with it. The key to check. True if is present and has at least one value associated with it. Returns false otherwise. Enumerate all the keys in the dictionary. An IEnumerator<TKey> that enumerates all of the keys in the dictionary that have at least one value associated with them. Enumerate the values in the a KeyAndValues structure. Can't return the array directly because: a) The array might be larger than the count. b) We can't allow clients to down-cast to the array and modify it. c) We have to abort enumeration if the hash changes. Item with the values to enumerate.. An enumerable that enumerates the items in the KeyAndValues structure. Determines if this dictionary contains a key equal to . If so, all the values associated with that key are returned through the values parameter. The key to search for. Returns all values associated with key, if true was returned. True if the dictionary contains key. False if the dictionary does not contain key. Gets the number of values associated with a given key. The key to count values of. The number of values associated with . If is not present in the dictionary, zero is returned. 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. Cloning the dictionary takes time O(N), where N is the number of key-value pairs in the dictionary. The cloned dictionary. Implements ICloneable.Clone. Makes a shallow clone of this dictionary; i.e., if keys or values are reference types, then they are not cloned. The cloned dictionary. Throw an InvalidOperationException indicating that this type is not cloneable. Type to test. 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. If TKey or TValue is a reference type, it must implement ICloneable. Otherwise, an InvalidOperationException is thrown. Cloning the dictionary takes time O(N log N), where N is the number of key-value pairs in the dictionary. The cloned dictionary. TKey or TValue is a reference type that does not implement ICloneable. MultiDictionaryBase is a base class that can be used to more easily implement a class that associates multiple values to a single key. The class implements the generic IDictionary<TKey, ICollection<TValue>> interface. To use MultiDictionaryBase as a base class, the derived class must override Count, Clear, Add, Remove(TKey), Remove(TKey,TValue), Contains(TKey,TValue), EnumerateKeys, and TryEnumerateValuesForKey. It may wish consider overriding CountValues, CountAllValues, ContainsKey, and EqualValues, but these are not required. The key type of the dictionary. The value type of the dictionary. Creates a new MultiDictionaryBase. Clears the dictionary. This method must be overridden in the derived class. Gets the number of keys in the dictionary. This property must be overridden in the derived class. Enumerate all the keys in the dictionary. This method must be overridden by a derived class. An IEnumerator<TKey> that enumerates all of the keys in the collection that have at least one value associated with them. Enumerate all of the values associated with a given key. This method must be overridden by the derived class. If the key exists and has values associated with it, an enumerator for those values is returned throught . If the key does not exist, false is returned. The key to get values for. If true is returned, this parameter receives an enumerators that enumerates the values associated with that key. True if the key exists and has values associated with it. False otherwise. Adds a key-value pair to the collection. The value part of the pair must be a collection of values to associate with the key. If values are already associated with the given key, the new values are added to the ones associated with that key. A KeyValuePair contains the Key and Value collection to add. Implements IDictionary<TKey, IEnumerable<TValue>>.Add. If the key is already present, and ArgumentException is thrown. Otherwise, a new key is added, and new values are associated with that key. Key to add. Values to associate with that key. The key is already present in the dictionary. Adds new values to be associated with a key. If duplicate values are permitted, this method always adds new key-value pairs to the dictionary. If duplicate values are not permitted, and already has a value equal to one of associated with it, then that value is replaced, and the number of values associate with is unchanged. The key to associate with. A collection of values to associate with . Adds a new key-value pair to the dictionary. This method must be overridden in the derived class. Key to add. Value to associated with the key. key is already present in the dictionary Removes a key from the dictionary. This method must be overridden in the derived class. Key to remove from the dictionary. True if the key was found, false otherwise. Removes a key-value pair from the dictionary. This method must be overridden in the derived class. Key to remove from the dictionary. Associated value to remove from the dictionary. True if the key-value pair was found, false otherwise. Removes a set of values from a given key. If all values associated with a key are removed, then the key is removed also. A KeyValuePair contains a key and a set of values to remove from that key. True if at least one values was found and removed. Removes a collection of values from the values associated with a key. If the last value is removed from a key, the key is removed also. A key to remove values from. A collection of values to remove. The number of values that were present and removed. Remove all of the keys (and any associated values) in a collection of keys. If a key is not present in the dictionary, nothing happens. A collection of key values to remove. The number of keys from the collection that were present and removed. Determines if this dictionary contains a key equal to . If so, all the values associated with that key are returned through the values parameter. This method must be overridden by the derived class. The key to search for. Returns all values associated with key, if true was returned. True if the dictionary contains key. False if the dictionary does not contain key. Determines whether a given key is found in the dictionary. The default implementation simply calls TryEnumerateValuesForKey. It may be appropriate to override this method to provide a more efficient implementation. Key to look for in the dictionary. True if the key is present in the dictionary. Determines if this dictionary contains a key-value pair equal to and . The dictionary is not changed. This method must be overridden in the derived class. The key to search for. The value to search for. True if the dictionary has associated with . Determines if this dictionary contains the given key and all of the values associated with that key.. A key and collection of values to search for. True if the dictionary has associated all of the values in .Value with .Key. If the derived class does not use the default comparison for values, this methods should be overridden to compare two values for equality. This is used for the correct implementation of ICollection.Contains on the Values and KeyValuePairs collections. First value to compare. Second value to compare. True if the values are equal. Gets a count of the number of values associated with a key. The default implementation is slow; it enumerators all of the values (using TryEnumerateValuesForKey) to count them. A derived class may be able to supply a more efficient implementation. The key to count values for. The number of values associated with . Gets a total count of values in the collection. This default implementation is slow; it enumerates all of the keys in the dictionary and calls CountValues on each. A derived class may be able to supply a more efficient implementation. The total number of values associated with all keys in the dictionary. Gets a read-only collection all the keys in this dictionary. An readonly ICollection<TKey> of all the keys in this dictionary. Gets a read-only collection of all the values in the dictionary. A read-only ICollection<TValue> of all the values in the dictionary. Gets a read-only collection of all the value collections in the dictionary. A read-only ICollection<IEnumerable<TValue>> of all the values in the dictionary. Gets a read-only collection of all key-value pairs in the dictionary. If a key has multiple values associated with it, then a key-value pair is present for each value associated with the key. Returns a collection of all of the values in the dictionary associated with , or changes the set of values associated with . If the key is not present in the dictionary, an ICollection enumerating no values is returned. The returned collection of values is read-write, and can be used to modify the collection of values associated with the key. The key to get the values associated with. An ICollection<TValue> with all the values associated with . Gets a collection of all the values in the dictionary associated with , or changes the set of values associated with . If the key is not present in the dictionary, a KeyNotFound exception is thrown. The key to get the values associated with. An IEnumerable<TValue> that enumerates all the values associated with . The given key is not present in the dictionary. Replaces all values associated with with the single value . This implementation simply calls Remove, followed by Add. The key to associate with. The new values to be associated with . Returns true if some values were removed. Returns false if was not present in the dictionary before Replace was called. Replaces all values associated with with a new collection of values. If the collection does not permit duplicate values, and has duplicate items, then only the last of duplicates is added. The key to associate with. The new values to be associated with . Returns true if some values were removed. Returns false if was not present in the dictionary before Replace was called. Shows the string representation of the dictionary. The string representation contains a list of the mappings in the dictionary. The string representation of the dictionary. Display the contents of the dictionary in the debugger. This is intentionally private, it is called only from the debugger due to the presence of the DebuggerDisplay attribute. It is similar format to ToString(), but is limited to 250-300 characters or so, so as not to overload the debugger. The string representation of the items in the collection, similar in format to ToString(). Enumerate all the keys in the dictionary, and for each key, the collection of values for that key. An enumerator to enumerate all the key, ICollection<value> pairs in the dictionary. A private class that provides the ICollection<TValue> for a particular key. This is the collection that is returned from the indexer. The collections is read-write, live, and can be used to add, remove, etc. values from the multi-dictionary. Constructor. Initializes this collection. Dictionary we're using. The key we're looking at. Remove the key and all values associated with it. Add a new values to this key. New values to add. Remove a value currently associated with key. Value to remove. True if item was assocaited with key, false otherwise. Get the number of values associated with the key. A simple function that returns an IEnumerator<TValue> that doesn't yield any values. A helper. An IEnumerator<TValue> that yields no values. Enumerate all the values associated with key. An IEnumerator<TValue> that enumerates all the values associated with key. Determines if the given values is associated with key. Value to check for. True if value is associated with key, false otherwise. A private class that implements ICollection<TKey> and ICollection for the Keys collection. The collection is read-only. Constructor. The dictionary this is associated with. A private class that implements ICollection<TValue> and ICollection for the Values collection. The collection is read-only. A private class that implements ICollection<ICollection<TValue>> and ICollection for the Values collection on IDictionary. The collection is read-only. A private class that implements ICollection<KeyValuePair<TKey,TValue>> and ICollection for the KeyValuePairs collection. The collection is read-only. OrderedBag<T> is a collection that contains items of type T. The item are maintained in a sorted order. Unlike a OrderedSet, duplicate items (items that compare equal to each other) are allows in an OrderedBag.

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

OrderedBag is implemented as a balanced binary tree. Inserting, deleting, and looking up an an element all are done in log(N) + M time, where N is the number of keys in the tree, and M is the current number of copies of the element being handled.

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

Creates a new OrderedBag. The T must implement IComparable<T> or IComparable. The CompareTo method of this interface will be used to compare items in this bag. Items that are null are permitted, and will be sorted before all other items. T does not implement IComparable<TKey>. Creates a new OrderedBag. The passed delegate will be used to compare items in this bag. A delegate to a method that will be used to compare items. Creates a new OrderedBag. The Compare method of the passed comparison object will be used to compare items in this bag. The GetHashCode and Equals methods of the provided IComparer<T> will never be called, and need not be implemented. An instance of IComparer<T> that will be used to compare items. Creates a new OrderedBag. The T must implement IComparable<T> or IComparable. The CompareTo method of this interface will be used to compare items in this bag. The bag is initialized with all the items in the given collection. Items that are null are permitted, and will be sorted before all other items. A collection with items to be placed into the OrderedBag. T does not implement IComparable<TKey>. Creates a new OrderedBag. The passed delegate will be used to compare items in this bag. The bag is initialized with all the items in the given collection. A collection with items to be placed into the OrderedBag. A delegate to a method that will be used to compare items. Creates a new OrderedBag. The Compare method of the passed comparison object will be used to compare items in this bag. The bag is initialized with all the items in the given collection. The GetHashCode and Equals methods of the provided IComparer<T> will never be called, and need not be implemented. A collection with items to be placed into the OrderedBag. An instance of IComparer<T> that will be used to compare items. Creates a new OrderedBag given a comparer and a tree that contains the data. Used internally for Clone. Comparer for the bag. Data for the bag. Makes a shallow clone of this bag; i.e., if items of the bag are reference types, then they are not cloned. If T is a value type, then each element is copied as if by simple assignment. Cloning the bag takes time O(N), where N is the number of items in the bag. The cloned bag. Makes a shallow clone of this bag; i.e., if items of the bag are reference types, then they are not cloned. If T is a value type, then each element is copied as if by simple assignment. Cloning the bag takes time O(N), where N is the number of items in the bag. The cloned bag. Makes a deep clone of this bag. A new bag is created with a clone of each element of this bag, by calling ICloneable.Clone on each element. If T is a value type, then each element is copied as if by simple assignment. If T is a reference type, it must implement ICloneable. Otherwise, an InvalidOperationException is thrown. Cloning the bag takes time O(N log N), where N is the number of items in the bag. The cloned bag. T is a reference type that does not implement ICloneable. Returns the IComparer<T> used to compare items in this bag. If the bag was created using a comparer, that comparer is returned. If the bag was created using a comparison delegate, then a comparer equivalent to that delegate is returned. Otherwise the default comparer for T (Comparer<T>.Default) is returned. Returns the number of items in the bag. The size of the bag is returned in constant time. The number of items in the bag. Returns the number of copies of in the bag. More precisely, returns the number of items in the bag that compare equal to . NumberOfCopies() takes time O(log N + M), where N is the total number of items in the bag, and M is the number of copies of in the bag. The item to search for in the bag. The number of items in the bag that compare equal to . Returns an enumerator that enumerates all the items in the bag. The items are enumerated in sorted order.

Typically, this method is not called directly. Instead the "foreach" statement is used to enumerate the items, which uses this method implicitly.

If an item is added to or deleted from the bag while it is being enumerated, then the enumeration will end with an InvalidOperationException.

Enumeration all the items in the bag takes time O(N), where N is the number of items in the bag.

An enumerator for enumerating all the items in the OrderedBag.
Determines if this bag contains an item equal to . The bag is not changed. Searching the bag for an item takes time O(log N), where N is the number of items in the bag. The item to search for. True if the bag contains . False if the bag does not contain . Enumerates all of the items in this bag that are equal to , according to the comparison mechanism that was used when the bag was created. The bag is not changed. If the bag does contain an item equal to , then the enumeration contains no items. Enumeration the items in the bag equal to takes time O(log N + M), where N is the total number of items in the bag, and M is the number of items equal to . The item to search for. An IEnumerable<T> that enumerates all the items in the bag equal to . Enumerates all the items in the bag, but enumerates equal items just once, even if they occur multiple times in the bag. If the bag is changed while items are being enumerated, the enumeration will terminate with an InvalidOperationException. An IEnumerable<T> that enumerates the unique items. Get the item by its index in the sorted order. The smallest item has index 0, the next smallest item has index 1, and the largest item has index Count-1. The indexer takes time O(log N), which N is the number of items in the set. The index to get the item by. The item at the given index. is less than zero or greater than or equal to Count. Get the index of the given item in the sorted order. The smallest item has index 0, the next smallest item has index 1, and the largest item has index Count-1. If multiple equal items exist, the largest index of the equal items is returned. Finding the index takes time O(log N), which N is the number of items in the set. The item to get the index of. The index of the last item in the sorted bag equal to , or -1 if the item is not present in the set. Get the index of the given item in the sorted order. The smallest item has index 0, the next smallest item has index 1, and the largest item has index Count-1. If multiple equal items exist, the smallest index of the equal items is returned. Finding the index takes time O(log N), which N is the number of items in the set. The item to get the index of. The index of the first item in the sorted bag equal to , or -1 if the item is not present in the set. Adds a new item to the bag. Since bags can contain duplicate items, the item is added even if the bag already contains an item equal to . In this case, the new item is placed after all equal items already present in the bag. Adding an item takes time O(log N), where N is the number of items in the bag. The item to add to the bag. Adds all the items in to the bag. Adding the collection takes time O(M log N), where N is the number of items in the bag, and M is the number of items in . A collection of items to add to the bag. is null. Searches the bag for one item equal to , and if found, removes it from the bag. If not found, the bag is unchanged. If more than one item equal to , the item that was last inserted is removed. Equality between items is determined by the comparison instance or delegate used to create the bag. Removing an item from the bag takes time O(log N), where N is the number of items in the bag. The item to remove. True if was found and removed. False if was not in the bag. Searches the bag for all items equal to , and removes all of them from the bag. If not found, the bag is unchanged. Equality between items is determined by the comparison instance or delegate used to create the bag. RemoveAllCopies() takes time O(M log N), where N is the total number of items in the bag, and M is the number of items equal to . The item to remove. The number of copies of that were found and removed. Removes all the items in from the bag. Items not present in the bag are ignored. Equality between items is determined by the comparison instance or delegate used to create the bag. Removing the collection takes time O(M log N), where N is the number of items in the bag, and M is the number of items in . A collection of items to remove from the bag. The number of items removed from the bag. is null. Removes all items from the bag. Clearing the bag takes a constant amount of time, regardless of the number of items in it. If the collection is empty, throw an invalid operation exception. The bag is empty. Returns the first item in the bag: the item that would appear first if the bag was enumerated. This is also the smallest item in the bag. GetFirst() takes time O(log N), where N is the number of items in the bag. The first item in the bag. If more than one item is smallest, the first one added is returned. The bag is empty. Returns the last item in the bag: the item that would appear last if the bag was enumerated. This is also the largest item in the bag. GetLast() takes time O(log N), where N is the number of items in the bag. The last item in the bag. If more than one item is largest, the last one added is returned. The bag is empty. Removes the first item in the bag. This is also the smallest item in the bag. RemoveFirst() takes time O(log N), where N is the number of items in the bag. The item that was removed, which was the smallest item in the bag. The bag is empty. Removes the last item in the bag. This is also the largest item in the bag. RemoveLast() takes time O(log N), where N is the number of items in the bag. The item that was removed, which was the largest item in the bag. The bag is empty. Check that this bag and another bag were created with the same comparison mechanism. Throws exception if not compatible. Other bag to check comparision mechanism. If otherBag and this bag don't use the same method for comparing items. is null. Determines if this bag is a superset of another bag. Neither bag is modified. This bag is a superset of if every element in is also in this bag, at least the same number of times. IsSupersetOf is computed in time O(M log N), where M is the size of the , and N is the size of the this set. OrderedBag to compare to. True if this is a superset of . This bag and don't use the same method for comparing items. is null. Determines if this bag is a proper superset of another bag. Neither bag is modified. This bag is a proper superset of if every element in is also in this bag, at least the same number of times. Additional, this bag must have strictly more items than . IsProperSupersetOf is computed in time O(M log N), where M is the number of unique items in . OrderedBag to compare to. True if this is a proper superset of . This bag and don't use the same method for comparing items. is null. Determines if this bag is a subset of another bag. Neither bag is modified. This bag is a subset of if every element in this bag is also in , at least the same number of times. IsSubsetOf is computed in time O(N log M), where M is the size of the , and N is the size of the this bag. OrderedBag to compare to. True if this is a subset of . This bag and don't use the same method for comparing items. is null. Determines if this bag is a proper subset of another bag. Neither bag is modified. This bag is a subset of if every element in this bag is also in , at least the same number of times. Additional, this bag must have strictly fewer items than . IsSubsetOf is computed in time O(N log M), where M is the size of the , and N is the size of the this bag. OrderedBag to compare to. True if this is a proper subset of . This bag and don't use the same method for comparing items. is null. Determines if this bag is disjoint from another bag. Two bags are disjoint if no item from one set is equal to any item in the other bag. The answer is computed in time O(N), where N is the size of the smaller set. Bag to check disjointness with. True if the two bags are disjoint, false otherwise. This bag and don't use the same method for comparing items. Determines if this bag is equal to another bag. This bag is equal to if they contain the same items, each the same number of times. IsEqualTo is computed in time O(N), where N is the number of items in this bag. OrderedBag to compare to True if this bag is equal to , false otherwise. This bag and don't use the same method for comparing items. Computes the union of this bag with another bag. The union of two bags is all items from both of the bags. If an item appears X times in one bag, and Y times in the other bag, the union contains the item Maximum(X,Y) times. This bag receives the union of the two bags, the other bag is unchanged. The union of two bags is computed in time O(M + N log M), where M is the size of the larger bag, and N is the size of the smaller bag. Bag to union with. This bag and don't use the same method for comparing items. is null. Computes the union of this bag with another bag. The union of two bags is all items from both of the bags. If an item appears X times in one bag, and Y times in the other bag, the union contains the item Maximum(X,Y) times. A new bag is created with the union of the bags and is returned. This bag and the other bag are unchanged. The union of two bags is computed in time O(M + N log M), where M is the size of the larger bag, and N is the size of the smaller bag. Bag to union with. The union of the two bags. This bag and don't use the same method for comparing items. is null. Computes the sum of this bag with another bag. The sum of two bags is all items from both of the bags. If an item appears X times in one bag, and Y times in the other bag, the sum contains the item (X+Y) times. This bag receives the sum of the two bags, the other bag is unchanged. The sum of two bags is computed in time O(M + N log M), where M is the size of the larger bag, and N is the size of the smaller bag. Bag to sum with. This bag and don't use the same method for comparing items. is null. Computes the sum of this bag with another bag. he sum of two bags is all items from both of the bags. If an item appears X times in one bag, and Y times in the other bag, the sum contains the item (X+Y) times. A new bag is created with the sum of the bags and is returned. This bag and the other bag are unchanged. The sum of two bags is computed in time O(M + N log M), where M is the size of the larger bag, and N is the size of the smaller bag. Bag to sum with. The sum of the two bags. This bag and don't use the same method for comparing items. is null. Computes the intersection of this bag with another bag. The intersection of two bags is all items that appear in both of the bags. If an item appears X times in one bag, and Y times in the other bag, the sum contains the item Minimum(X,Y) times. This bag receives the intersection of the two bags, the other bag is unchanged. When equal items appear in both bags, the intersection will include an arbitrary choice of one of the two equal items. The intersection of two bags is computed in time O(N log M), where M is the size of the larger bag, and N is the size of the smaller bag. Bag to intersection with. This bag and don't use the same method for comparing items. is null. Computes the intersection of this bag with another bag. The intersection of two bags is all items that appear in both of the bags. If an item appears X times in one bag, and Y times in the other bag, the sum contains the item Minimum(X,Y) times. A new bag is created with the intersection of the bags and is returned. This bag and the other bag are unchanged. When equal items appear in both bags, the intersection will include an arbitrary choice of one of the two equal items. The intersection of two bags is computed in time O(N log M), where M is the size of the larger bag, and N is the size of the smaller bag. Bag to intersection with. The intersection of the two bags. This bag and don't use the same method for comparing items. is null. Computes the difference of this bag with another bag. The difference of these two bags is all items that appear in this bag, but not in . If an item appears X times in this bag, and Y times in the other bag, the difference contains the item X - Y times (zero times if Y >= X). This bag receives the difference of the two bags; the other bag is unchanged. The difference of two bags is computed in time O(M + N log M), where M is the size of the larger bag, and N is the size of the smaller bag. Bag to difference with. This bag and don't use the same method for comparing items. is null. Computes the difference of this bag with another bag. The difference of these two bags is all items that appear in this bag, but not in . If an item appears X times in this bag, and Y times in the other bag, the difference contains the item X - Y times (zero times if Y >= X). A new bag is created with the difference of the bags and is returned. This bag and the other bag are unchanged. The difference of two bags is computed in time O(M + N log M), where M is the size of the larger bag, and N is the size of the smaller bag. Bag to difference with. The difference of the two bags. This bag and don't use the same method for comparing items. is null. Computes the symmetric difference of this bag with another bag. The symmetric difference of two bags is all items that appear in either of the bags, but not both. If an item appears X times in one bag, and Y times in the other bag, the symmetric difference contains the item AbsoluteValue(X - Y times). This bag receives the symmetric difference of the two bags; the other bag is unchanged. The symmetric difference of two bags is computed in time O(M + N), where M is the size of the larger bag, and N is the size of the smaller bag. Bag to symmetric difference with. This bag and don't use the same method for comparing items. is null. Computes the symmetric difference of this bag with another bag. The symmetric difference of two bags is all items that appear in either of the bags, but not both. If an item appears X times in one bag, and Y times in the other bag, the symmetric difference contains the item AbsoluteValue(X - Y times). A new bag is created with the symmetric difference of the bags and is returned. This bag and the other bag are unchanged. The symmetric difference of two bags is computed in time O(M + N), where M is the size of the larger bag, and N is the size of the smaller bag. Bag to symmetric difference with. The symmetric difference of the two bags. This bag and don't use the same method for comparing items. is null. Get a read-only list view of the items in this ordered bag. The items in the list are in sorted order, with the smallest item at index 0. This view does not copy any data, and reflects any changes to the underlying OrderedBag. A read-only IList<T> view onto this OrderedBag. The nested class that provides a read-only list view of all or part of the collection. Create a new list view wrapped the given set. The ordered bag to wrap. Range tester that defines the range being used. If true, then rangeTester defines the entire tree. Used to optimize some operations. Is the view enuemerated in reverse order? Returns a View collection that can be used for enumerating the items in the bag in reversed order.

Typically, this method is used in conjunction with a foreach statement. For example: foreach(T item in bag.Reversed()) { // process item }

If an item is added to or deleted from the bag while the View is being enumerated, then the enumeration will end with an InvalidOperationException.

Calling Reverse does not copy the data in the tree, and the operation takes constant time.

An OrderedBag.View of items in reverse order.
Returns a View collection that can be used for enumerating a range of the items in the bag. Only items that are greater than and less than are included. The items are enumerated in sorted order. Items equal to the end points of the range can be included or excluded depending on the and parameters.

If is greater than or equal to , the returned collection is empty.

Typically, this method is used in conjunction with a foreach statement. For example: foreach(T item in bag.Range(from, true, to, false)) { // process item }

If an item is added to or deleted from the bag while the View is being enumerated, then the enumeration will end with an InvalidOperationException.

Calling Range does not copy the data in the tree, and the operation takes constant time.

The lower bound of the range. If true, the lower bound is inclusive--items equal to the lower bound will be included in the range. If false, the lower bound is exclusive--items equal to the lower bound will not be included in the range. The upper bound of the range. If true, the upper bound is inclusive--items equal to the upper bound will be included in the range. If false, the upper bound is exclusive--items equal to the upper bound will not be included in the range. An OrderedBag.View of items in the given range.
Returns a View collection that can be used for enumerating a range of the items in the bag. Only items that are greater than (and optionally, equal to) are included. The items are enumerated in sorted order. Items equal to can be included or excluded depending on the parameter.

Typically, this method is used in conjunction with a foreach statement. For example: foreach(T item in bag.RangeFrom(from, true)) { // process item }

If an item is added to or deleted from the bag while the View is being enumerated, then the enumeration will end with an InvalidOperationException.

Calling RangeFrom does not copy the data in the tree, and the operation takes constant time.

The lower bound of the range. If true, the lower bound is inclusive--items equal to the lower bound will be included in the range. If false, the lower bound is exclusive--items equal to the lower bound will not be included in the range. An OrderedBag.View of items in the given range.
Returns a View collection that can be used for enumerating a range of the items in the bag. Only items that are less than (and optionally, equal to) are included. The items are enumerated in sorted order. Items equal to can be included or excluded depending on the parameter.

Typically, this method is used in conjunction with a foreach statement. For example: foreach(T item in bag.RangeTo(to, false)) { // process item }

If an item is added to or deleted from the bag while the View is being enumerated, then the enumeration will end with an InvalidOperationException.

Calling RangeTo does not copy the data in the tree, and the operation takes constant time.

The upper bound of the range. If true, the upper bound is inclusive--items equal to the upper bound will be included in the range. If false, the upper bound is exclusive--items equal to the upper bound will not be included in the range. An OrderedBag.View of items in the given range.
The OrderedBag<T>.View class is used to look at a subset of the items inside an ordered bag. It is returned from the Range, RangeTo, RangeFrom, and Reversed methods.

Views are dynamic. If the underlying bag changes, the view changes in sync. If a change is made to the view, the underlying bag changes accordingly.

Typically, this class is used in conjunction with a foreach statement to enumerate the items in a subset of the OrderedBag. For example:

foreach(T item in bag.Range(from, to)) { // process item }
Initialize the view. OrderedBag being viewed Range tester that defines the range being used. If true, then rangeTester defines the entire tree. Is the view enuemerated in reverse order? Determine if the given item lies within the bounds of this view. Item to test. True if the item is within the bounds of this view. Enumerate all the items in this view. An IEnumerator<T> with the items in this view. Number of items in this view. Number of items that lie within the bounds the view. Removes all the items within this view from the underlying bag. The following removes all the items that start with "A" from an OrderedBag. bag.Range("A", "B").Clear(); Adds a new item to the bag underlying this View. If the bag already contains an item equal to , that item is replaces with . If is outside the range of this view, an InvalidOperationException is thrown. Equality between items is determined by the comparison instance or delegate used to create the bag. Adding an item takes time O(log N), where N is the number of items in the bag. The item to add. True if the bag already contained an item equal to (which was replaced), false otherwise. Searches the underlying bag for an item equal to , and if found, removes it from the bag. If not found, the bag is unchanged. If the item is outside the range of this view, the bag is unchanged. Equality between items is determined by the comparison instance or delegate used to create the bag. Removing an item from the bag takes time O(log N), where N is the number of items in the bag. The item to remove. True if was found and removed. False if was not in the bag, or was outside the range of this view. Determines if this view of the bag contains an item equal to . The bag is not changed. If Searching the bag for an item takes time O(log N), where N is the number of items in the bag. The item to search for. True if the bag contains , and is within the range of this view. False otherwise. Get the first index of the given item in the view. The smallest item in the view has index 0, the next smallest item has index 1, and the largest item has index Count-1. Finding the index takes time O(log N), which N is the number of items in the set. The item to get the index of. The index of the first item in the view equal to , or -1 if the item is not present in the view. Get the last index of the given item in the view. The smallest item in the view has index 0, the next smallest item has index 1, and the largest item has index Count-1. Finding the index takes time O(log N), which N is the number of items in the set. The item to get the index of. The index of the last item in the view equal to , or -1 if the item is not present in the view. Get the item by its index in the sorted order. The smallest item in the view has index 0, the next smallest item has index 1, and the largest item has index Count-1. The indexer takes time O(log N), which N is the number of items in the set. The index to get the item by. The item at the given index. is less than zero or greater than or equal to Count. Get a read-only list view of the items in this view. The items in the list are in sorted order, with the smallest item at index 0. This view does not copy any data, and reflects any changes to the underlying OrderedSet. A read-only IList<T> view onto this view. Creates a new View that has the same items as this view, in the reversed order. A new View that has the reversed order of this view, with the same upper and lower bounds. Returns the first item in this view: the item that would appear first if the view was enumerated. GetFirst() takes time O(log N), where N is the number of items in the bag. The first item in the view. The view has no items in it. Returns the last item in the view: the item that would appear last if the view was enumerated. GetLast() takes time O(log N), where N is the number of items in the bag. The last item in the view. The view has no items in it. The OrderedMultiDictionary class that associates values with a key. Unlike an OrderedDictionary, each key can have multiple values associated with it. When indexing an OrderedMultidictionary, instead of a single value associated with a key, you retrieve an enumeration of values. All of the key are stored in sorted order. Also, the values associated with a given key are kept in sorted order as well. When constructed, you can chose to allow the same value to be associated with a key multiple times, or only one time. The type of the keys. The of values associated with the keys. Helper function to create a new KeyValuePair struct. The key. The value. A new KeyValuePair. Helper function to create a new KeyValuePair struct with a default value. The key. A new KeyValuePair. Get a RangeTester that maps to the range of all items with the given key. Key in the given range. A RangeTester delegate that selects the range of items with that range. Gets a range tester that defines a range by first and last items. The lower bound. True if the lower bound is inclusive, false if exclusive. The upper bound. True if the upper bound is inclusive, false if exclusive. A RangeTester delegate that tests for a key in the given range. Gets a range tester that defines a range by a lower bound. The lower bound. True if the lower bound is inclusive, false if exclusive. A RangeTester delegate that tests for a key in the given range. Gets a range tester that defines a range by upper bound. The upper bound. True if the upper bound is inclusive, false if exclusive. A RangeTester delegate that tests for a key in the given range. Create a new OrderedMultiDictionary. The default ordering of keys and values are used. If duplicate values are allowed, multiple copies of the same value can be associated with the same key. For example, the key "foo" could have "a", "a", and "b" associated with it. If duplicate values are not allowed, only one copies of a given value can be associated with the same key, although different keys can have the same value. For example, the key "foo" could have "a" and "b" associated with it, which key "bar" has values "b" and "c" associated with it. The default ordering of keys and values will be used, as defined by TKey and TValue's implementation of IComparable<T> (or IComparable if IComparable<T> is not implemented). If a different ordering should be used, other constructors allow a custom Comparer or IComparer to be passed to changed the ordering. Can the same value be associated with a key multiple times? TKey or TValue does not implement either IComparable<T> or IComparable. Create a new OrderedMultiDictionary. If duplicate values are allowed, multiple copies of the same value can be associated with the same key. For example, the key "foo" could have "a", "a", and "b" associated with it. If duplicate values are not allowed, only one copies of a given value can be associated with the same key, although different keys can have the same value. For example, the key "foo" could have "a" and "b" associated with it, which key "bar" has values "b" and "c" associated with it. Can the same value be associated with a key multiple times? A delegate to a method that will be used to compare keys. TValue does not implement either IComparable<TValue> or IComparable. Create a new OrderedMultiDictionary. If duplicate values are allowed, multiple copies of the same value can be associated with the same key. For example, the key "foo" could have "a", "a", and "b" associated with it. If duplicate values are not allowed, only one copies of a given value can be associated with the same key, although different keys can have the same value. For example, the key "foo" could have "a" and "b" associated with it, which key "bar" has values "b" and "c" associated with it. Can the same value be associated with a key multiple times? A delegate to a method that will be used to compare keys. A delegate to a method that will be used to compare values. Create a new OrderedMultiDictionary. If duplicate values are allowed, multiple copies of the same value can be associated with the same key. For example, the key "foo" could have "a", "a", and "b" associated with it. If duplicate values are not allowed, only one copies of a given value can be associated with the same key, although different keys can have the same value. For example, the key "foo" could have "a" and "b" associated with it, which key "bar" has values "b" and "c" associated with it. Can the same value be associated with a key multiple times? An IComparer<TKey> instance that will be used to compare keys. TValue does not implement either IComparable<TValue> or IComparable. Create a new OrderedMultiDictionary. If duplicate values are allowed, multiple copies of the same value can be associated with the same key. For example, the key "foo" could have "a", "a", and "b" associated with it. If duplicate values are not allowed, only one copies of a given value can be associated with the same key, although different keys can have the same value. For example, the key "foo" could have "a" and "b" associated with it, which key "bar" has values "b" and "c" associated with it. Can the same value be associated with a key multiple times? An IComparer<TKey> instance that will be used to compare keys. An IComparer<TValue> instance that will be used to compare values. Create a new OrderedMultiDictionary. Used internally for cloning. Can the same value be associated with a key multiple times? Number of keys. An IComparer<TKey> instance that will be used to compare keys. An IComparer<TValue> instance that will be used to compare values. Comparer of key-value pairs. The red-black tree used to store the data. Adds a new value to be associated with a key. If duplicate values are permitted, this method always adds a new key-value pair to the dictionary. If duplicate values are not permitted, and already has a value equal to associated with it, then that value is replaced with , and the number of values associate with is unchanged. The key to associate with. The value to associated with . Removes a given value from the values associated with a key. If the last value is removed from a key, the key is removed also. A key to remove a value from. The value to remove. True if was associated with (and was therefore removed). False if was not associated with . Removes a key and all associated values from the dictionary. If the key is not present in the dictionary, it is unchanged and false is returned. The key to remove. True if the key was present and was removed. Returns false if the key was not present. Removes all keys and values from the dictionary. Returns the IComparer<T> used to compare keys in this dictionary. If the dictionary was created using a comparer, that comparer is returned. If the dictionary was created using a comparison delegate, then a comparer equivalent to that delegate is returned. Otherwise the default comparer for TKey (Comparer<TKey>.Default) is returned. Returns the IComparer<T> used to compare values in this dictionary. If the dictionary was created using a comparer, that comparer is returned. If the dictionary was created using a comparison delegate, then a comparer equivalent to that delegate is returned. Otherwise the default comparer for TValue (Comparer<TValue>.Default) is returned. Determine if two values are equal. First value to compare. Second value to compare. True if the values are equal. Gets the number of key-value pairs in the dictionary. Each value associated with a given key is counted. If duplicate values are permitted, each duplicate value is included in the count. The number of key-value pairs in the dictionary. Checks to see if is associated with in the dictionary. The key to check. The value to check. True if is associated with . Checks to see if the key is present in the dictionary and has at least one value associated with it. The key to check. True if is present and has at least one value associated with it. Returns false otherwise. A private helper method that returns an enumerable that enumerates all the keys in a range. Defines the range to enumerate. Should the keys be enumerated in reverse order? An IEnumerable<TKey> that enumerates the keys in the given range. in the dictionary. A private helper method for the indexer to return an enumerable that enumerates all the values for a key. This is separate method because indexers can't use the yield return construct. An IEnumerable<TValue> that can be used to enumerate all the values associated with . If is not present, an enumerable that enumerates no items is returned. Determines if this dictionary contains a key equal to . If so, all the values associated with that key are returned through the values parameter. The key to search for. Returns all values associated with key, if true was returned. True if the dictionary contains key. False if the dictionary does not contain key. Enumerate all of the keys in the dictionary. An IEnumerator<TKey> of all of the keys in the dictionary. Gets the number of values associated with a given key. The key to count values of. The number of values associated with . If is not present in the dictionary, zero is returned. Gets a total count of values in the collection. The total number of values associated with all keys in the dictionary. 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. Cloning the dictionary takes time O(N), where N is the number of key-value pairs in the dictionary. The cloned dictionary. Implements ICloneable.Clone. Makes a shallow clone of this dictionary; i.e., if keys or values are reference types, then they are not cloned. The cloned dictionary. Throw an InvalidOperationException indicating that this type is not cloneable. Type to test. 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. If TKey or TValue is a reference type, it must implement ICloneable. Otherwise, an InvalidOperationException is thrown. Cloning the dictionary takes time O(N log N), where N is the number of key-value pairs in the dictionary. The cloned dictionary. TKey or TValue is a reference type that does not implement ICloneable. Gets a read-only collection of all key-value pairs in the dictionary. If a key has multiple values associated with it, then a key-value pair is present for each value associated with the key. A private class that implements ICollection<KeyValuePair<TKey,TValue>> and ICollection for the KeyValuePairs collection. The collection is read-only. Returns a View collection that can be used for enumerating the keys and values in the collection in reversed order.

Typically, this method is used in conjunction with a foreach statement. For example: foreach(KeyValuePair<TKey, TValue> pair in dictionary.Reversed()) { // process pair }

If an entry is added to or deleted from the dictionary while the View is being enumerated, then the enumeration will end with an InvalidOperationException.

Calling Reverse does not copy the data in the dictionary, and the operation takes constant time.

An OrderedDictionary.View of key-value pairs in reverse order.
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 less than 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 and parameters.

If is greater than or equal to , the returned collection is empty.

The sorted order of the keys is determined by the comparison instance or delegate used to create the dictionary.

Typically, this property is used in conjunction with a foreach statement. For example:

foreach(KeyValuePair<TKey, TValue> pair in dictionary.Range(from, true, to, false)) { // process pair }

Calling Range does not copy the data in the dictionary, and the operation takes constant time.

The lower bound of the range. If true, the lower bound is inclusive--keys equal to the lower bound will be included in the range. If false, the lower bound is exclusive--keys equal to the lower bound will not be included in the range. The upper bound of the range. If true, the upper bound is inclusive--keys equal to the upper bound will be included in the range. If false, the upper bound is exclusive--keys equal to the upper bound will not be included in the range. An OrderedMultiDictionary.View of key-value pairs in the given range.
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) are included. The keys are enumerated in sorted order. Keys equal to can be included or excluded depending on the parameter.

The sorted order of the keys is determined by the comparison instance or delegate used to create the dictionary.

Typically, this property is used in conjunction with a foreach statement. For example:

foreach(KeyValuePair<TKey, TValue> pair in dictionary.RangeFrom(from, true)) { // process pair }

Calling RangeFrom does not copy of the data in the dictionary, and the operation takes constant time.

The lower bound of the range. If true, the lower bound is inclusive--keys equal to the lower bound will be included in the range. If false, the lower bound is exclusive--keys equal to the lower bound will not be included in the range. An OrderedMultiDictionary.View of key-value pairs in the given range.
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) are included. The items are enumerated in sorted order. Items equal to can be included or excluded depending on the parameter.

The sorted order of the keys is determined by the comparison instance or delegate used to create the dictionary.

Typically, this property is used in conjunction with a foreach statement. For example:

foreach(KeyValuePair<TKey, TValue> pair in dictionary.RangeFrom(from, false)) { // process pair }

Calling RangeTo does not copy the data in the dictionary, and the operation takes constant time.

The upper bound of the range. If true, the upper bound is inclusive--keys equal to the upper bound will be included in the range. If false, the upper bound is exclusive--keys equal to the upper bound will not be included in the range. An OrderedMultiDictionary.View of key-value pairs in the given range.
The OrderedMultiDictionary<TKey,TValue>.View class is used to look at a subset of the keys and values inside an ordered multi-dictionary. It is returned from the Range, RangeTo, RangeFrom, and Reversed methods.

Views are dynamic. If the underlying dictionary changes, the view changes in sync. If a change is made to the view, the underlying dictionary changes accordingly.

Typically, this class is used in conjunction with a foreach statement to enumerate the keys and values in a subset of the OrderedMultiDictionary. For example:

foreach(KeyValuePair<TKey, TValue> pair in dictionary.Range(from, to)) { // process pair }
Initialize the View. Associated OrderedMultiDictionary to be viewed. Range tester that defines the range being used. If true, then rangeTester defines the entire tree. Is the view enuemerated in reverse order? Determine if the given key lies within the bounds of this view. Key to test. True if the key is within the bounds of this view. Enumerate all the keys in the dictionary. An IEnumerator<TKey> that enumerates all of the keys in the collection that have at least one value associated with them. Enumerate all of the values associated with a given key. If the key exists and has values associated with it, an enumerator for those values is returned throught . If the key does not exist, false is returned. The key to get values for. If true is returned, this parameter receives an enumerators that enumerates the values associated with that key. True if the key exists and has values associated with it. False otherwise. Number of keys in this view. Number of keys that lie within the bounds the view. Tests if the key is present in the part of the dictionary being viewed. Key to check True if the key is within this view. Tests if the key-value pair is present in the part of the dictionary being viewed. Key to check for. Value to check for. True if the key-value pair is within this view. Gets the number of values associated with a given key. The key to count values of. The number of values associated with . If is not present in this view, zero is returned. Adds the given key-value pair to the underlying dictionary of this view. If is not within the range of this view, an ArgumentException is thrown. is not within the range of this view. Removes the key (and associated value) from the underlying dictionary of this view. If no key in the view is equal to the passed key, the dictionary and view are unchanged. The key to remove. True if the key was found and removed. False if the key was not found. Removes the key and value from the underlying dictionary of this view. that is equal to the passed in key. If no key in the view is equal to the passed key, or has the given value associated with it, the dictionary and view are unchanged. The key to remove. The value to remove. True if the key-value pair was found and removed. False if the key-value pair was not found. Removes all the keys and values within this view from the underlying OrderedMultiDictionary. The following removes all the keys that start with "A" from an OrderedMultiDictionary. dictionary.Range("A", "B").Clear(); Creates a new View that has the same keys and values as this, in the reversed order. A new View that has the reversed order of this view. OrderedSet<T> is a collection that contains items of type T. The item are maintained in a sorted order, and duplicate items are not allowed. Each item has an index in the set: the smallest item has index 0, the next smallest item has index 1, and so forth.

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

OrderedSet 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.

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

Creates a new OrderedSet. The T must implement IComparable<T> or IComparable. The CompareTo method of this interface will be used to compare items in this set. Items that are null are permitted, and will be sorted before all other items. T does not implement IComparable<TKey>. Creates a new OrderedSet. The passed delegate will be used to compare items in this set. A delegate to a method that will be used to compare items. Creates a new OrderedSet. The Compare method of the passed comparison object will be used to compare items in this set. The GetHashCode and Equals methods of the provided IComparer<T> will never be called, and need not be implemented. An instance of IComparer<T> that will be used to compare items. Creates a new OrderedSet. The T must implement IComparable<T> or IComparable. The CompareTo method of this interface will be used to compare items in this set. The set is initialized with all the items in the given collection. Items that are null are permitted, and will be sorted before all other items. A collection with items to be placed into the OrderedSet. T does not implement IComparable<TKey>. Creates a new OrderedSet. The passed delegate will be used to compare items in this set. The set is initialized with all the items in the given collection. A collection with items to be placed into the OrderedSet. A delegate to a method that will be used to compare items. Creates a new OrderedSet. The Compare method of the passed comparison object will be used to compare items in this set. The set is initialized with all the items in the given collection. The GetHashCode and Equals methods of the provided IComparer<T> will never be called, and need not be implemented. A collection with items to be placed into the OrderedSet. An instance of IComparer<T> that will be used to compare items. Creates a new OrderedSet given a comparer and a tree that contains the data. Used internally for Clone. Comparer for the set. Data for the set. Makes a shallow clone of this set; i.e., if items of the set are reference types, then they are not cloned. If T is a value type, then each element is copied as if by simple assignment. Cloning the set takes time O(N), where N is the number of items in the set. The cloned set. Makes a shallow clone of this set; i.e., if items of the set are reference types, then they are not cloned. If T is a value type, then each element is copied as if by simple assignment. Cloning the set takes time O(N), where N is the number of items in the set. The cloned set. Makes a deep clone of this set. A new set is created with a clone of each element of this set, by calling ICloneable.Clone on each element. If T is a value type, then each element is copied as if by simple assignment. If T is a reference type, it must implement ICloneable. Otherwise, an InvalidOperationException is thrown. Cloning the set takes time O(N log N), where N is the number of items in the set. The cloned set. T is a reference type that does not implement ICloneable. Returns the IComparer<T> used to compare items in this set. If the set was created using a comparer, that comparer is returned. If the set was created using a comparison delegate, then a comparer equivalent to that delegate is returned. Otherwise the default comparer for T (Comparer<T>.Default) is returned. Returns the number of items in the set. The size of the set is returned in constant time. The number of items in the set. Returns an enumerator that enumerates all the items in the set. The items are enumerated in sorted order.

Typically, this method is not called directly. Instead the "foreach" statement is used to enumerate the items, which uses this method implicitly.

If an item is added to or deleted from the set while it is being enumerated, then the enumeration will end with an InvalidOperationException.

Enumeration all the items in the set takes time O(N log N), where N is the number of items in the set.

An enumerator for enumerating all the items in the OrderedSet.
Determines if this set contains an item equal to . The set is not changed. Searching the set for an item takes time O(log N), where N is the number of items in the set. The item to search for. True if the set contains . False if the set does not contain . Determines if this set contains an item equal to , according to the comparison mechanism that was used when the set was created. The set is not changed. If the set does contain an item equal to , then the item from the set is returned. Searching the set for an item takes time O(log N), where N is the number of items in the set. In the following example, the set contains strings which are compared in a case-insensitive manner. OrderedSet<string> set = new OrderedSet<string>(StringComparer.CurrentCultureIgnoreCase); set.Add("HELLO"); string s; bool b = set.TryGetItem("Hello", out s); // b receives true, s receives "HELLO". The item to search for. Returns the item from the set that was equal to . True if the set contains . False if the set does not contain . Get the item by its index in the sorted order. The smallest item has index 0, the next smallest item has index 1, and the largest item has index Count-1. The indexer takes time O(log N), which N is the number of items in the set. The index to get the item by. The item at the given index. is less than zero or greater than or equal to Count. Get the index of the given item in the sorted order. The smallest item has index 0, the next smallest item has index 1, and the largest item has index Count-1. Finding the index takes time O(log N), which N is the number of items in the set. The item to get the index of. The index of the item in the sorted set, or -1 if the item is not present in the set. Adds a new item to the set. If the set already contains an item equal to , that item is replaced with . Equality between items is determined by the comparison instance or delegate used to create the set. Adding an item takes time O(log N), where N is the number of items in the set. The item to add to the set. True if the set already contained an item equal to (which was replaced), false otherwise. Adds a new item to the set. If the set already contains an item equal to , that item is replaces with . Equality between items is determined by the comparison instance or delegate used to create the set. Adding an item takes time O(log N), where N is the number of items in the set. The item to add to the set. Adds all the items in to the set. If the set already contains an item equal to one of the items in , that item will be replaced. Equality between items is determined by the comparison instance or delegate used to create the set. Adding the collection takes time O(M log N), where N is the number of items in the set, and M is the number of items in . A collection of items to add to the set. Searches the set for an item equal to , and if found, removes it from the set. If not found, the set is unchanged. Equality between items is determined by the comparison instance or delegate used to create the set. Removing an item from the set takes time O(log N), where N is the number of items in the set. The item to remove. True if was found and removed. False if was not in the set. Removes all the items in from the set. Items not present in the set are ignored. Equality between items is determined by the comparison instance or delegate used to create the set. Removing the collection takes time O(M log N), where N is the number of items in the set, and M is the number of items in . A collection of items to remove from the set. The number of items removed from the set. is null. Removes all items from the set. Clearing the sets takes a constant amount of time, regardless of the number of items in it. If the collection is empty, throw an invalid operation exception. The set is empty. Returns the first item in the set: the item that would appear first if the set was enumerated. This is also the smallest item in the set. GetFirst() takes time O(log N), where N is the number of items in the set. The first item in the set. The set is empty. Returns the lastl item in the set: the item that would appear last if the set was enumerated. This is also the largest item in the set. GetLast() takes time O(log N), where N is the number of items in the set. The lastl item in the set. The set is empty. Removes the first item in the set. This is also the smallest item in the set. RemoveFirst() takes time O(log N), where N is the number of items in the set. The item that was removed, which was the smallest item in the set. The set is empty. Removes the last item in the set. This is also the largest item in the set. RemoveLast() takes time O(log N), where N is the number of items in the set. The item that was removed, which was the largest item in the set. The set is empty. Check that this set and another set were created with the same comparison mechanism. Throws exception if not compatible. Other set to check comparision mechanism. If otherSet and this set don't use the same method for comparing items. Determines if this set is a superset of another set. Neither set is modified. This set is a superset of if every element in is also in this set. IsSupersetOf is computed in time O(M log N), where M is the size of the , and N is the size of the this set. OrderedSet to compare to. True if this is a superset of . This set and don't use the same method for comparing items. Determines if this set is a proper superset of another set. Neither set is modified. This set is a proper superset of if every element in is also in this set. Additionally, this set must have strictly more items than . IsProperSupersetOf is computed in time O(M log N), where M is the number of unique items in . OrderedSet to compare to. True if this is a proper superset of . This set and don't use the same method for comparing items. Determines if this set is a subset of another set. Neither set is modified. This set is a subset of if every element in this set is also in . IsSubsetOf is computed in time O(N log M), where M is the size of the , and N is the size of the this set. Set to compare to. True if this is a subset of . This set and don't use the same method for comparing items. Determines if this set is a proper subset of another set. Neither set is modified. This set is a subset of if every element in this set is also in . Additionally, this set must have strictly fewer items than . IsSubsetOf is computed in time O(N log M), where M is the size of the , and N is the size of the this set. Set to compare to. True if this is a proper subset of . This set and don't use the same method for comparing items. Determines if this set is equal to another set. This set is equal to if they contain the same items. IsEqualTo is computed in time O(N), where N is the number of items in this set. Set to compare to True if this set is equal to , false otherwise. This set and don't use the same method for comparing items. Computes the union of this set with another set. The union of two sets is all items that appear in either or both of the sets. This set receives the union of the two sets, the other set is unchanged. If equal items appear in both sets, the union will include an arbitrary choice of one of the two equal items. The union of two sets is computed in time O(M + N log M), where M is the size of the larger set, and N is the size of the smaller set. Set to union with. This set and don't use the same method for comparing items. Determines if this set is disjoint from another set. Two sets are disjoint if no item from one set is equal to any item in the other set. The answer is computed in time O(N log M), where M is the size of the larger set, and N is the size of the smaller set. Set to check disjointness with. True if the two sets are disjoint, false otherwise. This set and don't use the same method for comparing items. Computes the union of this set with another set. The union of two sets is all items that appear in either or both of the sets. A new set is created with the union of the sets and is returned. This set and the other set are unchanged. If equal items appear in both sets, the union will include an arbitrary choice of one of the two equal items. The union of two sets is computed in time O(M + N log M), where M is the size of the larger set, and N is the size of the smaller set. Set to union with. The union of the two sets. This set and don't use the same method for comparing items. Computes the intersection of this set with another set. The intersection of two sets is all items that appear in both of the sets. This set receives the intersection of the two sets, the other set is unchanged. When equal items appear in both sets, the intersection will include an arbitrary choice of one of the two equal items. The intersection of two sets is computed in time O(N log M), where M is the size of the larger set, and N is the size of the smaller set. Set to intersection with. This set and don't use the same method for comparing items. Computes the intersection of this set with another set. The intersection of two sets is all items that appear in both of the sets. A new set is created with the intersection of the sets and is returned. This set and the other set are unchanged. When equal items appear in both sets, the intersection will include an arbitrary choice of one of the two equal items. The intersection of two sets is computed in time O(N log M), where M is the size of the larger set, and N is the size of the smaller set. Set to intersection with. The intersection of the two sets. This set and don't use the same method for comparing items. Computes the difference of this set with another set. The difference of these two sets is all items that appear in this set, but not in . This set receives the difference of the two sets; the other set is unchanged. The difference of two sets is computed in time O(M + N log M), where M is the size of the larger set, and N is the size of the smaller set. Set to difference with. This set and don't use the same method for comparing items. Computes the difference of this set with another set. The difference of these two sets is all items that appear in this set, but not in . A new set is created with the difference of the sets and is returned. This set and the other set are unchanged. The difference of two sets is computed in time O(M + N log M), where M is the size of the larger set, and N is the size of the smaller set. Set to difference with. The difference of the two sets. This set and don't use the same method for comparing items. Computes the symmetric difference of this set with another set. The symmetric difference of two sets is all items that appear in either of the sets, but not both. This set receives the symmetric difference of the two sets; the other set is unchanged. The symmetric difference of two sets is computed in time O(M + N log M), where M is the size of the larger set, and N is the size of the smaller set. Set to symmetric difference with. This set and don't use the same method for comparing items. Computes the symmetric difference of this set with another set. The symmetric difference of two sets is all items that appear in either of the sets, but not both. A new set is created with the symmetric difference of the sets and is returned. This set and the other set are unchanged. The symmetric difference of two sets is computed in time O(M + N log M), where M is the size of the larger set, and N is the size of the smaller set. Set to symmetric difference with. The symmetric difference of the two sets. This set and don't use the same method for comparing items. Get a read-only list view of the items in this ordered set. The items in the list are in sorted order, with the smallest item at index 0. This view does not copy any data, and reflects any changes to the underlying OrderedSet. A read-only IList<T> view onto this OrderedSet. The nested class that provides a read-only list view of all or part of the collection. Create a new list view wrapped the given set. Range tester that defines the range being used. If true, then rangeTester defines the entire tree. Used to optimize some operations. Is the view enuemerated in reverse order? Returns a View collection that can be used for enumerating the items in the set in reversed order.

Typically, this method is used in conjunction with a foreach statement. For example: foreach(T item in set.Reversed()) { // process item }

If an item is added to or deleted from the set while the View is being enumerated, then the enumeration will end with an InvalidOperationException.

Calling Reverse does not copy the data in the tree, and the operation takes constant time.

An OrderedSet.View of items in reverse order.
Returns a View collection that can be used for enumerating a range of the items in the set.. Only items that are greater than and less than are included. The items are enumerated in sorted order. Items equal to the end points of the range can be included or excluded depending on the and parameters.

If is greater than , the returned collection is empty.

Typically, this method is used in conjunction with a foreach statement. For example: foreach(T item in set.Range(from, true, to, false)) { // process item }

If an item is added to or deleted from the set while the View is being enumerated, then the enumeration will end with an InvalidOperationException.

Calling Range does not copy the data in the tree, and the operation takes constant time.

The lower bound of the range. If true, the lower bound is inclusive--items equal to the lower bound will be included in the range. If false, the lower bound is exclusive--items equal to the lower bound will not be included in the range. The upper bound of the range. If true, the upper bound is inclusive--items equal to the upper bound will be included in the range. If false, the upper bound is exclusive--items equal to the upper bound will not be included in the range. An OrderedSet.View of items in the given range.
Returns a View collection that can be used for enumerating a range of the items in the set.. Only items that are greater than (and optionally, equal to) are included. The items are enumerated in sorted order. Items equal to can be included or excluded depending on the parameter.

Typically, this method is used in conjunction with a foreach statement. For example: foreach(T item in set.RangeFrom(from, true)) { // process item }

If an item is added to or deleted from the set while the View is being enumerated, then the enumeration will end with an InvalidOperationException.

Calling RangeFrom does not copy the data in the tree, and the operation takes constant time.

The lower bound of the range. If true, the lower bound is inclusive--items equal to the lower bound will be included in the range. If false, the lower bound is exclusive--items equal to the lower bound will not be included in the range. An OrderedSet.View of items in the given range.
Returns a View collection that can be used for enumerating a range of the items in the set.. Only items that are less than (and optionally, equal to) are included. The items are enumerated in sorted order. Items equal to can be included or excluded depending on the parameter.

Typically, this method is used in conjunction with a foreach statement. For example: foreach(T item in set.RangeTo(to, false)) { // process item }

If an item is added to or deleted from the set while the View is being enumerated, then the enumeration will end with an InvalidOperationException.

Calling RangeTo does not copy the data in the tree, and the operation takes constant time.

The upper bound of the range. If true, the upper bound is inclusive--items equal to the upper bound will be included in the range. If false, the upper bound is exclusive--items equal to the upper bound will not be included in the range. An OrderedSet.View of items in the given range.
The OrderedSet<T>.View class is used to look at a subset of the Items inside an ordered set. It is returned from the Range, RangeTo, RangeFrom, and Reversed methods.

Views are dynamic. If the underlying set changes, the view changes in sync. If a change is made to the view, the underlying set changes accordingly.

Typically, this class is used in conjunction with a foreach statement to enumerate the items in a subset of the OrderedSet. For example:

foreach(T item in set.Range(from, to)) { // process item }
Initialize the view. OrderedSet being viewed Range tester that defines the range being used. If true, then rangeTester defines the entire tree. Used to optimize some operations. Is the view enuemerated in reverse order? Determine if the given item lies within the bounds of this view. Item to test. True if the item is within the bounds of this view. Enumerate all the items in this view. An IEnumerator<T> with the items in this view. Number of items in this view. Number of items that lie within the bounds the view. Removes all the items within this view from the underlying set. The following removes all the items that start with "A" from an OrderedSet. set.Range("A", "B").Clear(); Adds a new item to the set underlying this View. If the set already contains an item equal to , that item is replaces with . If is outside the range of this view, an InvalidOperationException is thrown. Equality between items is determined by the comparison instance or delegate used to create the set. Adding an item takes time O(log N), where N is the number of items in the set. The item to add. True if the set already contained an item equal to (which was replaced), false otherwise. Adds a new item to the set underlying this View. If the set already contains an item equal to , that item is replaces with . If is outside the range of this view, an InvalidOperationException is thrown. Equality between items is determined by the comparison instance or delegate used to create the set. Adding an item takes time O(log N), where N is the number of items in the set. The item to add. Searches the underlying set for an item equal to , and if found, removes it from the set. If not found, the set is unchanged. If the item is outside the range of this view, the set is unchanged. Equality between items is determined by the comparison instance or delegate used to create the set. Removing an item from the set takes time O(log N), where N is the number of items in the set. The item to remove. True if was found and removed. False if was not in the set, or was outside the range of this view. Determines if this view of the set contains an item equal to . The set is not changed. If Searching the set for an item takes time O(log N), where N is the number of items in the set. The item to search for. True if the set contains , and is within the range of this view. False otherwise. Get the index of the given item in the view. The smallest item in the view has index 0, the next smallest item has index 1, and the largest item has index Count-1. Finding the index takes time O(log N), which N is the number of items in the set. The item to get the index of. The index of the item in the view, or -1 if the item is not present in the view. Get the item by its index in the sorted order. The smallest item in the view has index 0, the next smallest item has index 1, and the largest item has index Count-1. The indexer takes time O(log N), which N is the number of items in the set. The index to get the item by. The item at the given index. is less than zero or greater than or equal to Count. Get a read-only list view of the items in this view. The items in the list are in sorted order, with the smallest item at index 0. This view does not copy any data, and reflects any changes to the underlying OrderedSet. A read-only IList<T> view onto this view. Creates a new View that has the same items as this view, in the reversed order. A new View that has the reversed order of this view, with the same upper and lower bounds. Returns the first item in this view: the item that would appear first if the view was enumerated. GetFirst() takes time O(log N), where N is the number of items in the set. The first item in the view. The view has no items in it. Returns the last item in the view: the item that would appear last if the view was enumerated. GetLast() takes time O(log N), where N is the number of items in the set. The last item in the view. The view has no items in it. Stores a pair of objects within a single struct. This struct is useful to use as the T of a collection, or as the TKey or TValue of a dictionary. Comparers for the first and second type that are used to compare values. The first element of the pair. The second element of the pair. Creates a new pair with given first and second elements. The first element of the pair. The second element of the pair. Creates a new pair using elements from a KeyValuePair structure. The First element gets the Key, and the Second elements gets the Value. The KeyValuePair to initialize the Pair with . Determines if this pair is equal to another object. The pair is equal to another object if that object is a Pair, both element types are the same, and the first and second elements both compare equal using object.Equals. Object to compare for equality. True if the objects are equal. False if the objects are not equal. Determines if this pair is equal to another pair. The pair is equal if the first and second elements both compare equal using IComparable<T>.Equals or object.Equals. Pair to compare with for equality. True if the pairs are equal. False if the pairs are not equal. Returns a hash code for the pair, suitable for use in a hash-table or other hashed collection. Two pairs that compare equal (using Equals) will have the same hash code. The hash code for the pair is derived by combining the hash codes for each of the two elements of the pair. The hash code. Compares this pair to another pair of the some type. The pairs are compared by using the IComparable<T> or IComparable interface on TFirst and TSecond. The pairs are compared by their first elements first, if their first elements are equal, then they are compared by their second elements. If either TFirst or TSecond does not implement IComparable<T> or IComparable, then an NotSupportedException is thrown, because the pairs cannot be compared. The pair to compare to. An integer indicating how this pair compares to . Less than zero indicates this pair is less than . Zero indicate this pair is equals to . Greater than zero indicates this pair is greater than . Either FirstSecond or TSecond is not comparable via the IComparable<T> or IComparable interfaces. Compares this pair to another pair of the some type. The pairs are compared by using the IComparable<T> or IComparable interface on TFirst and TSecond. The pairs are compared by their first elements first, if their first elements are equal, then they are compared by their second elements. If either TFirst or TSecond does not implement IComparable<T> or IComparable, then an NotSupportedException is thrown, because the pairs cannot be compared. The pair to compare to. An integer indicating how this pair compares to . Less than zero indicates this pair is less than . Zero indicate this pair is equals to . Greater than zero indicates this pair is greater than . is not of the correct type. Either FirstSecond or TSecond is not comparable via the IComparable<T> or IComparable interfaces. Returns a string representation of the pair. The string representation of the pair is of the form: First: {0}, Second: {1} where {0} is the result of First.ToString(), and {1} is the result of Second.ToString() (or "null" if they are null.) The string representation of the pair. Determines if two pairs are equal. Two pairs are equal if the first and second elements both compare equal using IComparable<T>.Equals or object.Equals. First pair to compare. Second pair to compare. True if the pairs are equal. False if the pairs are not equal. Determines if two pairs are not equal. Two pairs are equal if the first and second elements both compare equal using IComparable<T>.Equals or object.Equals. First pair to compare. Second pair to compare. True if the pairs are not equal. False if the pairs are equal. Converts a Pair to a KeyValuePair. The Key part of the KeyValuePair gets the First element, and the Value part of the KeyValuePair gets the Second elements. Pair to convert. The KeyValuePair created from . Converts this Pair to a KeyValuePair. The Key part of the KeyValuePair gets the First element, and the Value part of the KeyValuePair gets the Second elements. The KeyValuePair created from this Pair. Converts a KeyValuePair structure into a Pair. The First element gets the Key, and the Second element gets the Value. The KeyValuePair to convert. The Pair created by converted the KeyValuePair into a Pair. ReadOnlyCollectionBase is a base class that can be used to more easily implement the generic ICollection<T> and non-generic ICollection interfaces for a read-only collection: a collection that does not allow adding or removing elements. To use ReadOnlyCollectionBase as a base class, the derived class must override the Count and GetEnumerator methods. ICollection<T>.Contains need not be implemented by the derived class, but it should be strongly considered, because the ReadOnlyCollectionBase implementation may not be very efficient. The item type of the collection. Creates a new ReadOnlyCollectionBase. Throws an NotSupportedException stating that this collection cannot be modified. Shows the string representation of the collection. The string representation contains a list of the items in the collection. The string representation of the collection. Determines if the collection contains any item that satisfies the condition defined by . A delegate that defines the condition to check for. True if the collection contains one or more items that satisfy the condition defined by . False if the collection does not contain an item that satisfies . Determines if all of the items in the collection satisfy the condition defined by . A delegate that defines the condition to check for. True if all of the items in the collection satisfy the condition defined by , or if the collection is empty. False if one or more items in the collection do not satisfy . Counts the number of items in the collection that satisfy the condition defined by . A delegate that defines the condition to check for. The number of items in the collection that satisfy . Enumerates the items in the collection that satisfy the condition defined by . A delegate that defines the condition to check for. An IEnumerable<T> that enumerates the items that satisfy the condition. Performs the specified action on each item in this collection. An Action delegate which is invoked for each item in this collection. Convert this collection of items by applying a delegate to each item in the collection. The resulting enumeration contains the result of applying to each item in this collection, in order. The type each item is being converted to. A delegate to the method to call, passing each item in this collection. An IEnumerable<TOutput^gt; that enumerates the resulting collection from applying to each item in this collection in order. is null. This method throws an NotSupportedException stating the collection is read-only. Item to be added to the collection. Always thrown. This method throws an NotSupportedException stating the collection is read-only. Always thrown. This method throws an NotSupportedException stating the collection is read-only. Item to be removed from the collection. Always thrown. Determines if the collection contains a particular item. This default implementation iterates all of the items in the collection via GetEnumerator, testing each item against using IComparable<T>.Equals or Object.Equals. You should strongly consider overriding this method to provide a more efficient implementation. The item to check for in the collection. True if the collection contains , false otherwise. 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. Array to copy to. Starting index in to copy to. Creates an array of the correct size, and copies all the items in the collection into the array, by calling CopyTo. An array containing all the elements in the collection, in order. Must be overridden to provide the number of items in the collection. The number of items in the collection. Indicates whether the collection is read-only. Returns the value of readOnly that was provided to the constructor. Always true. Must be overridden to enumerate all the members of the collection. A generic IEnumerator<T> that can be used to enumerate all the items in the collection. 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. Array to copy to. Starting index in to copy to. Indicates whether the collection is synchronized. Always returns false, indicating that the collection is not synchronized. Indicates the synchronization object for this collection. Always returns this. Provides an IEnumerator that can be used to iterate all the members of the collection. This implementation uses the IEnumerator<T> that was overridden by the derived classes to enumerate the members of the collection. An IEnumerator that can be used to iterate the collection. Display the contents of the collection in the debugger. This is intentionally private, it is called only from the debugger due to the presence of the DebuggerDisplay attribute. It is similar format to ToString(), but is limited to 250-300 characters or so, so as not to overload the debugger. The string representation of the items in the collection, similar in format to ToString(). ReadOnlyDictionaryBase is a base class that can be used to more easily implement the generic IDictionary<T> and non-generic IDictionary interfaces. To use ReadOnlyDictionaryBase as a base class, the derived class must override Count, TryGetValue, GetEnumerator. The key type of the dictionary. The value type of the dictionary. Creates a new DictionaryBase. This must be called from the constructor of the derived class to specify whether the dictionary is read-only and the name of the collection. Throws an NotSupportedException stating that this collection cannot be modified. Adds a new key-value pair to the dictionary. Always throws an exception indicating that this method is not supported in a read-only dictionary. Key to add. Value to associated with the key. Always thrown. Removes a key from the dictionary. Always throws an exception indicating that this method is not supported in a read-only dictionary. Key to remove from the dictionary. True if the key was found, false otherwise. Always thrown. Determines whether a given key is found in the dictionary. The default implementation simply calls TryGetValue and returns what it returns. Key to look for in the dictionary. True if the key is present in the dictionary. Determines if this dictionary contains a key equal to . If so, the value associated with that key is returned through the value parameter. This method must be overridden in the derived class. The key to search for. Returns the value associated with key, if true was returned. True if the dictionary contains key. False if the dictionary does not contain key. The indexer of the dictionary. The set accessor throws an NotSupportedException stating the dictionary is read-only. The get accessor is implemented by calling TryGetValue. Key to find in the dictionary. The value associated with the key. Always thrown from the set accessor, indicating that the dictionary is read only. Thrown from the get accessor if the key was not found. Shows the string representation of the dictionary. The string representation contains a list of the mappings in the dictionary. The string representation of the dictionary. Returns a collection of the keys in this dictionary. A read-only collection of the keys in this dictionary. 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. 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. A KeyValuePair containing the Key and Value to check for. Adds a key-value pair to the collection. Always throws an exception indicating that this method is not supported in a read-only dictionary. Key to add to the dictionary. Value to add to the dictionary. Always thrown. Clears this dictionary. Always throws an exception indicating that this method is not supported in a read-only dictionary. Always thrown. Determines if this dictionary contains a key equal to . The dictionary is not changed. Calls the (overridden) ContainsKey method. If key is not of the correct TKey for the dictionary, false is returned. The key to search for. True if the dictionary contains key. False if the dictionary does not contain key. Removes the key (and associated value) from the collection that is equal to the passed in key. Always throws an exception indicating that this method is not supported in a read-only dictionary. The key to remove. Always thrown. Returns an enumerator that enumerates all the entries in the dictionary. Each entry is returned as a DictionaryEntry. The entries are enumerated in the same orders as the (overridden) GetEnumerator method. An enumerator for enumerating all the elements in the OrderedDictionary. Returns an enumerator that enumerates all the entries in the dictionary. Each entry is returned as a DictionaryEntry. The entries are enumerated in the same orders as the (overridden) GetEnumerator method. An enumerator for enumerating all the elements in the OrderedDictionary. Returns whether this dictionary is fixed size. Always returns true. Returns if this dictionary is read-only. Always returns true. Returns a collection of all the keys in the dictionary. The values in this collection will be enumerated in the same order as the (overridden) GetEnumerator method. The collection of keys. Returns a collection of all the values in the dictionary. The values in this collection will be enumerated in the same order as the (overridden) GetEnumerator method. The collection of values. Gets the value associated with a given key. When getting a value, if this key is not found in the collection, then null is returned. If the key is not of the correct type for this dictionary, null is returned. The value associated with the key, or null if the key was not present. Always thrown from the set accessor, indicating that the dictionary is read only. Display the contents of the dictionary in the debugger. This is intentionally private, it is called only from the debugger due to the presence of the DebuggerDisplay attribute. It is similar format to ToString(), but is limited to 250-300 characters or so, so as not to overload the debugger. The string representation of the items in the collection, similar in format to ToString(). A private class that implements ICollection<TKey> and ICollection for the Keys collection. The collection is read-only. Constructor. The dictionary this is associated with. A private class that implements ICollection<TKey> and ICollection for the Values collection. The collection is read-only. A class that wraps a IDictionaryEnumerator around an IEnumerator that enumerates KeyValuePairs. This is useful in implementing IDictionary, because IEnumerator can be implemented with an iterator, but IDictionaryEnumerator cannot. Constructor. The enumerator of KeyValuePairs that is being wrapped. ReadOnlyListBase is an abstract class that can be used as a base class for a read-only collection that needs to implement the generic IList<T> and non-generic IList collections. The derived class needs to override the Count property and the get part of the indexer. The implementation of all the other methods in IList<T> and IList are handled by ListBase. Creates a new ReadOnlyListBase. Throws an NotSupportedException stating that this collection cannot be modified. The property must be overridden by the derived class to return the number of items in the list. The number of items in the list. The get part of the indexer must be overridden by the derived class to get values of the list at a particular index. The index in the list to get or set an item at. The first item in the list has index 0, and the last has index Count-1. The item at the given index. is less than zero or greater than or equal to Count. Enumerates all of the items in the list, in order. The item at index 0 is enumerated first, then the item at index 1, and so on. An IEnumerator<T> that enumerates all the items in the list. Determines if the list contains any item that compares equal to . The implementation simply checks whether IndexOf(item) returns a non-negative value. Equality in the list is determined by the default sense of equality for T. If T implements IComparable<T>, the Equals method of that interface is used to determine equality. Otherwise, Object.Equals is used to determine equality. The item to search for. True if the list contains an item that compares equal to . Copies all the items in the list, in order, to , starting at index 0. The array to copy to. This array must have a size that is greater than or equal to Count. Copies all the items in the list, in order, to , starting at . The array to copy to. This array must have a size that is greater than or equal to Count + arrayIndex. The starting index in to copy to. Copies a range of elements from the list to , starting at . The starting index in the source list of the range to copy. The array to copy to. This array must have a size that is greater than or equal to Count + arrayIndex. The starting index in to copy to. The number of items to copy. Finds the first item in the list that satisfies the condition defined by . If no item matches the condition, than the default value for T (null or all-zero) is returned. If the default value for T (null or all-zero) matches the condition defined by , and the list might contain the default value, then it is impossible to distinguish the different between finding the default value and not finding any item. To distinguish these cases, use . A delegate that defined the condition to check for. The first item that satisfies the condition . If no item satisfies that condition, the default value for T is returned. Finds the first item in the list that satisfies the condition defined by . A delegate that defines the condition to check for. If true is returned, this parameter receives the first item in the list that satifies the condition defined by . True if an item that satisfies the condition was found. False if no item in the list satisfies that condition. Finds the last item in the list that satisfies the condition defined by . If no item matches the condition, than the default value for T (null or all-zero) is returned. If the default value for T (null or all-zero) matches the condition defined by , and the list might contain the default value, then it is impossible to distinguish the different between finding the default value and not finding any item. To distinguish these cases, use . A delegate that defined the condition to check for. The last item that satisfies the condition . If no item satisfies that condition, the default value for T is returned. Finds the last item in the list that satisfies the condition defined by . A delegate that defines the condition to check for. If true is returned, this parameter receives the last item in the list that satifies the condition defined by . True if an item that satisfies the condition was found. False if no item in the list satisfies that condition. Finds the index of the first item in the list that satisfies the condition defined by . If no item matches the condition, -1 is returned. A delegate that defined the condition to check for. The index of the first item that satisfies the condition . If no item satisfies that condition, -1 is returned. Finds the index of the first item, in the range of items extending from to the end, that satisfies the condition defined by . If no item matches the condition, -1 is returned. A delegate that defined the condition to check for. The starting index of the range to check. The index of the first item in the given range that satisfies the condition . If no item satisfies that condition, -1 is returned. Finds the index of the first item, in the range of items starting from , that satisfies the condition defined by . If no item matches the condition, -1 is returned. A delegate that defined the condition to check for. The starting index of the range to check. The number of items in range to check. The index of the first item in the given range that satisfies the condition . If no item satisfies that condition, -1 is returned. Finds the index of the last item in the list that satisfies the condition defined by . If no item matches the condition, -1 is returned. A delegate that defined the condition to check for. The index of the last item that satisfies the condition . If no item satisfies that condition, -1 is returned. Finds the index of the last item, in the range of items extending from the beginning of the list to , that satisfies the condition defined by . If no item matches the condition, -1 is returned. A delegate that defined the condition to check for. The ending index of the range to check. The index of the last item in the given range that satisfies the condition . If no item satisfies that condition, -1 is returned. Finds the index of the last item, in the range of items ending at , that satisfies the condition defined by . If no item matches the condition, -1 is returned. A delegate that defined the condition to check for. The ending index of the range to check. The number of items in range to check. The index of the last item in the given range that satisfies the condition . If no item satisfies that condition, -1 is returned. Finds the index of the first item in the list that is equal to . The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals. The item to search fror. The index of the first item in the list that that is equal to . If no item is equal to , -1 is returned. Finds the index of the first item, in the range of items extending from to the end, that is equal to . The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals. The item to search fror. The starting index of the range to check. The index of the first item in the given range that that is equal to . If no item is equal to , -1 is returned. Finds the index of the first item, in the range of items starting from , that is equal to . The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals. The item to search fror. The starting index of the range to check. The number of items in range to check. The index of the first item in the given range that that is equal to . If no item is equal to , -1 is returned. Finds the index of the last item in the list that is equal to . The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals. The item to search fror. The index of the last item in the list that that is equal to . If no item is equal to , -1 is returned. Finds the index of the last item, in the range of items extending from the beginning of the list to , that is equal to . The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals. The item to search fror. The ending index of the range to check. The index of the last item in the given range that that is equal to . If no item is equal to , -1 is returned. Finds the index of the last item, in the range of items ending at , that is equal to . The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals. The item to search for. The ending index of the range to check. The number of items in range to check. The index of the last item in the given range that that is equal to . If no item is equal to , -1 is returned. Returns a view onto a sub-range of this list. Items are not copied; the returned IList<T> is simply a different view onto the same underlying items. This method can be used to apply an algorithm to a portion of a list. For example: Algorithms.Reverse(deque.Range(3, 6)) will return the reverse opf the 6 items beginning at index 3. The starting index of the view. The number of items in the view. A list that is a view onto the given sub-part of this list. or is negative. + is greater than the size of the list. Inserts a new item at the given index. This implementation throws a NotSupportedException indicating that the list is read-only. The index in the list to insert the item at. After the insertion, the inserted item is located at this index. The first item in the list has index 0. The item to insert at the given index. Always thrown. Removes the item at the given index. This implementation throws a NotSupportedException indicating that the list is read-only. The index in the list to remove the item at. The first item in the list has index 0. Always thrown. Adds an item to the end of the list. This implementation throws a NotSupportedException indicating that the list is read-only. The item to add to the list. Always thrown. Removes all the items from the list, resulting in an empty list. This implementation throws a NotSupportedException indicating that the list is read-only. Always thrown. Determines if the list contains any item that compares equal to . Equality in the list is determined by the default sense of equality for T. If T implements IComparable<T>, the Equals method of that interface is used to determine equality. Otherwise, Object.Equals is used to determine equality. The item to search for. Find the first occurrence of an item equal to in the list, and returns the index of that item. Equality in the list is determined by the default sense of equality for T. If T implements IComparable<T>, the Equals method of that interface is used to determine equality. Otherwise, Object.Equals is used to determine equality. The item to search for. The index of , or -1 if no item in the list compares equal to . Insert a new item at the given index. This implementation throws a NotSupportedException indicating that the list is read-only. The index in the list to insert the item at. After the insertion, the inserted item is located at this index. The first item in the list has index 0. The item to insert at the given index. Always thrown. Returns whether the list is a fixed size. This implementation always returns true. Alway true, indicating that the list is fixed size. Returns whether the list is read only. This implementation always returns true. Alway true, indicating that the list is read-only. Searches the list for the first item that compares equal to . If one is found, it is removed. Otherwise, the list is unchanged. This implementation throws a NotSupportedException indicating that the list is read-only. Equality in the list is determined by the default sense of equality for T. If T implements IComparable<T>, the Equals method of that interface is used to determine equality. Otherwise, Object.Equals is used to determine equality. The item to remove from the list. Always thrown. Removes the item at the given index. This implementation throws a NotSupportedException indicating that the list is read-only. The index in the list to remove the item at. The first item in the list has index 0. Always thrown. Gets or sets the value at a particular index in the list. The index in the list to get or set an item at. The first item in the list has index 0, and the last has index Count-1. The item at the given index. is less than zero or greater than or equal to Count. cannot be converted to T. Always thrown from the setter, indicating that the list is read-only. BigList<T> provides a list of items, in order, with indices of the items ranging from 0 to one less than the count of items in the collection. BigList<T> is optimized for efficient operations on large (>100 items) lists, especially for insertions, deletions, copies, and concatinations. BigList<T> class is similar in functionality to the standard List<T> class. Both classes provide a collection that stores an set of items in order, with indices of the items ranging from 0 to one less than the count of items in the collection. Both classes provide the ability to add and remove items from any index, and the get or set the item at any index. BigList<T> differs significantly from List<T> in the performance of various operations, especially when the lists become large (several hundred items or more). With List<T>, inserting or removing elements from anywhere in a large list except the end is very inefficient -- every item after the point of inserting or deletion has to be moved in the list. The BigList<T> class, however, allows for fast insertions and deletions anywhere in the list. Furthermore, BigList<T> allows copies of a list, sub-parts of a list, and concatinations of two lists to be very fast. When a copy is made of part or all of a BigList, two lists shared storage for the parts of the lists that are the same. Only when one of the lists is changed is additional memory allocated to store the distinct parts of the lists. Of course, there is a small price to pay for this extra flexibility. Although still quite efficient, using an index to get or change one element of a BigList, while still reasonably efficient, is significantly slower than using a plain List. Because of this, if you want to process every element of a BigList, using a foreach loop is a lot more efficient than using a for loop and indexing the list. In general, use a List when the only operations you are using are Add (to the end), foreach, or indexing, or you are very sure the list will always remain small (less than 100 items). For large (>100 items) lists that do insertions, removals, copies, concatinations, or sub-ranges, BigList will be more efficient than List. In almost all cases, BigList is more efficient and easier to use than LinkedList. The type of items to store in the BigList. Must be called whenever there is a structural change in the tree. Causes changeStamp to be changed, which causes any in-progress enumerations to throw exceptions. Checks the given stamp against the current change stamp. If different, the collection has changed during enumeration and an InvalidOperationException must be thrown changeStamp at the start of the enumeration. Creates a new BigList. The BigList is initially empty. Creating a empty BigList takes constant time and consumes a very small amount of memory. Creates a new BigList initialized with the items from , in order. Initializing the tree list with the elements of collection takes time O(N), where N is the number of items in . The collection used to initialize the BigList. is null. Creates a new BigList initialized with a given number of copies of the items from , in order. Initializing the tree list with the elements of collection takes time O(N + log K), where N is the number of items in , and K is the number of copies. Number of copies of the collection to use. The collection used to initialize the BigList. is negative. is null. Creates a new BigList that is a copy of . Copying a BigList takes constant time, and little additional memory, since the storage for the items of the two lists is shared. However, changing either list will take additional time and memory. Portions of the list are copied when they are changed. The BigList to copy. is null. Creates a new BigList that is several copies of . Creating K copies of a BigList takes time O(log K), and O(log K) additional memory, since the storage for the items of the two lists is shared. However, changing either list will take additional time and memory. Portions of the list are copied when they are changed. Number of copies of the collection to use. The BigList to copy. is null. Creates a new BigList from the indicated Node. Node that becomes the new root. If null, the new BigList is empty. Gets the number of items stored in the BigList. The indices of the items range from 0 to Count-1. Getting the number of items in the BigList takes constant time. The number of items in the BigList. Gets or sets an item in the list, by index. Gettingor setting an item takes time O(log N), where N is the number of items in the list. To process each of the items in the list, using GetEnumerator() or a foreach loop is more efficient that accessing each of the elements by index. The index of the item to get or set. The first item in the list has index 0, the last item has index Count-1. The value of the item at the given index. is less than zero or greater than or equal to Count. Removes all of the items from the BigList. Clearing a BigList takes constant time. Inserts a new item at the given index in the BigList. All items at indexes equal to or greater than move up one index. The amount of time to insert an item is O(log N), no matter where in the list the insertion occurs. Inserting an item at the beginning or end of the list is O(N). The index to insert the item at. After the insertion, the inserted item is located at this index. The first item has index 0. The item to insert at the given index. is less than zero or greater than Count. Inserts a collection of items at the given index in the BigList. All items at indexes equal to or greater than increase their indices by the number of items inserted. The amount of time to insert an arbitrary collection in the BigList is O(M + log N), where M is the number of items inserted, and N is the number of items in the list. The index to insert the collection at. After the insertion, the first item of the inserted collection is located at this index. The first item has index 0. The collection of items to insert at the given index. is less than zero or greater than Count. is null. Inserts a BigList of items at the given index in the BigList. All items at indexes equal to or greater than increase their indices by the number of items inserted. The amount of time to insert another BigList is O(log N), where N is the number of items in the list, regardless of the number of items in the inserted list. Storage is shared between the two lists until one of them is changed. The index to insert the collection at. After the insertion, the first item of the inserted collection is located at this index. The first item has index 0. The BigList of items to insert at the given index. is less than zero or greater than Count. is null. Removes the item at the given index in the BigList. All items at indexes greater than move down one index. The amount of time to delete an item in the BigList is O(log N), where N is the number of items in the list. The index in the list to remove the item at. The first item in the list has index 0. is less than zero or greater than or equal to Count. Removes a range of items at the given index in the Deque. All items at indexes greater than move down indices in the Deque. The amount of time to delete items in the Deque is proportional to the distance of index from the closest end of the Deque, plus : O(count + Min(, Count - 1 - )). The index in the list to remove the range at. The first item in the list has index 0. The number of items to remove. is less than zero or greater than or equal to Count, or is less than zero or too large. Adds an item to the end of the BigList. The indices of all existing items in the Deque are unchanged. Adding an item takes, on average, constant time. The item to add. Adds an item to the beginning of the BigList. The indices of all existing items in the Deque are increased by one, and the new item has index zero. Adding an item takes, on average, constant time. The item to add. Adds a collection of items to the end of BigList. The indices of all existing items are unchanged. The last item in the added collection becomes the last item in the BigList. This method takes time O(M + log N), where M is the number of items in the , and N is the size of the BigList. The collection of items to add. is null. Adds a collection of items to the front of BigList. The indices of all existing items in the are increased by the number of items in . The first item in the added collection becomes the first item in the BigList. This method takes time O(M + log N), where M is the number of items in the , and N is the size of the BigList. The collection of items to add. is null. Creates a new BigList that is a copy of this list. Copying a BigList takes constant time, and little additional memory, since the storage for the items of the two lists is shared. However, changing either list will take additional time and memory. Portions of the list are copied when they are changed. A copy of the current list Creates a new BigList that is a copy of this list. Copying a BigList takes constant time, and little additional memory, since the storage for the items of the two lists is shared. However, changing either list will take additional time and memory. Portions of the list are copied when they are changed. A copy of the current list Makes a deep clone of this BigList. A new BigList is created with a clone of each element of this set, by calling ICloneable.Clone on each element. If T is a value type, then this method is the same as Clone. If T is a reference type, it must implement ICloneable. Otherwise, an InvalidOperationException is thrown. If T is a reference type, cloning the list takes time approximate O(N), where N is the number of items in the list. The cloned set. T is a reference type that does not implement ICloneable. Adds a BigList of items to the end of BigList. The indices of all existing items are unchanged. The last item in becomes the last item in this list. The added list is unchanged. This method takes, on average, constant time, regardless of the size of either list. Although conceptually all of the items in are copied, storage is shared between the two lists until changes are made to the shared sections. The list of items to add. is null. Adds a BigList of items to the front of BigList. The indices of all existing items are increased by the number of items in . The first item in becomes the first item in this list. The added list is unchanged. This method takes, on average, constant time, regardless of the size of either list. Although conceptually all of the items in are copied, storage is shared between the two lists until changes are made to the shared sections. The list of items to add. is null. Concatenates two lists together to create a new list. Both lists being concatenated are unchanged. The resulting list contains all the items in , followed by all the items in . This method takes, on average, constant time, regardless of the size of either list. Although conceptually all of the items in both lists are copied, storage is shared until changes are made to the shared sections. The first list to concatenate. The second list to concatenate. or is null. Creates a new list that contains a subrange of elements from this list. The current list is unchanged. This method takes take O(log N), where N is the size of the current list. Although the sub-range is conceptually copied, storage is shared between the two lists until a change is made to the shared items. If a view of a sub-range is desired, instead of a copy, use the more efficient method, which provides a view onto a sub-range of items. The starting index of the sub-range. The number of items in the sub-range. If this is zero, the returned list is empty. A new list with the items that start at . Returns a view onto a sub-range of this list. Items are not copied; the returned IList<T> is simply a different view onto the same underlying items. Changes to this list are reflected in the view, and vice versa. Insertions and deletions in the view change the size of the view, but insertions and deletions in the underlying list do not. If a copy of the sub-range is desired, use the method instead. This method can be used to apply an algorithm to a portion of a list. For example: Algorithms.ReverseInPlace(list.Range(3, 6)) will reverse the 6 items beginning at index 3. The starting index of the view. The number of items in the view. A list that is a view onto the given sub-list. or is negative. + is greater than the size of this list. Enumerates a range of the items in the list, in order. The item at is enumerated first, then the next item at index 1, and so on. At most items are enumerated. Enumerating all of the items in the list take time O(N), where N is the number of items being enumerated. Using GetEnumerator() or foreach is much more efficient than accessing all items by index. Index to start enumerating at. Max number of items to enumerate. An IEnumerator<T> that enumerates all the items in the given range. Enumerates all of the items in the list, in order. The item at index 0 is enumerated first, then the item at index 1, and so on. Usually, the foreach statement is used to call this method implicitly. Enumerating all of the items in the list take time O(N), where N is the number of items in the list. Using GetEnumerator() or foreach is much more efficient than accessing all items by index. An IEnumerator<T> that enumerates all the items in the list. Given an IEnumerable<T>, create a new Node with all of the items in the enumerable. Returns null if the enumerable has no items. The collection to copy. Returns a Node, not shared or with any shared children, with the items from the collection. If the collection was empty, null is returned. Consumes up to MAXLEAF items from an Enumerator and places them in a leaf node. If the enumerator is at the end, null is returned. The enumerator to take items from. A LeafNode with items taken from the enumerator. Create a node that has N copies of the given node. Number of copies. Must be non-negative. Node to make copies of. null if node is null or copies is 0. Otherwise, a node consisting of copies of node. copies is negative. Check the balance of the current tree and rebalance it if it is more than BALANCEFACTOR levels away from fully balanced. Note that rebalancing a tree may leave it two levels away from fully balanced. Rebalance the current tree. Once rebalanced, the depth of the current tree is no more than two levels from fully balanced, where fully balanced is defined as having Fibonacci(N+2) or more items in a tree of depth N. The rebalancing algorithm is from "Ropes: an Alternative to Strings", by Boehm, Atkinson, and Plass, in SOFTWARE--PRACTICE AND EXPERIENCE, VOL. 25(12), 1315–1330 (DECEMBER 1995). Part of the rebalancing algorithm. Adds a node to the rebalance array. If it is already balanced, add it directly, otherwise add its children. Rebalance array to insert into. Node to add. If true, mark the node as shared before adding, because one of its parents was shared. Part of the rebalancing algorithm. Adds a balanced node to the rebalance array. Rebalance array to insert into. Node to add. Convert the list to a new list by applying a delegate to each item in the collection. The resulting list contains the result of applying to each item in the list, in order. The current list is unchanged. The type each item is being converted to. A delegate to the method to call, passing each item in . The resulting BigList from applying to each item in this list. is null. Reverses the current list in place. Reverses the items in the range of items starting from , in place. The starting index of the range to reverse. The number of items in range to reverse. Sorts the list in place. The Quicksort algorithm is used to sort the items. In virtually all cases, this takes time O(N log N), where N is the number of items in the list. Values are compared by using the IComparable or IComparable<T> interface implementation on the type T. The type T does not implement either the IComparable or IComparable<T> interfaces. Sorts the list in place. A supplied IComparer<T> is used to compare the items in the list. The Quicksort algorithms is used to sort the items. In virtually all cases, this takes time O(N log N), where N is the number of items in the list. The comparer instance used to compare items in the collection. Only the Compare method is used. Sorts the list in place. A supplied Comparison<T> delegate is used to compare the items in the list. The Quicksort algorithms is used to sort the items. In virtually all cases, this takes time O(N log N), where N is the number of items in the list. The comparison delegate used to compare items in the collection. Searches a sorted list for an item via binary search. The list must be sorted in the order defined by the default ordering of the item type; otherwise, incorrect results will be returned. The item to search for. Returns the index of the first occurence of in the list. If the item does not occur in the list, the bitwise complement of the first item larger than in the list is returned. If no item is larger than , the bitwise complement of Count is returned. The type T does not implement either the IComparable or IComparable<T> interfaces. Searches a sorted list for an item via binary search. The list must be sorted by the ordering defined by the passed IComparer<T> interface; otherwise, incorrect results will be returned. The item to search for. The IComparer<T> interface used to sort the list. Returns the index of the first occurence of in the list. If the item does not occur in the list, the bitwise complement of the first item larger than in the list is returned. If no item is larger than , the bitwise complement of Count is returned. Searches a sorted list for an item via binary search. The list must be sorted by the ordering defined by the passed Comparison<T> delegate; otherwise, incorrect results will be returned. The item to search for. The comparison delegate used to sort the list. Returns the index of the first occurence of in the list. If the item does not occur in the list, the bitwise complement of the first item larger than in the list is returned. If no item is larger than , the bitwise complement of Count is returned. The base class for the two kinds of nodes in the tree: Concat nodes and Leaf nodes. The number of items stored in the node (or below it). The number of items in the node or below. Is this node shared by more that one list (or within a single) lists. If true, indicates that this node, and any nodes below it, may never be modified. Never becomes false after being set to true. Marks this node as shared by setting the shared variable. Gets the depth of this node. A leaf node has depth 0, a concat node with two leaf children has depth 1, etc. The depth of this node. Returns the items at the given index in this node. 0-based index, relative to this node. Item at that index. Returns a node that has a sub-range of items from this node. The sub-range may not be empty, but may extend outside the node. In other words, first might be less than zero or last might be greater than count. But, last can't be less than zero and first can't be greater than count. Also, last must be greater than or equal to last. Inclusive first element, relative to this node. Inclusize last element, relative to this node. Node with the given sub-range. Changes the item at the given index. Never changes this node, but always returns a new node with the given item changed. Index, relative to this node, to change. New item to place at the given index. A new node with the given item changed. Changes the item at the given index. May change this node, or return a new node with the given item changed. Index, relative to this node, to change. New item to place at the given index. A node with the give item changed. If it can be done in place then "this" is returned. Append a node after this node. Never changes this node, but returns a new node with the given appending done. Node to append. If true, the given node is not used in any current list, so it may be change, overwritten, or destroyed if convenient. If false, the given node is in use. It should be marked as shared if is is used within the return value. A new node with the give node appended to this node. Append a node after this node. May change this node, or return a new node. Node to append. If true, the given node is not used in any current list, so it may be change, overwritten, or destroyed if convenient. If false, the given node is in use. It should be marked as shared if is is used within the return value. A node with the give node appended to this node. May be a new node or the current node. Append a item after this node. May change this node, or return a new node. Equivalent to AppendInPlace(new LeafNode(item), true), but may be more efficient because a new LeafNode might not be allocated. Item to append. A node with the given item appended to this node. May be a new node or the current node. Remove a range of items from this node. Never changes this node, but returns a new node with the removing done. The sub-range may not be empty, but may extend outside the node. In other words, first might be less than zero or last might be greater than count. But, last can't be less than zero and first can't be greater than count. Also, last must be greater than or equal to last. Inclusive index of first item in sub-range, relative to this node. Inclusize index of last item in sub-range, relative to this node. A new node with the sub-range removed. Remove a range of items from this node. May change this node, or returns a new node with the given appending done. The sub-range may not be empty, but may extend outside the node. In other words, first might be less than zero or last might be greater than count. But, last can't be less than zero and first can't be greater than count. Also, last must be greater than or equal to last. Inclusive index of first item in sub-range, relative to this node. Inclusize index of last item in sub-range, relative to this node. A node with the sub-range removed. If done in-place, returns "this". Inserts a node inside this node. Never changes this node, but returns a new node with the given appending done. Index, relative to this node, to insert at. Must be in bounds. Node to insert. If true, the given node is not used in any current list, so it may be change, overwritten, or destroyed if convenient. If false, the given node is in use. It should be marked as shared if is is used within the return value. A new node with the give node inserted. Inserts an item inside this node. May change this node, or return a new node with the given appending done. Equivalent to InsertInPlace(new LeafNode(item), true), but may be more efficient. Index, relative to this node, to insert at. Must be in bounds. Item to insert. A node with the give item inserted. If done in-place, returns "this". Inserts a node inside this node. May change this node, or return a new node with the given appending done. Index, relative to this node, to insert at. Must be in bounds. Node to insert. If true, the given node is not used in any current list, so it may be change, overwritten, or destroyed if convenient. If false, the given node is in use. It should be marked as shared if is is used within the return value. A node with the given item inserted. If done in-place, returns "this". Prefpend a node before this node. Never changes this node, but returns a new node with the given prepending done. Node to prepend. If true, the given node is not used in any current list, so it may be change, overwritten, or destroyed if convenient. If false, the given node is in use. It should be marked as shared if is is used within the return value. A new node with the give node prepended to this node. Prepend a node before this node. May change this node, or return a new node. Node to prepend. If true, the given node is not used in any current list, so it may be change, overwritten, or destroyed if convenient. If false, the given node is in use. It should be marked as shared if is is used within the return value. A node with the give node prepended to this node. May be a new node or the current node. Prepend a item before this node. May change this node, or return a new node. Equivalent to PrependInPlace(new LeafNode(item), true), but may be more efficient because a new LeafNode might not be allocated. Item to prepend. A node with the given item prepended to this node. May be a new node or the current node. Determine if this node is balanced. A node is balanced if the number of items is greater than Fibonacci(Depth+2). Balanced nodes are never rebalanced unless they go out of balance again. True if the node is balanced by this definition. Determine if this node is almost balanced. A node is almost balanced if t its depth is at most one greater than a fully balanced node with the same count. True if the node is almost balanced by this definition. The LeafNode class is the type of node that lives at the leaf of a tree and holds the actual items stored in the list. Each leaf holds at least 1, and at most MAXLEAF items in the items array. The number of items stored is found in "count", which may be less than "items.Length". Array that stores the items in the nodes. Always has a least "count" elements, but may have more as padding. Creates a LeafNode that holds a single item. Item to place into the leaf node. Creates a new leaf node with the indicates count of item and the Number of items. Can't be zero. The array of items. The LeafNode takes possession of this array. Returns the items at the given index in this node. 0-based index, relative to this node. Item at that index. Changes the item at the given index. May change this node, or return a new node with the given item changed. Index, relative to this node, to change. New item to place at the given index. A node with the give item changed. If it can be done in place then "this" is returned. Changes the item at the given index. Never changes this node, but always returns a new node with the given item changed. Index, relative to this node, to change. New item to place at the given index. A new node with the given item changed. If other is a leaf node, and the resulting size would be less than MAXLEAF, merge the other leaf node into this one (after this one) and return true. Other node to possible merge. If could be merged into this node, returns true. Otherwise returns false and the current node is unchanged. If other is a leaf node, and the resulting size would be less than MAXLEAF, merge the other leaf node with this one (after this one) and return a new node with the merged items. Does not modify this. If no merging, return null. Other node to possible merge. If the nodes could be merged, returns the new node. Otherwise returns null. Prepend a item before this node. May change this node, or return a new node. Equivalent to PrependInPlace(new LeafNode(item), true), but may be more efficient because a new LeafNode might not be allocated. Item to prepend. A node with the given item prepended to this node. May be a new node or the current node. Append a item after this node. May change this node, or return a new node. Equivalent to AppendInPlace(new LeafNode(item), true), but may be more efficient because a new LeafNode might not be allocated. Item to append. A node with the given item appended to this node. May be a new node or the current node. Append a node after this node. May change this node, or return a new node. Node to append. If true, the given node is not used in any current list, so it may be change, overwritten, or destroyed if convenient. If false, the given node is in use. It should be marked as shared if is is used within the return value. A node with the give node appended to this node. May be a new node or the current node. Inserts an item inside this node. May change this node, or return a new node with the given appending done. Equivalent to InsertInPlace(new LeafNode(item), true), but may be more efficient. Index, relative to this node, to insert at. Must be in bounds. Item to insert. A node with the give item inserted. If done in-place, returns "this". Inserts a node inside this node. May change this node, or return a new node with the given appending done. Index, relative to this node, to insert at. Must be in bounds. Node to insert. If true, the given node is not used in any current list, so it may be change, overwritten, or destroyed if convenient. If false, the given node is in use. It should be marked as shared if is is used within the return value. A node with the given item inserted. If done in-place, returns "this". Inserts a node inside this node. Never changes this node, but returns a new node with the given appending done. Index, relative to this node, to insert at. Must be in bounds. Node to insert. If true, the given node is not used in any current list, so it may be change, overwritten, or destroyed if convenient. If false, the given node is in use. It should be marked as shared if is is used within the return value. A new node with the give node inserted. Remove a range of items from this node. May change this node, or returns a new node with the given appending done. The sub-range may not be empty, but may extend outside the node. In other words, first might be less than zero or last might be greater than count. But, last can't be less than zero and first can't be greater than count. Also, last must be greater than or equal to last. Inclusive index of first item in sub-range, relative to this node. Inclusize index of last item in sub-range, relative to this node. A node with the sub-range removed. If done in-place, returns "this". Remove a range of items from this node. Never changes this node, but returns a new node with the removing done. The sub-range may not be empty, but may extend outside the node. In other words, first might be less than zero or last might be greater than count. But, last can't be less than zero and first can't be greater than count. Also, last must be greater than or equal to last. Inclusive index of first item in sub-range, relative to this node. Inclusize index of last item in sub-range, relative to this node. A new node with the sub-range removed. Returns a node that has a sub-range of items from this node. The sub-range may not be empty, but may extend outside the node. In other words, first might be less than zero or last might be greater than count. But, last can't be less than zero and first can't be greater than count. Also, last must be greater than or equal to last. Inclusive first element, relative to this node. Inclusize last element, relative to this node. Node with the given sub-range. A ConcatNode is an interior (non-leaf) node that represents the concatination of the left and right child nodes. Both children must always be non-null. The left and right child nodes. They are never null. The left and right child nodes. They are never null. The depth of this node -- the maximum length path to a leaf. If this node has two children that are leaves, the depth in 1. The depth of this node -- the maximum length path to a leaf. If this node has two children that are leaves, the depth in 1. The depth of this node. Create a new ConcatNode with the given children. The left child. May not be null. The right child. May not be null. Create a new node with the given children. Mark unchanged children as shared. There are four possible cases: 1. If one of the new children is null, the other new child is returned. 2. If neither child has changed, then this is marked as shared as returned. 3. If one child has changed, the other child is marked shared an a new node is returned. 4. If both children have changed, a new node is returned. New left child. New right child. New node with the given children. Returns null if and only if both new children are null. Updates a node with the given new children. If one of the new children is null, the other is returned. If both are null, null is returned. New left child. New right child. Node with the given children. Usually, but not always, this. Returns null if and only if both new children are null. Returns the items at the given index in this node. 0-based index, relative to this node. Item at that index. Changes the item at the given index. May change this node, or return a new node with the given item changed. Index, relative to this node, to change. New item to place at the given index. A node with the give item changed. If it can be done in place then "this" is returned. Changes the item at the given index. Never changes this node, but always returns a new node with the given item changed. Index, relative to this node, to change. New item to place at the given index. A new node with the given item changed. Prepend a item before this node. May change this node, or return a new node. Equivalent to PrependInPlace(new LeafNode(item), true), but may be more efficient because a new LeafNode might not be allocated. Item to prepend. A node with the given item prepended to this node. May be a new node or the current node. Append a item after this node. May change this node, or return a new node. Equivalent to AppendInPlace(new LeafNode(item), true), but may be more efficient because a new LeafNode might not be allocated. Item to append. A node with the given item appended to this node. May be a new node or the current node. Append a node after this node. May change this node, or return a new node. Node to append. If true, the given node is not used in any current list, so it may be change, overwritten, or destroyed if convenient. If false, the given node is in use. It should be marked as shared if is is used within the return value. A node with the give node appended to this node. May be a new node or the current node. Inserts an item inside this node. May change this node, or return a new node with the given appending done. Equivalent to InsertInPlace(new LeafNode(item), true), but may be more efficient. Index, relative to this node, to insert at. Must be in bounds. Item to insert. A node with the give item inserted. If done in-place, returns "this". Inserts a node inside this node. May change this node, or return a new node with the given appending done. Index, relative to this node, to insert at. Must be in bounds. Node to insert. If true, the given node is not used in any current list, so it may be change, overwritten, or destroyed if convenient. If false, the given node is in use. It should be marked as shared if is is used within the return value. A node with the given item inserted. If done in-place, returns "this". Inserts a node inside this node. Never changes this node, but returns a new node with the given appending done. Index, relative to this node, to insert at. Must be in bounds. Node to insert. If true, the given node is not used in any current list, so it may be change, overwritten, or destroyed if convenient. If false, the given node is in use. It should be marked as shared if is is used within the return value. A new node with the give node inserted. Remove a range of items from this node. May change this node, or returns a new node with the given appending done. The sub-range may not be empty, but may extend outside the node. In other words, first might be less than zero or last might be greater than count. But, last can't be less than zero and first can't be greater than count. Also, last must be greater than or equal to last. Inclusive index of first item in sub-range, relative to this node. Inclusize index of last item in sub-range, relative to this node. A node with the sub-range removed. If done in-place, returns "this". Remove a range of items from this node. Never changes this node, but returns a new node with the removing done. The sub-range may not be empty, but may extend outside the node. In other words, first might be less than zero or last might be greater than count. But, last can't be less than zero and first can't be greater than count. Also, last must be greater than or equal to last. Inclusive index of first item in sub-range, relative to this node. Inclusize index of last item in sub-range, relative to this node. A new node with the sub-range removed. Returns a node that has a sub-range of items from this node. The sub-range may not be empty, but may extend outside the node. In other words, first might be less than zero or last might be greater than count. But, last can't be less than zero and first can't be greater than count. Also, last must be greater than or equal to last. Inclusive first element, relative to this node. Inclusize last element, relative to this node. Node with the given sub-range. The class that is used to implement IList<T> to view a sub-range of a BigList. The object stores a wrapped list, and a start/count indicating a sub-range of the list. Insertion/deletions through the sub-range view cause the count to change also; insertions and deletions directly on the wrapped list do not. This is different from Algorithms.Range in a very few respects: it is specialized to only wrap BigList, and it is a lot more efficient in enumeration. Create a sub-range view object on the indicate part of the list. List to wrap. The start index of the view in the wrapped list. The number of items in the view. MultiDictionaryBase is a base class that can be used to more easily implement a class that associates multiple values to a single key. The class implements the generic IDictionary<TKey, ICollection<TValue>> interface. The resulting collection is read-only -- items cannot be added or removed. To use ReadOnlyMultiDictionaryBase as a base class, the derived class must override Count, Contains(TKey,TValue), EnumerateKeys, and TryEnumerateValuesForKey . The key type of the dictionary. The value type of the dictionary. Creates a new ReadOnlyMultiDictionaryBase. Throws an NotSupportedException stating that this collection cannot be modified. Gets the number of keys in the dictionary. This property must be overridden in the derived class. Enumerate all the keys in the dictionary. This method must be overridden by a derived class. An IEnumerator<TKey> that enumerates all of the keys in the collection that have at least one value associated with them. Enumerate all of the values associated with a given key. This method must be overridden by the derived class. If the key exists and has values associated with it, an enumerator for those values is returned throught . If the key does not exist, false is returned. The key to get values for. If true is returned, this parameter receives an enumerators that enumerates the values associated with that key. True if the key exists and has values associated with it. False otherwise. Implements IDictionary<TKey, IEnumerable<TValue>>.Add. If the key is already present, and ArgumentException is thrown. Otherwise, a new key is added, and new values are associated with that key. Key to add. Values to associate with that key. The key is already present in the dictionary. Removes a key from the dictionary. This method must be overridden in the derived class. Key to remove from the dictionary. True if the key was found, false otherwise. Determines if this dictionary contains a key equal to . If so, all the values associated with that key are returned through the values parameter. This method must be overridden by the derived class. The key to search for. Returns all values associated with key, if true was returned. True if the dictionary contains key. False if the dictionary does not contain key. Determines whether a given key is found in the dictionary. The default implementation simply calls TryGetValue. It may be appropriate to override this method to provide a more efficient implementation. Key to look for in the dictionary. True if the key is present in the dictionary. Determines if this dictionary contains a key-value pair equal to and . The dictionary is not changed. This method must be overridden in the derived class. The key to search for. The value to search for. True if the dictionary has associated with . Determines if this dictionary contains the given key and all of the values associated with that key.. A key and collection of values to search for. True if the dictionary has associated all of the values in .Value with .Key. If the derived class does not use the default comparison for values, this methods should be overridden to compare two values for equality. This is used for the correct implementation of ICollection.Contains on the Values and KeyValuePairs collections. First value to compare. Second value to compare. True if the values are equal. Gets a count of the number of values associated with a key. The default implementation is slow; it enumerators all of the values (using TryEnumerateValuesForKey) to count them. A derived class may be able to supply a more efficient implementation. The key to count values for. The number of values associated with . Gets a total count of values in the collection. This default implementation is slow; it enumerates all of the keys in the dictionary and calls CountValues on each. A derived class may be able to supply a more efficient implementation. The total number of values associated with all keys in the dictionary. Gets a read-only collection all the keys in this dictionary. An readonly ICollection<TKey> of all the keys in this dictionary. Gets a read-only collection of all the values in the dictionary. A read-only ICollection<TValue> of all the values in the dictionary. Gets a read-only collection of all the value collections in the dictionary. A read-only ICollection<IEnumerable<TValue>> of all the values in the dictionary. Gets a read-only collection of all key-value pairs in the dictionary. If a key has multiple values associated with it, then a key-value pair is present for each value associated with the key. Returns a collection of all of the values in the dictionary associated with . If the key is not present in the dictionary, an ICollection with no values is returned. The returned ICollection is read-only. The key to get the values associated with. An ICollection<TValue> with all the values associated with . Gets a collection of all the values in the dictionary associated with . If the key is not present in the dictionary, a KeyNotFound exception is thrown. The key to get the values associated with. An IEnumerable<TValue> that enumerates all the values associated with . The given key is not present in the dictionary. The set accessor is called. Shows the string representation of the dictionary. The string representation contains a list of the mappings in the dictionary. The string representation of the dictionary. Display the contents of the dictionary in the debugger. This is intentionally private, it is called only from the debugger due to the presence of the DebuggerDisplay attribute. It is similar format to ToString(), but is limited to 250-300 characters or so, so as not to overload the debugger. The string representation of the items in the collection, similar in format to ToString(). Enumerate all the keys in the dictionary, and for each key, the collection of values for that key. An enumerator to enumerate all the key, ICollection<value> pairs in the dictionary. A private class that provides the ICollection<TValue> for a particular key. This is the collection that is returned from the indexer. The collections is read-write, live, and can be used to add, remove, etc. values from the multi-dictionary. Constructor. Initializes this collection. Dictionary we're using. The key we're looking at. Get the number of values associated with the key. A simple function that returns an IEnumerator<TValue> that doesn't yield any values. A helper. An IEnumerator<TValue> that yields no values. Enumerate all the values associated with key. An IEnumerator<TValue> that enumerates all the values associated with key. Determines if the given values is associated with key. Value to check for. True if value is associated with key, false otherwise. A private class that implements ICollection<TKey> and ICollection for the Keys collection. The collection is read-only. Constructor. The dictionary this is associated with. A private class that implements ICollection<TValue> and ICollection for the Values collection. The collection is read-only. A private class that implements ICollection<IEnumerable<TValue>> and ICollection for the Values collection on IDictionary. The collection is read-only. A private class that implements ICollection<KeyValuePair<TKey,TValue>> and ICollection for the KeyValuePairs collection. The collection is read-only. Set<T> is a collection that contains items of type T. The item are maintained in a haphazard, unpredictable order, and duplicate items are not allowed.

The items are compared in one of two ways. If T implements IComparable<T> then the Equals method of that interface will be used to compare items, otherwise the Equals method from Object will be used. Alternatively, an instance of IComparer<T> can be passed to the constructor to use to compare items.

Set is implemented as a hash table. Inserting, deleting, and looking up an an element all are done in approximately constant time, regardless of the number of items in the Set.

is similar, but uses comparison instead of hashing, and does maintains the items in sorted order.

Creates a new Set. The Equals method and GetHashCode method on T will be used to compare items for equality. Items that are null are permitted, and will be sorted before all other items. Creates a new Set. The Equals and GetHashCode method of the passed comparer object will be used to compare items in this set. An instance of IEqualityComparer<T> that will be used to compare items. Creates a new Set. The Equals method and GetHashCode method on T will be used to compare items for equality. Items that are null are permitted. A collection with items to be placed into the Set. Creates a new Set. The Equals and GetHashCode method of the passed comparer object will be used to compare items in this set. The set is initialized with all the items in the given collection. A collection with items to be placed into the Set. An instance of IEqualityComparer<T> that will be used to compare items. Creates a new Set given a comparer and a tree that contains the data. Used internally for Clone. EqualityComparer for the set. Data for the set. Makes a shallow clone of this set; i.e., if items of the set are reference types, then they are not cloned. If T is a value type, then each element is copied as if by simple assignment. Cloning the set takes time O(N), where N is the number of items in the set. The cloned set. Makes a shallow clone of this set; i.e., if items of the set are reference types, then they are not cloned. If T is a value type, then each element is copied as if by simple assignment. Cloning the set takes time O(N), where N is the number of items in the set. The cloned set. Makes a deep clone of this set. A new set is created with a clone of each element of this set, by calling ICloneable.Clone on each element. If T is a value type, then each element is copied as if by simple assignment. If T is a reference type, it must implement ICloneable. Otherwise, an InvalidOperationException is thrown. Cloning the set takes time O(N), where N is the number of items in the set. The cloned set. T is a reference type that does not implement ICloneable. Returns the IEqualityComparer<T> used to compare items in this set. If the set was created using a comparer, that comparer is returned. Otherwise the default comparer for T (EqualityComparer<T>.Default) is returned. Returns the number of items in the set. The size of the set is returned in constant time. The number of items in the set. Returns an enumerator that enumerates all the items in the set. The items are enumerated in sorted order.

Typically, this method is not called directly. Instead the "foreach" statement is used to enumerate the items, which uses this method implicitly.

If an item is added to or deleted from the set while it is being enumerated, then the enumeration will end with an InvalidOperationException.

Enumerating all the items in the set takes time O(N), where N is the number of items in the set.

An enumerator for enumerating all the items in the Set.
Determines if this set contains an item equal to . The set is not changed. Searching the set for an item takes approximately constant time, regardless of the number of items in the set. The item to search for. True if the set contains . False if the set does not contain . Determines if this set contains an item equal to , according to the comparison mechanism that was used when the set was created. The set is not changed. If the set does contain an item equal to , then the item from the set is returned. Searching the set for an item takes approximately constant time, regardless of the number of items in the set. In the following example, the set contains strings which are compared in a case-insensitive manner. Set<string> set = new Set<string>(StringComparer.CurrentCultureIgnoreCase); set.Add("HELLO"); string s; bool b = set.TryGetItem("Hello", out s); // b receives true, s receives "HELLO". The item to search for. Returns the item from the set that was equal to . True if the set contains . False if the set does not contain . Adds a new item to the set. If the set already contains an item equal to , that item is replaced with . Equality between items is determined by the comparison instance or delegate used to create the set. Adding an item takes approximately constant time, regardless of the number of items in the set. The item to add to the set. True if the set already contained an item equal to (which was replaced), false otherwise. Adds a new item to the set. If the set already contains an item equal to , that item is replaced with . Equality between items is determined by the comparison instance or delegate used to create the set. Adding an item takes approximately constant time, regardless of the number of items in the set. The item to add to the set. True if the set already contained an item equal to (which was replaced), false otherwise. Adds all the items in to the set. If the set already contains an item equal to one of the items in , that item will be replaced. Equality between items is determined by the comparison instance or delegate used to create the set. Adding the collection takes time O(M), where M is the number of items in . A collection of items to add to the set. Searches the set for an item equal to , and if found, removes it from the set. If not found, the set is unchanged. Equality between items is determined by the comparison instance or delegate used to create the set. Removing an item from the set takes approximately constant time, regardless of the size of the set. The item to remove. True if was found and removed. False if was not in the set. Removes all the items in from the set. Equality between items is determined by the comparison instance or delegate used to create the set. Removing the collection takes time O(M), where M is the number of items in . A collection of items to remove from the set. The number of items removed from the set. is null. Removes all items from the set. Clearing the set takes a constant amount of time, regardless of the number of items in it. Check that this set and another set were created with the same comparison mechanism. Throws exception if not compatible. Other set to check comparision mechanism. If otherSet and this set don't use the same method for comparing items. Determines if this set is a superset of another set. Neither set is modified. This set is a superset of if every element in is also in this set. IsSupersetOf is computed in time O(M), where M is the size of the . Set to compare to. True if this is a superset of . This set and don't use the same method for comparing items. Determines if this set is a proper superset of another set. Neither set is modified. This set is a proper superset of if every element in is also in this set. Additionally, this set must have strictly more items than . IsProperSubsetOf is computed in time O(M), where M is the size of . Set to compare to. True if this is a proper superset of . This set and don't use the same method for comparing items. Determines if this set is a subset of another set. Neither set is modified. This set is a subset of if every element in this set is also in . IsSubsetOf is computed in time O(N), where N is the size of the this set. Set to compare to. True if this is a subset of . This set and don't use the same method for comparing items. Determines if this set is a proper subset of another set. Neither set is modified. This set is a subset of if every element in this set is also in . Additionally, this set must have strictly fewer items than . IsProperSubsetOf is computed in time O(N), where N is the size of the this set. Set to compare to. True if this is a proper subset of . This set and don't use the same method for comparing items. Determines if this set is equal to another set. This set is equal to if they contain the same items. IsEqualTo is computed in time O(N), where N is the number of items in this set. Set to compare to True if this set is equal to , false otherwise. This set and don't use the same method for comparing items. Determines if this set is disjoint from another set. Two sets are disjoint if no item from one set is equal to any item in the other set. The answer is computed in time O(N), where N is the size of the smaller set. Set to check disjointness with. True if the two sets are disjoint, false otherwise. This set and don't use the same method for comparing items. Computes the union of this set with another set. The union of two sets is all items that appear in either or both of the sets. This set receives the union of the two sets, the other set is unchanged. If equal items appear in both sets, the union will include an arbitrary choice of one of the two equal items. The union of two sets is computed in time O(M + N), where M is the size of the larger set, and N is the size of the smaller set. Set to union with. This set and don't use the same method for comparing items. Computes the union of this set with another set. The union of two sets is all items that appear in either or both of the sets. A new set is created with the union of the sets and is returned. This set and the other set are unchanged. If equal items appear in both sets, the union will include an arbitrary choice of one of the two equal items. The union of two sets is computed in time O(M + N), where M is the size of the one set, and N is the size of the other set. Set to union with. The union of the two sets. This set and don't use the same method for comparing items. Computes the intersection of this set with another set. The intersection of two sets is all items that appear in both of the sets. This set receives the intersection of the two sets, the other set is unchanged. When equal items appear in both sets, the intersection will include an arbitrary choice of one of the two equal items. The intersection of two sets is computed in time O(N), where N is the size of the smaller set. Set to intersection with. This set and don't use the same method for comparing items. Computes the intersection of this set with another set. The intersection of two sets is all items that appear in both of the sets. A new set is created with the intersection of the sets and is returned. This set and the other set are unchanged. When equal items appear in both sets, the intersection will include an arbitrary choice of one of the two equal items. The intersection of two sets is computed in time O(N), where N is the size of the smaller set. Set to intersection with. The intersection of the two sets. This set and don't use the same method for comparing items. Computes the difference of this set with another set. The difference of these two sets is all items that appear in this set, but not in . This set receives the difference of the two sets; the other set is unchanged. The difference of two sets is computed in time O(N), where N is the size of the smaller set. Set to difference with. This set and don't use the same method for comparing items. Computes the difference of this set with another set. The difference of these two sets is all items that appear in this set, but not in . A new set is created with the difference of the sets and is returned. This set and the other set are unchanged. The difference of two sets is computed in time O(N), where N is the size of the smaller set. Set to difference with. The difference of the two sets. This set and don't use the same method for comparing items. Computes the symmetric difference of this set with another set. The symmetric difference of two sets is all items that appear in either of the sets, but not both. This set receives the symmetric difference of the two sets; the other set is unchanged. The symmetric difference of two sets is computed in time O(N), where N is the size of the smaller set. Set to symmetric difference with. This set and don't use the same method for comparing items. Computes the symmetric difference of this set with another set. The symmetric difference of two sets is all items that appear in either of the sets, but not both. A new set is created with the symmetric difference of the sets and is returned. This set and the other set are unchanged. The symmetric difference of two sets is computed in time O(N), where N is the size of the smaller set. Set to symmetric difference with. The symmetric difference of the two sets. This set and don't use the same method for comparing items. A collection of methods to create IComparer and IEqualityComparer instances in various ways. Class to change an IEqualityComparer<TKey> to an IEqualityComparer<KeyValuePair<TKey, TValue>> Only the keys are compared. Class to change an IComparer<TKey> to an IComparer<KeyValuePair<TKey, TValue>> Only the keys are compared. Class to change an IComparer<TKey> and IComparer<TValue> to an IComparer<KeyValuePair<TKey, TValue>> Keys are compared, followed by values. Class to change an Comparison<T> to an IComparer<T>. Class to change an Comparison<TKey> to an IComparer<KeyValuePair<TKey, TValue>>. GetHashCode cannot be used on this class. Given an Comparison on a type, returns an IComparer on that type. T to compare. Comparison delegate on T IComparer that uses the comparison. Given an IComparer on TKey, returns an IComparer on key-value Pairs. TKey of the pairs TValue of the apris IComparer on TKey IComparer for comparing key-value pairs. Given an IEqualityComparer on TKey, returns an IEqualityComparer on key-value Pairs. TKey of the pairs TValue of the apris IComparer on TKey IEqualityComparer for comparing key-value pairs. Given an IComparer on TKey and TValue, returns an IComparer on key-value Pairs of TKey and TValue, comparing first keys, then values. TKey of the pairs TValue of the apris IComparer on TKey IComparer on TValue IComparer for comparing key-value pairs. Given an Comparison on TKey, returns an IComparer on key-value Pairs. TKey of the pairs TValue of the apris Comparison delegate on TKey IComparer for comparing key-value pairs. Given an element type, check that it implements IComparable<T> or IComparable, then returns a IComparer that can be used to compare elements of that type. The IComparer<T> instance. T does not implement IComparable<T>. Given an key and value type, check that TKey implements IComparable<T> or IComparable, then returns a IComparer that can be used to compare KeyValuePairs of those types. The IComparer<KeyValuePair<TKey, TValue>> instance. TKey does not implement IComparable<T>. Describes what to do if a key is already in the tree when doing an insertion. The base implementation for various collections classes that use Red-Black trees as part of their implementation. This class should not (and can not) be used directly by end users; it's only for internal use by the collections package. The Red-Black tree manages items of type T, and uses a IComparer<T> that compares items to sort the tree. Multiple items can compare equal and be stored in the tree. Insert, Delete, and Find operations are provided in their full generality; all operations allow dealing with either the first or last of items that compare equal. Create an array of Nodes big enough for any path from top to bottom. This is cached, and reused from call-to-call, so only one can be around at a time per tree. The node stack. The class that is each node in the red-black tree. Is this a red node? Get or set the Count field -- a 31-bit field that holds the number of nodes at or below this level. Add one to the Count. Subtract one from the Count. The current Count must be non-zero. Clones a node and all its descendants. The cloned node. Must be called whenever there is a structural change in the tree. Causes changeStamp to be changed, which causes any in-progress enumerations to throw exceptions. Checks the given stamp against the current change stamp. If different, the collection has changed during enumeration and an InvalidOperationException must be thrown changeStamp at the start of the enumeration. Initialize a red-black tree, using the given interface instance to compare elements. Only Compare is used on the IComparer interface. The IComparer<T> used to sort keys. Returns the number of elements in the tree. Clone the tree, returning a new tree containing the same items. Should take O(N) take. Clone version of this tree. Finds the key in the tree. If multiple items in the tree have compare equal to the key, finds the first or last one. Optionally replaces the item with the one searched for. Key to search for. If true, find the first of duplicates, else finds the last of duplicates. If true, replaces the item with key (if function returns true) Returns the found item, before replacing (if function returns true). True if the key was found. Finds the index of the key in the tree. If multiple items in the tree have compare equal to the key, finds the first or last one. Key to search for. If true, find the first of duplicates, else finds the last of duplicates. Index of the item found if the key was found, -1 if not found. Find the item at a particular index in the tree. The zero-based index of the item. Must be >= 0 and < Count. The item at the particular index. Insert a new node into the tree, maintaining the red-black invariants. Algorithm from Sedgewick, "Algorithms". The new item to insert What to do if equal item is already present. If false, returned, the previous item. false if duplicate exists, otherwise true. Split a node with two red children (a 4-node in the 2-3-4 tree formalism), as part of an insert operation. great grand-parent of "node", can be null near root grand-parent of "node", can be null near root parent of "node", can be null near root Node to split, can't be null Indicates that rotation(s) occurred in the tree. Node to continue searching from. Performs a rotation involving the node, it's child and grandchild. The counts of childs and grand-child are set the correct values from their children; this is important if they have been adjusted on the way down the try as part of an insert/delete. Top node of the rotation. Can be null if child==root. One child of "node". Not null. One child of "child". Not null. Deletes a key from the tree. If multiple elements are equal to key, deletes the first or last. If no element is equal to the key, returns false. Top-down algorithm from Weiss. Basic plan is to move down in the tree, rotating and recoloring along the way to always keep the current node red, which ensures that the node we delete is red. The details are quite complex, however! Key to delete. Which item to delete if multiple are equal to key. True to delete the first, false to delete last. Returns the item that was deleted, if true returned. True if an element was deleted, false if no element had specified key. Enumerate all the items in-order An enumerator for all the items, in order. The tree has an item added or deleted during the enumeration. Enumerate all the items in-order An enumerator for all the items, in order. The tree has an item added or deleted during the enumeration. A delegate that tests if an item is within a custom range. The range must be a contiguous range of items with the ordering of this tree. The range test function must test if an item is before, withing, or after the range. Item to test against the range. Returns negative if item is before the range, zero if item is withing the range, and positive if item is after the range. Gets a range tester that defines a range by first and last items. If true, bound the range on the bottom by first. If useFirst is true, the inclusive lower bound. If true, bound the range on the top by last. If useLast is true, the exclusive upper bound. A RangeTester delegate that tests for an item in the given range. Gets a range tester that defines a range by first and last items. The lower bound. True if the lower bound is inclusive, false if exclusive. The upper bound. True if the upper bound is inclusive, false if exclusive. A RangeTester delegate that tests for an item in the given range. Gets a range tester that defines a range by a lower bound. The lower bound. True if the lower bound is inclusive, false if exclusive. A RangeTester delegate that tests for an item in the given range. Gets a range tester that defines a range by upper bound. The upper bound. True if the upper bound is inclusive, false if exclusive. A RangeTester delegate that tests for an item in the given range. Gets a range tester that defines a range by all items equal to an item. The item that is contained in the range. A RangeTester delegate that tests for an item equal to . A range tester that defines a range that is the entire tree. Item to test. Always returns 0. Enumerate the items in a custom range in the tree. The range is determined by a RangeTest delegate. Tests an item against the custom range. An IEnumerable<T> that enumerates the custom range in order. The tree has an item added or deleted during the enumeration. Enumerate all the items in a custom range, under and including node, in-order. Tests an item against the custom range. Node to begin enumeration. May be null. An enumerable of the items. The tree has an item added or deleted during the enumeration. Enumerate the items in a custom range in the tree, in reversed order. The range is determined by a RangeTest delegate. Tests an item against the custom range. An IEnumerable<T> that enumerates the custom range in reversed order. The tree has an item added or deleted during the enumeration. Enumerate all the items in a custom range, under and including node, in reversed order. Tests an item against the custom range. Node to begin enumeration. May be null. An enumerable of the items, in reversed oreder. The tree has an item added or deleted during the enumeration. Deletes either the first or last item from a range, as identified by a RangeTester delegate. If the range is empty, returns false. Top-down algorithm from Weiss. Basic plan is to move down in the tree, rotating and recoloring along the way to always keep the current node red, which ensures that the node we delete is red. The details are quite complex, however! Range to delete from. If true, delete the first item from the range, else the last. Returns the item that was deleted, if true returned. True if an element was deleted, false if the range is empty. Delete all the items in a range, identified by a RangeTester delegate. The delegate that defines the range to delete. The number of items deleted. Count the items in a custom range in the tree. The range is determined by a RangeTester delegate. The delegate that defines the range. The number of items in the range. Count all the items in a custom range, under and including node. The delegate that defines the range. Node to begin enumeration. May be null. This node and all under it are either in the range or below it. This node and all under it are either in the range or above it. The number of items in the range, under and include node. Find the first item in a custom range in the tree, and it's index. The range is determined by a RangeTester delegate. The delegate that defines the range. Returns the item found, if true was returned. Index of first item in range if range is non-empty, -1 otherwise. Find the last item in a custom range in the tree, and it's index. The range is determined by a RangeTester delegate. The delegate that defines the range. Returns the item found, if true was returned. Index of the item if range is non-empty, -1 otherwise. 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.

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.

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

Helper function to create a new KeyValuePair struct. The key. The value. A new KeyValuePair. Helper function to create a new KeyValuePair struct with a default value. The key. A new KeyValuePair. 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. TKey does not implement IComparable<TKey>. Creates a new OrderedDictionary. The Compare method of the passed comparison object will be used to compare keys in this dictionary. The GetHashCode and Equals methods of the provided IComparer<TKey> will never be called, and need not be implemented. An instance of IComparer<TKey> that will be used to compare keys. Creates a new OrderedDictionary. The passed delegate will be used to compare keys in this dictionary. A delegate to a method that will be used to compare keys. 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. A collection of keys and values whose contents are used to initialized the dictionary. TKey does not implement IComparable<TKey>. 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. The GetHashCode and Equals methods of the provided IComparer<TKey> will never be called, and need not be implemented. A collection of keys and values whose contents are used to initialized the dictionary. An instance of IComparer<TKey> that will be used to compare keys. 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. A collection of keys and values whose contents are used to initialized the dictionary. A delegate to a method that will be used to compare keys. Creates a new OrderedDictionary. The passed comparer will be used to compare key-value pairs in this dictionary. Used internally from other constructors. A collection of keys and values whose contents are used to initialized the dictionary. An IComparer that will be used to compare keys. An IComparer that will be used to compare key-value pairs. Creates a new OrderedDictionary. The passed comparison delegate will be used to compare keys in this dictionary, and the given tree is used. Used internally for Clone(). An IComparer that will be used to compare keys. A delegate to a method that will be used to compare key-value pairs. RedBlackTree that contains the data for the dictionary. 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. Cloning the dictionary takes time O(N), where N is the number of keys in the dictionary. The cloned dictionary. Throw an InvalidOperationException indicating that this type is not cloneable. Type to test. 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. If TKey or TValue is a reference type, it must implement ICloneable. Otherwise, an InvalidOperationException is thrown. Cloning the dictionary takes time O(N log N), where N is the number of keys in the dictionary. The cloned dictionary. TKey or TValue is a reference type that does not implement ICloneable. Returns the IComparer<T> used to compare keys in this dictionary. If the dictionary was created using a comparer, that comparer is returned. If the dictionary was created using a comparison delegate, then a comparer equivalent to that delegate is returned. Otherwise the default comparer for TKey (Comparer<TKey>.Default) is returned. Returns a View collection that can be used for enumerating the keys and values in the collection in reversed order.

Typically, this method is used in conjunction with a foreach statement. For example: foreach(KeyValuePair<TKey, TValue> pair in dictionary.Reversed()) { // process pair }

If an entry is added to or deleted from the dictionary while the View is being enumerated, then the enumeration will end with an InvalidOperationException.

Calling Reverse does not copy the data in the dictionary, and the operation takes constant time.

An OrderedDictionary.View of key-value pairs in reverse order.
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 less than 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 and parameters.

If is greater than or equal to , the returned collection is empty.

The sorted order of the keys is determined by the comparison instance or delegate used to create the dictionary.

Typically, this property is used in conjunction with a foreach statement. For example:

foreach(KeyValuePair<TKey, TValue> pair in dictionary.Range(from, true, to, false)) { // process pair }

Calling Range does not copy the data in the dictionary, and the operation takes constant time.

The lower bound of the range. If true, the lower bound is inclusive--keys equal to the lower bound will be included in the range. If false, the lower bound is exclusive--keys equal to the lower bound will not be included in the range. The upper bound of the range. If true, the upper bound is inclusive--keys equal to the upper bound will be included in the range. If false, the upper bound is exclusive--keys equal to the upper bound will not be included in the range. An OrderedDictionary.View of key-value pairs in the given range.
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) are included. The keys are enumerated in sorted order. Keys equal to can be included or excluded depending on the parameter.

The sorted order of the keys is determined by the comparison instance or delegate used to create the dictionary.

Typically, this property is used in conjunction with a foreach statement. For example:

foreach(KeyValuePair<TKey, TValue> pair in dictionary.RangeFrom(from, true)) { // process pair }

Calling RangeFrom does not copy of the data in the dictionary, and the operation takes constant time.

The lower bound of the range. If true, the lower bound is inclusive--keys equal to the lower bound will be included in the range. If false, the lower bound is exclusive--keys equal to the lower bound will not be included in the range. An OrderedDictionary.View of key-value pairs in the given range.
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) are included. The items are enumerated in sorted order. Items equal to can be included or excluded depending on the parameter.

The sorted order of the keys is determined by the comparison instance or delegate used to create the dictionary.

Typically, this property is used in conjunction with a foreach statement. For example:

foreach(KeyValuePair<TKey, TValue> pair in dictionary.RangeFrom(from, false)) { // process pair }

Calling RangeTo does not copy the data in the dictionary, and the operation takes constant time.

The upper bound of the range. If true, the upper bound is inclusive--keys equal to the upper bound will be included in the range. If false, the upper bound is exclusive--keys equal to the upper bound will not be included in the range. An OrderedDictionary.View of key-value pairs in the given range.
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. Equality between keys is determined by the comparison instance or delegate used to create the dictionary. The key to remove. True if the key was found and removed. False if the key was not found. Removes all keys and values from the dictionary. Clearing the dictionary takes a constant amount of time, regardless of the number of keys in it. 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. between keys is determined by the comparison instance or delegate used to create the dictionary. This method takes time O(log N), where N is the number of keys in the dictionary. If a value is added, It is more efficient than calling TryGetValue followed by Add, because the dictionary is not searched twice. The new key. The new value to associated with that key, if the key isn't present. If the key was present, returns the exist value associated with that key. True if key was already present, false if key wasn't present (and a new value was added). 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 Equality between keys is determined by the comparison instance or delegate used to create the dictionary. Adding an key and value takes time O(log N), where N is the number of keys in the dictionary. The new key. "null" is a valid key value. The new value to associated with that key. key is already present in the dictionary 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.

Unlike adding or removing an element, changing the value associated with a key can be performed while an enumeration (foreach) on the the dictionary is in progress.

Equality between keys is determined by the comparison instance or delegate used to create the dictionary.

Replace takes time O(log N), where N is the number of entries in the dictionary.

The new key. The new value to associated with that key. key is not present in the dictionary
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 (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. AddMany takes time O(M log (N+M)), where M is the size of , and N is the size of this dictionary. A collection of keys and values whose contents are added to the current dictionary. 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. RemoveMany takes time O(M log N), where M is the size of keyCollectionToRemove, and N is this size of this collection. The number of keys removed from the dictionary. A collection of keys to remove from the dictionary. 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. The indexer takes time O(log N), where N is the number of entries in the dictionary. The value associated with the key A value is being retrieved, and the key is not present in the dictionary. is null. Determines if this dictionary contains a key equal to . The dictionary is not changed. Searching the dictionary for a key takes time O(log N), where N is the number of keys in the dictionary. The key to search for. True if the dictionary contains key. False if the dictionary does not contain key. Determines if this dictionary contains a key equal to . If so, the value associated with that key is returned through the value parameter. TryGetValue takes time O(log N), where N is the number of entries in the dictionary. The key to search for. Returns the value associated with key, if true was returned. True if the dictionary contains key. False if the dictionary does not contain key. Returns the number of keys in the dictionary. The size of the dictionary is returned in constant time.. The number of keys in the dictionary. 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.

Typically, this method is not called directly. Instead the "foreach" statement is used to enumerate the elements of the dictionary, which uses this method implicitly.

If an element is added to or deleted from the dictionary while it is being enumerated, then the enumeration will end with an InvalidOperationException.

Enumeration all the entries in the dictionary takes time O(N log N), where N is the number of entries in the dictionary.

An enumerator for enumerating all the elements in the OrderedDictionary.
Implements ICloneable.Clone. Makes a shallow clone of this dictionary; i.e., if keys or values are reference types, then they are not cloned. The cloned dictionary. The OrderedDictionary<TKey,TValue>.View class is used to look at a subset of the keys and values inside an ordered dictionary. It is returned from the Range, RangeTo, RangeFrom, and Reversed methods.

Views are dynamic. If the underlying dictionary changes, the view changes in sync. If a change is made to the view, the underlying dictionary changes accordingly.

Typically, this class is used in conjunction with a foreach statement to enumerate the keys and values in a subset of the OrderedDictionary. For example:

foreach(KeyValuePair<TKey, TValue> pair in dictionary.Range(from, to)) { // process pair }
Initialize the View. Associated OrderedDictionary to be viewed. Range tester that defines the range being used. If true, then rangeTester defines the entire tree. Is the view enuemerated in reverse order? Determine if the given key lies within the bounds of this view. Key to test. True if the key is within the bounds of this view. Enumerate all the keys and values in this view. An IEnumerator of KeyValuePairs with the keys and views in this view. Number of keys in this view. Number of keys that lie within the bounds the view. Tests if the key is present in the part of the dictionary being viewed. Key to check for. True if the key is within this view. Determines if this view contains a key equal to . If so, the value associated with that key is returned through the value parameter. The key to search for. Returns the value associated with key, if true was returned. True if the key is within this view. 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. When setting a value, the key must be within the range of keys being viewed. The value associated with the key. A value is being retrieved, and the key is not present in the dictionary, or a value is being set, and the key is outside the range of keys being viewed by this View. Removes the key (and associated value) from the underlying dictionary of this view. that is equal to the passed in key. If no key in the view is equal to the passed key, the dictionary and view are unchanged. The key to remove. True if the key was found and removed. False if the key was not found. Removes all the keys and values within this view from the underlying OrderedDictionary. The following removes all the keys that start with "A" from an OrderedDictionary. dictionary.Range("A", "B").Clear(); Creates a new View that has the same keys and values as this, in the reversed order. A new View that has the reversed order of this view. A holder class for localizable strings that are used. Currently, these are not loaded from resources, but just coded into this class. To make this library localizable, simply change this class to load the given strings from resources. Stores a triple of objects within a single struct. This struct is useful to use as the T of a collection, or as the TKey or TValue of a dictionary. Comparers for the first and second type that are used to compare values. The first element of the triple. The second element of the triple. The thrid element of the triple. Creates a new triple with given elements. The first element of the triple. The second element of the triple. The third element of the triple. Determines if this triple is equal to another object. The triple is equal to another object if that object is a Triple, all element types are the same, and the all three elements compare equal using object.Equals. Object to compare for equality. True if the objects are equal. False if the objects are not equal. Determines if this triple is equal to another triple. Two triples are equal if the all three elements compare equal using IComparable<T>.Equals or object.Equals. Triple to compare with for equality. True if the triples are equal. False if the triples are not equal. Returns a hash code for the triple, suitable for use in a hash-table or other hashed collection. Two triples that compare equal (using Equals) will have the same hash code. The hash code for the triple is derived by combining the hash codes for each of the two elements of the triple. The hash code. Compares this triple to another triple of the some type. The triples are compared by using the IComparable<T> or IComparable interface on TFirst, TSecond, and TThird. The triples are compared by their first elements first, if their first elements are equal, then they are compared by their second elements. If their second elements are also equal, then they are compared by their third elements. If TFirst, TSecond, or TThird does not implement IComparable<T> or IComparable, then an NotSupportedException is thrown, because the triples cannot be compared. The triple to compare to. An integer indicating how this triple compares to . Less than zero indicates this triple is less than . Zero indicate this triple is equals to . Greater than zero indicates this triple is greater than . Either FirstSecond, TSecond, or TThird is not comparable via the IComparable<T> or IComparable interfaces. Compares this triple to another triple of the some type. The triples are compared by using the IComparable<T> or IComparable interface on TFirst, TSecond, and TThird. The triples are compared by their first elements first, if their first elements are equal, then they are compared by their second elements. If their second elements are also equal, then they are compared by their third elements. If TFirst, TSecond, or TThird does not implement IComparable<T> or IComparable, then an NotSupportedException is thrown, because the triples cannot be compared. The triple to compare to. An integer indicating how this triple compares to . Less than zero indicates this triple is less than . Zero indicate this triple is equals to . Greater than zero indicates this triple is greater than . is not of the correct type. Either FirstSecond, TSecond, or TThird is not comparable via the IComparable<T> or IComparable interfaces. Returns a string representation of the triple. The string representation of the triple is of the form: First: {0}, Second: {1}, Third: {2} where {0} is the result of First.ToString(), {1} is the result of Second.ToString(), and {2} is the result of Third.ToString() (or "null" if they are null.) The string representation of the triple. Determines if two triples are equal. Two triples are equal if the all three elements compare equal using IComparable<T>.Equals or object.Equals. First triple to compare. Second triple to compare. True if the triples are equal. False if the triples are not equal. Determines if two triples are not equal. Two triples are equal if the all three elements compare equal using IComparable<T>.Equals or object.Equals. First triple to compare. Second triple to compare. True if the triples are not equal. False if the triples are equal. A holder class for various internal utility functions that need to be shared. Determine if a type is cloneable: either a value type or implementing ICloneable. Type to check. Returns if the type is a value type, and does not implement ICloneable. True if the type is cloneable. Returns the simple name of the class, for use in exception messages. The simple name of this class. Wrap an enumerable so that clients can't get to the underlying implementation via a down-cast. Create the wrapper around an enumerable. IEnumerable to wrap. Wrap an enumerable so that clients can't get to the underlying implementation via a down-case Enumerable to wrap. A wrapper around the enumerable. Gets the hash code for an object using a comparer. Correctly handles null. Item to get hash code for. Can be null. The comparer to use. The hash code for the item.