NetTopologySuite
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
Wintellect.PowerCollections.OrderedSet< T > Class Template Reference

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

Inheritance diagram for Wintellect.PowerCollections.OrderedSet< T >:
Wintellect.PowerCollections.CollectionBase< T > Wintellect.PowerCollections.OrderedSet< T >.View Wintellect.PowerCollections.OrderedSet< T >.View

Classes

class  View
 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. More...
 

Public Member Functions

 OrderedSet ()
 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. More...
 
 OrderedSet (Comparison< T > comparison)
 Creates a new OrderedSet. The passed delegate will be used to compare items in this set. More...
 
 OrderedSet (IComparer< T > comparer)
 Creates a new OrderedSet. The Compare method of the passed comparison object will be used to compare items in this set. More...
 
 OrderedSet (IEnumerable< T > collection)
 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. More...
 
 OrderedSet (IEnumerable< T > collection, Comparison< T > comparison)
 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. More...
 
 OrderedSet (IEnumerable< T > collection, IComparer< T > comparer)
 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. More...
 
OrderedSet< T > Clone ()
 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. More...
 
OrderedSet< T > CloneContents ()
 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. More...
 
sealed override IEnumerator< T > GetEnumerator ()
 Returns an enumerator that enumerates all the items in the set. The items are enumerated in sorted order. More...
 
sealed override bool Contains (T item)
 Determines if this set contains an item equal to item . The set is not changed. More...
 
bool TryGetItem (T item, out T foundItem)
 
int IndexOf (T item)
 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. More...
 
new bool Add (T item)
 Adds a new item to the set. If the set already contains an item equal to item , that item is replaced with item . More...
 
void AddMany (IEnumerable< T > collection)
 Adds all the items in collection to the set. If the set already contains an item equal to one of the items in collection , that item will be replaced. More...
 
sealed override bool Remove (T item)
 Searches the set for an item equal to item , and if found, removes it from the set. If not found, the set is unchanged. More...
 
int RemoveMany (IEnumerable< T > collection)
 Removes all the items in collection from the set. Items not present in the set are ignored. More...
 
sealed override void Clear ()
 Removes all items from the set. More...
 
GetFirst ()
 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. More...
 
GetLast ()
 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. More...
 
RemoveFirst ()
 Removes the first item in the set. This is also the smallest item in the set. More...
 
RemoveLast ()
 Removes the last item in the set. This is also the largest item in the set. More...
 
bool IsSupersetOf (OrderedSet< T > otherSet)
 Determines if this set is a superset of another set. Neither set is modified. This set is a superset of otherSet if every element in otherSet is also in this set. More...
 
bool IsProperSupersetOf (OrderedSet< T > otherSet)
 Determines if this set is a proper superset of another set. Neither set is modified. This set is a proper superset of otherSet if every element in otherSet is also in this set. Additionally, this set must have strictly more items than otherSet . More...
 
bool IsSubsetOf (OrderedSet< T > otherSet)
 Determines if this set is a subset of another set. Neither set is modified. This set is a subset of otherSet if every element in this set is also in otherSet . More...
 
bool IsProperSubsetOf (OrderedSet< T > otherSet)
 Determines if this set is a proper subset of another set. Neither set is modified. This set is a subset of otherSet if every element in this set is also in otherSet . Additionally, this set must have strictly fewer items than otherSet . More...
 
bool IsEqualTo (OrderedSet< T > otherSet)
 Determines if this set is equal to another set. This set is equal to otherSet if they contain the same items. More...
 
void UnionWith (OrderedSet< T > otherSet)
 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. More...
 
bool IsDisjointFrom (OrderedSet< T > otherSet)
 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. More...
 
OrderedSet< T > Union (OrderedSet< T > otherSet)
 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. More...
 
void IntersectionWith (OrderedSet< T > otherSet)
 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. More...
 
OrderedSet< T > Intersection (OrderedSet< T > otherSet)
 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. More...
 
void DifferenceWith (OrderedSet< T > otherSet)
 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 otherSet . This set receives the difference of the two sets; the other set is unchanged. More...
 
OrderedSet< T > Difference (OrderedSet< T > otherSet)
 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 otherSet . A new set is created with the difference of the sets and is returned. This set and the other set are unchanged. More...
 
void SymmetricDifferenceWith (OrderedSet< T > otherSet)
 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. More...
 
OrderedSet< T > SymmetricDifference (OrderedSet< T > otherSet)
 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. More...
 
IList< T > AsList ()
 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. More...
 
View Reversed ()
 Returns a View collection that can be used for enumerating the items in the set in reversed order. More...
 
View Range (T from, bool fromInclusive, T to, bool toInclusive)
 Returns a View collection that can be used for enumerating a range of the items in the set.. Only items that are greater than from and less than to 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 fromInclusive and toInclusive parameters. More...
 
