Table of Contents

Interface ITwoWayDictionary<T1, T2>

Namespace
LfrlAnvil.Collections
Assembly
LfrlAnvil.Collections.dll

Represents a generic collection of two-way (forward, reverse) pairs.

public interface ITwoWayDictionary<T1, T2> : IReadOnlyTwoWayDictionary<T1, T2>, IReadOnlyCollection<Pair<T1, T2>>, ICollection<Pair<T1, T2>>, IEnumerable<Pair<T1, T2>>, IEnumerable where T1 : notnull where T2 : notnull

Type Parameters

T1

First value type.

T2

Second value type.

Inherited Members
Extension Methods

Properties

Count

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

int Count { get; }

Property Value

int

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

Methods

Add(T1, T2)

Adds the provided pair.

void Add(T1 first, T2 second)

Parameters

first T1

First value.

second T2

Second value.

Exceptions

ArgumentException

When either element already exists as key in its respective dictionary.

RemoveForward(T1)

Attempts to remove a pair by its first value.

bool RemoveForward(T1 value)

Parameters

value T1

Entry's key.

Returns

bool

true when pair was removed, otherwise false.

RemoveForward(T1, out T2)

Attempts to remove a pair by its first value.

bool RemoveForward(T1 value, out T2 second)

Parameters

value T1

Entry's key.

second T2

out parameter that returns second value associated with the removed pair.

Returns

bool

true when pair was removed, otherwise false.

RemoveReverse(T2)

Attempts to remove a pair by its second value.

bool RemoveReverse(T2 value)

Parameters

value T2

Entry's key.

Returns

bool

true when pair was removed, otherwise false.

RemoveReverse(T2, out T1)

Attempts to remove a pair by its second value.

bool RemoveReverse(T2 value, out T1 first)

Parameters

value T2

Entry's key.

first T1

out parameter that returns first value associated with the removed pair.

Returns

bool

true when pair was removed, otherwise false.

TryAdd(T1, T2)

Attempts to add the provided pair.

bool TryAdd(T1 first, T2 second)

Parameters

first T1

First value.

second T2

Second value.

Returns

bool

true when pair was added, otherwise false.

TryUpdateForward(T1, T2)

Attempts to update the value associated with the specified first key.

bool TryUpdateForward(T1 first, T2 second)

Parameters

first T1

Entry's key.

second T2

Second value to set.

Returns

bool

true when pair was updated, otherwise false.

TryUpdateReverse(T2, T1)

Attempts to update the value associated with the specified second key.

bool TryUpdateReverse(T2 second, T1 first)

Parameters

second T2

Entry's key.

first T1

First value to set.

Returns

bool

true when pair was updated, otherwise false.

UpdateForward(T1, T2)

Updates the value associated with the specified first key.

void UpdateForward(T1 first, T2 second)

Parameters

first T1

Entry's key.

second T2

Second value to set.

Exceptions

ArgumentException

When the provided second already exists as a key.

UpdateReverse(T2, T1)

Updates the value associated with the specified second key.

void UpdateReverse(T2 second, T1 first)

Parameters

second T2

Entry's key.

first T1

First value to set.

Exceptions

ArgumentException

When the provided first already exists as a key.