Table of Contents

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>
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 int

The 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

int

Methods

Add(T)

Adds an item to the set.

public void Add(T item)

Parameters

item T

The item to add.

Contains(T)

Checks if the set contains an item.

public bool Contains(T item)

Parameters

item T

The item to check for.

Returns

bool

true if the set contains the item, false otherwise.

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 T

The item to remove.

Returns

bool

true if the item was removed, false otherwise.