View RangeFrom (T from, bool fromInclusive)
 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) from are included. The items are enumerated in sorted order. Items equal to from can be included or excluded depending on the fromInclusive parameter. More...
 
View RangeTo (T to, bool toInclusive)
 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) to are included. The items are enumerated in sorted order. Items equal to to can be included or excluded depending on the toInclusive parameter. More...
 
- Public Member Functions inherited from Wintellect.PowerCollections.CollectionBase< T >
override string ToString ()
 Shows the string representation of the collection. The string representation contains a list of the items in the collection. Contained collections (except string) are expanded recursively. More...
 

Properties

IComparer< T > Comparer [get]
 Returns the IComparer<T> used to compare items in this set. More...
 
sealed override int Count [get]
 Returns the number of items in the set. More...
 
this[int index] [get]
 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. More...
 

Additional Inherited Members

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

Detailed Description

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.

Set&lt;T&gt; is similar, but uses hashing instead of comparison, and does not maintain the items in sorted order.

/remarks> seealso cref="Set&lt;T&gt;"/>

Constructor & Destructor Documentation

Wintellect.PowerCollections.OrderedSet< T >.OrderedSet ( )

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.

remarks> Items that are null are permitted, and will be sorted before all other items. /remarks>

Exceptions
InvalidOperationExceptionT does not implement IComparable<TKey>.
Wintellect.PowerCollections.OrderedSet< T >.OrderedSet ( Comparison< T >  comparison)

Creates a new OrderedSet. The passed delegate will be used to compare items in this set.

Parameters
comparisonA delegate to a method that will be used to compare items.
Wintellect.PowerCollections.OrderedSet< T >.OrderedSet ( IComparer< T >  comparer)

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.

Parameters
comparerAn instance of IComparer<T> that will be used to compare items.
Wintellect.PowerCollections.OrderedSet< T >.OrderedSet ( IEnumerable< T >  collection)

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.

remarks> Items that are null are permitted, and will be sorted before all other items. /remarks>

Parameters
collectionA collection with items to be placed into the OrderedSet.
Exceptions
InvalidOperationExceptionT does not implement IComparable<TKey>.
Wintellect.PowerCollections.OrderedSet< T >.OrderedSet ( IEnumerable< T >  collection,
Comparison< T >  comparison 
)

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.

Parameters
collectionA collection with items to be placed into the OrderedSet.
comparisonA delegate to a method that will be used to compare items.
Wintellect.PowerCollections.OrderedSet< T >.OrderedSet ( IEnumerable< T >  collection,
IComparer< T >  comparer 
)

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.

Parameters
collectionA collection with items to be placed into the OrderedSet.
comparerAn instance of IComparer<T> that will be used to compare items.

Member Function Documentation

new bool Wintellect.PowerCollections.OrderedSet< T >.Add ( item)

Adds a new item to the set. If the set already contains an item equal to item , that item is replaced with item .

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.

Parameters
itemThe item to add to the set.
Returns
True if the set already contained an item equal to item (which was replaced), false otherwise.
void Wintellect.PowerCollections.OrderedSet< T >.AddMany ( IEnumerable< T >  collection)

Adds all the items in collection to the set. If the set already contains an item equal to one of the items in collection , 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 collection .

Parameters
collectionA collection of items to add to the set.
IList<T> Wintellect.PowerCollections.OrderedSet< T >.AsList ( )

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.

Returns
A read-only IList<T> view onto this OrderedSet.
sealed override void Wintellect.PowerCollections.OrderedSet< T >.Clear ( )

Removes all items from the set.

Clearing the sets takes a constant amount of time, regardless of the number of items in it.

OrderedSet<T> Wintellect.PowerCollections.OrderedSet< T >.Clone ( )

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.

Returns
The cloned set.
OrderedSet<T> Wintellect.PowerCollections.OrderedSet< T >.CloneContents ( )

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.

Returns
The cloned set.
Exceptions
InvalidOperationExceptionT is a reference type that does not implement ICloneable.
sealed override bool Wintellect.PowerCollections.OrderedSet< T >.Contains ( item)

Determines if this set contains an item equal to item . 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.

Parameters
itemThe item to search for.
Returns
True if the set contains item . False if the set does not contain item .
OrderedSet<T> Wintellect.PowerCollections.OrderedSet< T >.Difference ( OrderedSet< T >  otherSet)

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

Parameters
otherSetSet to difference with.
Returns
The difference of the two sets.
Exceptions
InvalidOperationExceptionThis set and otherSet don't use the same method for comparing items.
void Wintellect.PowerCollections.OrderedSet< T >.DifferenceWith ( OrderedSet< T >  otherSet)

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

