Table of Contents

Class SequentialHashSet<T>

Namespace
LfrlAnvil.Collections
Assembly
LfrlAnvil.Collections.dll

Represents a generic set of elements whose insertion order is preserved.

public class SequentialHashSet<T> : ISet<T>, ICollection<T>, IReadOnlySet<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable where T : notnull

Type Parameters

T

Element type.

Inheritance
SequentialHashSet<T>
Implements
ISet<T>
Inherited Members
Extension Methods

Constructors

SequentialHashSet()

Creates a new empty SequentialHashSet<T> instance with Default comparer.

public SequentialHashSet()

SequentialHashSet(IEqualityComparer<T>)

Creates a new empty SequentialHashSet<T> instance.

public SequentialHashSet(IEqualityComparer<T> comparer)

Parameters

comparer IEqualityComparer<T>

Element comparer.

Properties

Comparer

Element comparer.

public IEqualityComparer<T> Comparer { get; }

Property Value

IEqualityComparer<T>

Count

Gets the number of elements contained in the ICollection<T>.

public int Count { get; }

Property Value

int

The number of elements contained in the ICollection<T>.

Methods

Add(T)

Adds an element to the current set and returns a value to indicate if the element was successfully added.

public bool Add(T item)

Parameters

item T

The element to add to the set.

Returns

bool

true if the element is added to the set; false if the element is already in the set.

Clear()

Removes all items from the ICollection<T>.

public void Clear()

Exceptions

NotSupportedException

The ICollection<T> is read-only.

Contains(T)

Determines whether the ICollection<T> contains a specific value.

[Pure]
public bool Contains(T item)

Parameters

item T

The object to locate in the ICollection<T>.

Returns

bool

true if item is found in the ICollection<T>; otherwise, false.

ExceptWith(IEnumerable<T>)

Removes all elements in the specified collection from the current set.

public void ExceptWith(IEnumerable<T> other)

Parameters

other IEnumerable<T>

The collection of items to remove from the set.

Exceptions

ArgumentNullException

other is null.

GetEnumerator()

Creates a new LinkedListSlimNodeEnumerator<T> instance for this hash set.

[Pure]
public LinkedListSlimNodeEnumerator<T> GetEnumerator()

Returns

LinkedListSlimNodeEnumerator<T>

New LinkedListSlimNodeEnumerator<T> instance.

IntersectWith(IEnumerable<T>)

Modifies the current set so that it contains only elements that are also in a specified collection.

public void IntersectWith(IEnumerable<T> other)

Parameters

other IEnumerable<T>

The collection to compare to the current set.

Exceptions

ArgumentNullException

other is null.

IsProperSubsetOf(IEnumerable<T>)

Determines whether the current set is a proper (strict) subset of a specified collection.

[Pure]
public bool IsProperSubsetOf(IEnumerable<T> other)

Parameters

other IEnumerable<T>

The collection to compare to the current set.

Returns

bool

true if the current set is a proper subset of other; otherwise, false.

Exceptions

ArgumentNullException

other is null.

IsProperSupersetOf(IEnumerable<T>)

Determines whether the current set is a proper (strict) superset of a specified collection.

[Pure]
public bool IsProperSupersetOf(IEnumerable<T> other)

Parameters

other IEnumerable<T>

The collection to compare to the current set.

Returns

bool

true if the current set is a proper superset of other; otherwise, false.

Exceptions

ArgumentNullException

other is null.

IsSubsetOf(IEnumerable<T>)

Determines whether a set is a subset of a specified collection.

[Pure]
public bool IsSubsetOf(IEnumerable<T> other)

Parameters

other IEnumerable<T>

The collection to compare to the current set.

Returns

bool

true if the current set is a subset of other; otherwise, false.

Exceptions

ArgumentNullException

other is null.

IsSupersetOf(IEnumerable<T>)

Determines whether the current set is a superset of a specified collection.

[Pure]
public bool IsSupersetOf(IEnumerable<T> other)

Parameters

other IEnumerable<T>

The collection to compare to the current set.

Returns

bool

true if the current set is a superset of other; otherwise, false.

Exceptions

ArgumentNullException

other is null.

Overlaps(IEnumerable<T>)

Determines whether the current set overlaps with the specified collection.

[Pure]
public bool Overlaps(IEnumerable<T> other)

Parameters

other IEnumerable<T>

The collection to compare to the current set.

Returns

bool

true if the current set and other share at least one common element; otherwise, false.

Exceptions

ArgumentNullException

other is null.

Remove(T)

Removes the first occurrence of a specific object from the ICollection<T>.

public bool Remove(T item)

Parameters

item T

The object to remove from the ICollection<T>.

Returns

bool

true if item was successfully removed from the ICollection<T>; otherwise, false. This method also returns false if item is not found in the original ICollection<T>.

Exceptions

NotSupportedException

The ICollection<T> is read-only.

SetEquals(IEnumerable<T>)

Determines whether the current set and the specified collection contain the same elements.

[Pure]
public bool SetEquals(IEnumerable<T> other)

Parameters

other IEnumerable<T>

The collection to compare to the current set.

Returns

bool

true if the current set is equal to other; otherwise, false.

Exceptions

ArgumentNullException

other is null.

SymmetricExceptWith(IEnumerable<T>)

Modifies the current set so that it contains only elements that are present either in the current set or in the specified collection, but not both.

public void SymmetricExceptWith(IEnumerable<T> other)

Parameters

other IEnumerable<T>

The collection to compare to the current set.

Exceptions

ArgumentNullException

other is null.

UnionWith(IEnumerable<T>)

Modifies the current set so that it contains all elements that are present in the current set, in the specified collection, or in both.

public void UnionWith(IEnumerable<T> other)

Parameters

other IEnumerable<T>

The collection to compare to the current set.

Exceptions

ArgumentNullException

other is null.