Table of Contents

Class InterlinkedDictionary<T>

Namespace
Garyon.DataStructures
Assembly
Garyon.dll

Represents a collection of interlinked pairs of values of the same type, where the first and second components are mapped to each other.

public sealed class InterlinkedDictionary<T> where T : notnull

Type Parameters

T

The type of both components of the pairs.

Inheritance
InterlinkedDictionary<T>
Inherited Members
Extension Methods

Constructors

InterlinkedDictionary()

Initializes a new empty InterlinkedDictionary<T>.

public InterlinkedDictionary()

InterlinkedDictionary(InterlinkedDictionary<T>)

Initializes a new InterlinkedDictionary<T> out of another, copying the pairs to this new instance.

public InterlinkedDictionary(InterlinkedDictionary<T> other)

Parameters

other InterlinkedDictionary<T>

The other InterlinkedDictionary<T> from which to copy the pairs. That instance remains unaffected upon performing operations on this new one.

Properties

Count

Gets the count of pairs that are present in the dictionary.

public int Count { get; }

Property Value

int

ValuePairs

Gets all the currently stored pairs of values.

public IEnumerable<(T, T)> ValuePairs { get; }

Property Value

IEnumerable<(T, T)>

Values1

Gets all the currently stored values of the first component.

public IEnumerable<T> Values1 { get; }

Property Value

IEnumerable<T>

Values2

Gets all the currently stored values of the second component.

public IEnumerable<T> Values2 { get; }

Property Value

IEnumerable<T>

Methods

Add(T, T)

Adds a pair of values to the dictionary.

public void Add(T t1Value, T t2Value)

Parameters

t1Value T
t2Value T

Exceptions

ArgumentException

Thrown if one of the values already exists in the dictionary.

ArgumentNullException

Thrown if any of the values is null.

Clear()

Clears the dictionary, removing all stored pairs.

public void Clear()

Contains1(T)

Determines whether a value exists as the first component of a stored pair.

public bool Contains1(T value)

Parameters

value T

Returns

bool

Contains2(T)

Determines whether a value exists as the second component of a stored pair.

public bool Contains2(T value)

Parameters

value T

Returns

bool

GetValue1(T)

Gets the paired second component for a stored first component.

public T GetValue1(T t1Key)

Parameters

t1Key T

Returns

T

GetValue2(T)

Gets the paired first component for a stored second component.

public T GetValue2(T t2Key)

Parameters

t2Key T

Returns

T

Remove1(T)

Removes a stored pair by its first component, if it exists.

public bool Remove1(T t1Value)

Parameters

t1Value T

Returns

bool

Remove2(T)

Removes a stored pair by its second component, if it exists.

public bool Remove2(T t2Value)

Parameters

t2Value T

Returns

bool

SetValue1(T, T)

Changes the paired second component for a stored first component.

public void SetValue1(T t1Key, T t2Value)

Parameters

t1Key T
t2Value T

SetValue2(T, T)

Changes the paired first component for a stored second component.

public void SetValue2(T t2Key, T t1Value)

Parameters

t2Key T
t1Value T

TryGetValue1(T, out T?)

Attempts to get the paired second component for a stored first component.

public bool TryGetValue1(T t1Key, out T? t2Value)

Parameters

t1Key T
t2Value T

Returns

bool

TryGetValue2(T, out T?)

Attempts to get the paired first component for a stored second component.

public bool TryGetValue2(T t2Key, out T? t1Value)

Parameters

t2Key T
t1Value T

Returns

bool

ValueOrDefault1(T)

Gets the paired second component for a stored first component, or default if it is not present.

public T? ValueOrDefault1(T key)

Parameters

key T

Returns

T

ValueOrDefault2(T)

Gets the paired first component for a stored second component, or default if it is not present.

public T? ValueOrDefault2(T key)

Parameters

key T

Returns

T