Class SetWithArray<T>
- Namespace
- AlgorithmsSW.Set
- Assembly
- AlgorithmsSW.dll
Represents a set of unique items implemented with an array.
public class SetWithArray<T> : ISet<T>, IEnumerable<T>, IEnumerable
Type Parameters
T
The type of the items in the set.
- Inheritance
-
SetWithArray<T>
- Implements
-
ISet<T>IEnumerable<T>
- Inherited Members
- Extension Methods
Constructors
SetWithArray(int, IComparer<T>)
Initializes a new instance of the SetWithArray<T> class.
public SetWithArray(int initialCapacity, IComparer<T> comparer)
Parameters
initialCapacity
intThe initial capacity of the set.
comparer
IComparer<T>The comparer used to compare items.
Properties
Comparer
Gets the comparer used to compare items.
public IComparer<T> Comparer { get; }
Property Value
- IComparer<T>
Count
Gets the number of items in the set.
public int Count { get; }
Property Value
Methods
Add(T)
Adds an item to the set.
public void Add(T item)
Parameters
item
TThe item to add.
Contains(T)
Checks if the set contains an item.
public bool Contains(T item)
Parameters
item
TThe item to check for.
Returns
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
An enumerator that can be used to iterate through the collection.
Remove(T)
Removes an item from the set.
public bool Remove(T item)
Parameters
item
TThe item to remove.