LinkedHashSet<T> Class

Hash table and linked list implementation of the ISet<T> interface, with predictable iteration order.

C#
public sealed class LinkedHashSet<T> : ISet<T>
where T : notnull

Type Parameters

T
notnull

The type of elements maintained by this set.

Inheritance
LinkedHashSet<T>
Implements

Remarks

This implementation differs from HashSet<T> in that it maintains a doubly-linked list running through all of its entries. This linked list defines the iteration ordering, which is the order in which elements were inserted into the set (insertion-order). Note that insertion order is not affected if an element is re-inserted into the set. (An element e is reinserted into a set s if s.Add(e) is invoked when s.Contains(e) would return true immediately prior to the invocation.)

Constructors

LinkedHashSet()

Initializes a new instance of the LinkedHashSet<T> class.

LinkedHashSet(int)

Initializes a new instance of the LinkedHashSet<T> class.

Properties

Methods

Explicit Interface Implementations

Constructors Detail

LinkedHashSet()

Initializes a new instance of the LinkedHashSet<T> class.

C#
public LinkedHashSet()

LinkedHashSet(int)

Initializes a new instance of the LinkedHashSet<T> class.

C#
public LinkedHashSet(int initialCapacity)

Parameters

initialCapacity
int

The initial capacity.

Properties Detail

Count

C#
public int Count { get; }

Property Value

int

Implements

IsReadOnly

C#
public bool IsReadOnly { get; }

Property Value

Implements

Methods Detail

Add(T)

C#
public bool Add(T item)

Parameters

item
T

Returns

Implements

Clear()

C#
public void Clear()

Implements

Contains(T)

C#
public bool Contains(T item)

Parameters

item
T

Returns

Implements

CopyTo(T[], int)

C#
public void CopyTo(T[] array, int arrayIndex)

Parameters

array
T[]
arrayIndex
int

Implements

ExceptWith(IEnumerable<T>)

C#
public void ExceptWith(IEnumerable<T> other)

Parameters

Implements

GetEnumerator()

C#
public IEnumerator<T> GetEnumerator()

Returns

Implements

IntersectWith(IEnumerable<T>)

C#
public void IntersectWith(IEnumerable<T> other)

Parameters

Implements

IsProperSubsetOf(IEnumerable<T>)

C#
public bool IsProperSubsetOf(IEnumerable<T> other)

Parameters

Returns

Implements

IsProperSupersetOf(IEnumerable<T>)

C#
public bool IsProperSupersetOf(IEnumerable<T> other)

Parameters

Returns

Implements

IsSubsetOf(IEnumerable<T>)

C#
public bool IsSubsetOf(IEnumerable<T> other)

Parameters

Returns

Implements

IsSupersetOf(IEnumerable<T>)

C#
public bool IsSupersetOf(IEnumerable<T> other)

Parameters

Returns

Implements

Overlaps(IEnumerable<T>)

C#
public bool Overlaps(IEnumerable<T> other)

Parameters

Returns

Implements

Remove(T)

C#
public bool Remove(T item)

Parameters

item
T

Returns

Implements

SetEquals(IEnumerable<T>)

C#
public bool SetEquals(IEnumerable<T> other)

Parameters

Returns

Implements

SymmetricExceptWith(IEnumerable<T>)

C#
public void SymmetricExceptWith(IEnumerable<T> other)

Parameters

Implements

UnionWith(IEnumerable<T>)

C#
public void UnionWith(IEnumerable<T> other)

Parameters

Implements

Explicit Interface Implementations Detail

ICollection<T>.Add(T)

C#
private void ICollection<T>.Add(T item)

Parameters

item
T

Implements

IEnumerable.GetEnumerator()

C#
private IEnumerator IEnumerable.GetEnumerator()

Returns

Implements