Collection of distinct objects.
Items in a Set are unique within the Set according to the EqualityComparer used.
Set is implemented in terms of a Dictionary<T, Object>, so its performance matches that of Dictionary<T, Object>.
T | Type of the Set's items. |
Public Member Functions |
|
Set () | |
Construct an empty Set using the default
equality comparer and default capacity. |
|
Set (int capacity) | |
Construct an empty Set with a given minimum
capacity, and using the default equality comparer. |
|
Set (ICollection< T > items) | |
Construct a Set from a collection of
items, using the default equality comparer. |
|
Set (IEqualityComparer< T > comparer) | |
Construct an empty Set with a specific equality
comparer, using the default capacity. |
|
Set (int capacity, IEqualityComparer< T > comparer) | |
Construct an empty Set with a given capacity and
a specific equality comparer. |
|
Set (ICollection< T > items, IEqualityComparer< T > comparer) | |
Construct a Set from a collection of
items, using a specific comparer. |
|
Set (Set< T > other) | |
Construct a new Set with the same items and
comparer as an existing Set. |
|
void | Add (T item) |
Adds an item to the Set. |
|
void | AddRange (IEnumerable< T > items) |
Adds all items in a given collection to this
set. |
|
void | Clear () |
Removes all items from this Set. |
|
bool | Contains (T item) |
Determines if this Set contains the given item.
|
|
void | CopyTo (T[] array, int baseIndex) |
Copies all of the items in this Set to the given array,
starting at the specified base index in the array. |
|
bool | Remove (T item) |
Removes an item from this Set. |
|
IEnumerator< T > | GetEnumerator () |
Get an Enumerator for iterating over this
Set's items. |
|
void | Union (IEnumerable< T > items) |
Replaces the current Set with the union of this
Set and the given collection.
|
|
void | Intersection (IEnumerable< T > items) |
Replaces the current Set with the intersection of
this Set and the given
collection. |
|
void | RemoveRange (IEnumerable< T > items) |
Removes all items in the given collection
from this Set. |
|
Properties |
|
IEqualityComparer< T > |
Comparer [get] |
Used to determine the equality of items in
this Set. |
|
int |
Count [get] |
The current number of items in this
Set. |
CSharpUtilities::Set< T >::Set | ( | ) | [inline] |
Construct an empty Set using the default equality comparer and default capacity.
The default equality comparer is EqualityComparer<T>.Default.
Using a constructor to specify a capacity may improve efficiency by avoiding resizing while adding any initial objects.
CSharpUtilities::Set< T >::Set | ( | int | capacity | ) | [inline] |
Construct an empty Set with a given minimum capacity, and using the default equality comparer.
The default equality comparer is EqualityComparer<T>.Default.
Using a constructor to specify a capacity may improve efficiency by avoiding resizing while adding any initial objects.
capacity | The number of elements that can be added before resizing is necessary. |
CSharpUtilities::Set< T >::Set | ( | ICollection< T > | items | ) | [inline] |
Construct a Set from a collection of items, using the default equality comparer.
The default equality comparer is EqualityComparer<T>.Default.
CSharpUtilities::Set< T >::Set | ( | IEqualityComparer< T > | comparer | ) | [inline] |
CSharpUtilities::Set< T >::Set | ( | int | capacity, |
IEqualityComparer< T > | comparer | ||
) | [inline] |
CSharpUtilities::Set< T >::Set | ( | ICollection< T > | items, |
IEqualityComparer< T > | comparer | ||
) | [inline] |
Construct a Set from a collection of items, using a specific comparer.
CSharpUtilities::Set< T >::Set | ( | Set< T > | other | ) | [inline] |
void CSharpUtilities::Set< T >::Add | ( | T | item | ) | [inline] |
void CSharpUtilities::Set< T >::AddRange | ( | IEnumerable< T > | items | ) | [inline] |
Adds all items in a given collection to this set.
Any duplicate items in items
and any items already
in this Set will be
ignored.
items | Collection of items to add. |
void CSharpUtilities::Set< T >::Clear | ( | ) | [inline] |
Removes all items from this Set.
bool CSharpUtilities::Set< T >::Contains | ( | T | item | ) | [inline] |
void CSharpUtilities::Set< T >::CopyTo | ( | T[] | array, |
int | baseIndex | ||
) | [inline] |
Copies all of the items in this Set to the given array, starting at the specified base index in the array.
array | Destination one-dimensional array into which this Set's items will be copied. |
baseIndex | Starting index in the destination array at which to begin copying elements. |
ArgumentException | Throws if array.Length - baseIndex <
this.Count . |
ArgumentOutOfRangeException | Throws if baseIndex < 0 |
ArgumentNullException | Throws if array is null. |
bool CSharpUtilities::Set< T >::Remove | ( | T | item | ) | [inline] |
IEnumerator<T> CSharpUtilities::Set< T >::GetEnumerator | ( | ) | [inline] |
Get an Enumerator for iterating over this Set's items.
void CSharpUtilities::Set< T >::Union | ( | IEnumerable< T > | items | ) | [inline] |
void CSharpUtilities::Set< T >::Intersection | ( | IEnumerable< T > | items | ) | [inline] |
void CSharpUtilities::Set< T >::RemoveRange | ( | IEnumerable< T > | items | ) | [inline] |
IEqualityComparer<T> CSharpUtilities::Set<
T >::Comparer [get] |
Used to determine the equality of items in this Set.
int CSharpUtilities::Set<
T >::Count [get] |
The current number of items in this Set.