Parameters
otherSetSet to difference with.
Exceptions
InvalidOperationExceptionThis set and otherSet don't use the same method for comparing items.
sealed override IEnumerator<T> Wintellect.PowerCollections.OrderedSet< T >.GetEnumerator ( )

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.

Returns
An enumerator for enumerating all the items in the OrderedSet.
T Wintellect.PowerCollections.OrderedSet< T >.GetFirst ( )

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.

Returns
The first item in the set.
Exceptions
InvalidOperationExceptionThe set is empty.
T Wintellect.PowerCollections.OrderedSet< T >.GetLast ( )

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.

Returns
The lastl item in the set.
Exceptions
InvalidOperationExceptionThe set is empty.
int Wintellect.PowerCollections.OrderedSet< T >.IndexOf ( item)

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.

Parameters
itemThe item to get the index of.
Returns
The index of the item in the sorted set, or -1 if the item is not present in the set.
OrderedSet<T> Wintellect.PowerCollections.OrderedSet< T >.Intersection ( OrderedSet< T >  otherSet)

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.

Parameters
otherSetSet to intersection with.
Returns
The intersection of the two sets.
Exceptions
InvalidOperationExceptionThis set and otherSet don't use the same method for comparing items.
void Wintellect.PowerCollections.OrderedSet< T >.IntersectionWith ( OrderedSet< T >  otherSet)

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.

Parameters
otherSetSet to intersection with.
Exceptions
InvalidOperationExceptionThis set and otherSet don't use the same method for comparing items.
bool Wintellect.PowerCollections.OrderedSet< T >.IsDisjointFrom ( OrderedSet< T >  otherSet)

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.

Parameters
otherSetSet to check disjointness with.
Returns
True if the two sets are disjoint, false otherwise.
Exceptions
InvalidOperationExceptionThis set and otherSet don't use the same method for comparing items.
bool Wintellect.PowerCollections.OrderedSet< T >.IsEqualTo ( OrderedSet< T >  otherSet)

Determines if this set is equal to another set. This set is equal to otherSet if they contain the same items.

IsEqualTo is computed in time O(N), where N is the number of items in this set.

Parameters
otherSetSet to compare to
Returns
True if this set is equal to otherSet , false otherwise.
Exceptions
InvalidOperationExceptionThis set and otherSet don't use the same method for comparing items.
bool Wintellect.PowerCollections.OrderedSet< T >.IsProperSubsetOf ( OrderedSet< T >  otherSet)

Determines if this set is a proper subset of another set. Neither set is modified. This set is a subset of otherSet if every element in this set is also in otherSet . Additionally, this set must have strictly fewer items than otherSet .

IsSubsetOf is computed in time O(N log M), where M is the size of the otherSet , and N is the size of the this set.

Parameters
otherSetSet to compare to.
Returns
True if this is a proper subset of otherSet .
Exceptions
InvalidOperationExceptionThis set and otherSet don't use the same method for comparing items.
bool Wintellect.PowerCollections.OrderedSet< T >.IsProperSupersetOf ( OrderedSet< T >  otherSet)

Determines if this set is a proper superset of another set. Neither set is modified. This set is a proper superset of otherSet if every element in otherSet is also in this set. Additionally, this set must have strictly more items than otherSet .

IsProperSupersetOf is computed in time O(M log N), where M is the number of unique items in otherSet .

Parameters
otherSetOrderedSet to compare to.
Returns
True if this is a proper superset of otherSet .
Exceptions
InvalidOperationExceptionThis set and otherSet don't use the same method for comparing items.
bool Wintellect.PowerCollections.OrderedSet< T >.IsSubsetOf ( OrderedSet< T >  otherSet)

Determines if this set is a subset of another set. Neither set is modified. This set is a subset of otherSet if every element in this set is also in otherSet .

IsSubsetOf is computed in time O(N log M), where M is the size of the otherSet , and N is the size of the this set.

Parameters
otherSetSet to compare to.
Returns
True if this is a subset of otherSet .
Exceptions
InvalidOperationExceptionThis set and otherSet don't use the same method for comparing items.
bool Wintellect.PowerCollections.OrderedSet< T >.IsSupersetOf ( OrderedSet< T >  otherSet)

Determines if this set is a superset of another set. Neither set is modified. This set is a superset of otherSet if every element in otherSet is also in this set.

IsSupersetOf is computed in time O(M log N), where M is the size of the otherSet , and N is the size of the this set.

Parameters
otherSetOrderedSet to compare to.
Returns
True if this is a superset of otherSet .
Exceptions
InvalidOperationExceptionThis set and otherSet don't use the same method for comparing items.
View Wintellect.PowerCollections.OrderedSet< T >.Range ( from,
bool  fromInclusive,
to,
bool  toInclusive 
)

Returns a View collection that can be used for enumerating a range of the items in the set.. Only items that are greater than from and less than to 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 fromInclusive and toInclusive parameters.

remarks> p>If from is greater than to , the returned collection is empty.

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

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.

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

/remarks>

Parameters
fromThe lower bound of the range.
fromInclusiveIf 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.
toThe upper bound of the range.
toInclusiveIf 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.
Returns
An OrderedSet.View of items in the given range.
View Wintellect.PowerCollections.OrderedSet< T >.RangeFrom ( from,
bool  fromInclusive 
)

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) from are included. The items are enumerated in sorted order. Items equal to from can be included or excluded depending on the fromInclusive parameter.

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

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.

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

/remarks>

Parameters
fromThe lower bound of the range.
fromInclusiveIf 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.
Returns
An OrderedSet.View of items in the given range.
View Wintellect.PowerCollections.OrderedSet< T >.RangeTo ( to,
bool  toInclusive 
)

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) to are included. The items are enumerated in sorted order. Items equal to to can be included or excluded depending on the toInclusive parameter.

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

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.

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

/remarks>

Parameters
toThe upper bound of the range.
toInclusiveIf 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.
Returns
An OrderedSet.View of items in the given range.
sealed override bool Wintellect.PowerCollections.OrderedSet< T >.Remove ( item)

Searches the set for an item equal to item , 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.

Parameters
itemThe item to remove.
Returns
True if item was found and removed. False if item was not in the set.
T Wintellect.PowerCollections.OrderedSet< T >.RemoveFirst ( )

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.

Returns
The item that was removed, which was the smallest item in the set.
Exceptions
InvalidOperationExceptionThe set is empty.
T Wintellect.PowerCollections.OrderedSet< T >.RemoveLast ( )

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.

Returns
The item that was removed, which was the largest item in the set.
Exceptions
InvalidOperationExceptionThe set is empty.
int Wintellect.PowerCollections.OrderedSet< T >.RemoveMany ( IEnumerable< T >  collection)

Removes all the items in collection 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 collection .

Parameters
collectionA collection of items to remove from the set.
Returns
The number of items removed from the set.
Exceptions
ArgumentNullExceptioncollection is null.
View Wintellect.PowerCollections.OrderedSet< T >.Reversed ( )

Returns a View collection that can be used for enumerating the items in the set in reversed order.

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

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.

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

/remarks>

Returns
An OrderedSet.View of items in reverse order.
OrderedSet<T> Wintellect.PowerCollections.OrderedSet< T >.SymmetricDifference ( OrderedSet< T >  otherSet)

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.

Parameters
otherSetSet to symmetric difference with.
Returns
The symmetric difference of the two sets.
Exceptions
InvalidOperationExceptionThis set and otherSet don't use the same method for comparing items.
void Wintellect.PowerCollections.OrderedSet< T >.SymmetricDifferenceWith ( OrderedSet< T >  otherSet)

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.

Parameters
otherSetSet to symmetric difference with.
Exceptions
InvalidOperationExceptionThis set and otherSet don't use the same method for comparing items.
bool Wintellect.PowerCollections.OrderedSet< T >.TryGetItem ( item,
out T  foundItem 
)

Determines if this set contains an item equal to item , 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 item , 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&lt;string&gt; set = new OrderedSet&lt;string&gt;(StringComparer.CurrentCultureIgnoreCase);
set.Add("HELLO");
string s;
bool b = set.TryGetItem("Hello", out s); // b receives true, s receives "HELLO".
Parameters
itemThe item to search for.
foundItemReturns the item from the set that was equal to item .
Returns
True if the set contains item . False if the set does not contain item .
OrderedSet<T> Wintellect.PowerCollections.OrderedSet< T >.Union ( OrderedSet< T >  otherSet)

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.

Parameters
otherSetSet to union with.
Returns
The union of the two sets.
Exceptions
InvalidOperationExceptionThis set and otherSet don't use the same method for comparing items.
void Wintellect.PowerCollections.OrderedSet< T >.UnionWith ( OrderedSet< T >  otherSet)

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.

Parameters
otherSetSet to union with.
Exceptions
InvalidOperationExceptionThis set and otherSet don't use the same method for comparing items.

Property Documentation

IComparer<T> Wintellect.PowerCollections.OrderedSet< T >.Comparer
get

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.

sealed override int Wintellect.PowerCollections.OrderedSet< T >.Count
get

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.

T Wintellect.PowerCollections.OrderedSet< T >.this[int index]
get

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.

Parameters
indexThe index to get the item by.
Returns
The item at the given index.
Exceptions
ArgumentOutOfRangeExceptionindex is less than zero or greater than or equal to Count.

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