Table of Contents

Class ValueCollectionExtensions

Namespace
Badeend.ValueCollections
Assembly
Badeend.ValueCollections.dll

Extension methods related to ValueCollections.

public static class ValueCollectionExtensions
Inheritance
ValueCollectionExtensions
Inherited Members

Methods

AddRange<T>(Builder, IEnumerable<T>)

Add the items to the end of the list.

public static ValueList<T>.Builder AddRange<T>(this ValueList<T>.Builder builder, IEnumerable<T> items)

Parameters

builder ValueList<T>.Builder
items IEnumerable<T>

Returns

ValueList<T>.Builder

Type Parameters

T

Remarks

This overload is an extension method to avoid call site ambiguity.

Exceptions

InvalidOperationException

Can't add builder into itself.

AddRange<TKey, TValue>(Builder, IEnumerable<KeyValuePair<TKey, TValue>>)

Add multiple entries to the dictionary.

public static ValueDictionary<TKey, TValue>.Builder AddRange<TKey, TValue>(this ValueDictionary<TKey, TValue>.Builder builder, IEnumerable<KeyValuePair<TKey, TValue>> items) where TKey : notnull

Parameters

builder ValueDictionary<TKey, TValue>.Builder
items IEnumerable<KeyValuePair<TKey, TValue>>

Returns

ValueDictionary<TKey, TValue>.Builder

Type Parameters

TKey
TValue

Remarks

This overload is an extension method to avoid call site ambiguity.

Exceptions

ArgumentException

items contains a duplicate key or a key that already exists in the dictionary.

ExceptWith<T>(Builder, IEnumerable<T>)

Remove all elements that appear in the other collection.

public static ValueSet<T>.Builder ExceptWith<T>(this ValueSet<T>.Builder builder, IEnumerable<T> other)

Parameters

builder ValueSet<T>.Builder
other IEnumerable<T>

Returns

ValueSet<T>.Builder

Type Parameters

T

InsertRange<T>(Builder, int, IEnumerable<T>)

Insert the items into the list at the specified index.

public static ValueList<T>.Builder InsertRange<T>(this ValueList<T>.Builder builder, int index, IEnumerable<T> items)

Parameters

builder ValueList<T>.Builder
index int
items IEnumerable<T>

Returns

ValueList<T>.Builder

Type Parameters

T

Remarks

This overload is an extension method to avoid call site ambiguity.

Exceptions

InvalidOperationException

Can't insert builder into itself.

ArgumentOutOfRangeException

Invalid index.

IntersectWith<T>(Builder, IEnumerable<T>)

Modify the current builder to contain only elements that are present in both thisand the other collection.

public static ValueSet<T>.Builder IntersectWith<T>(this ValueSet<T>.Builder builder, IEnumerable<T> other)

Parameters

builder ValueSet<T>.Builder
other IEnumerable<T>

Returns

ValueSet<T>.Builder

Type Parameters

T

Remarks

Warning

In the worst case scenario this ends up allocating a temporary copy of the other collection.

IsProperSubsetOf<T>(ValueSet<T>, IEnumerable<T>)

Check whether this set is a proper subset of the provided collection.

public static bool IsProperSubsetOf<T>(this ValueSet<T> set, IEnumerable<T> other)

Parameters

set ValueSet<T>
other IEnumerable<T>

Returns

bool

Type Parameters

T

Remarks

Warning

In the worst case scenario this ends up allocating a temporary copy of the other collection.

IsProperSubsetOf<T>(Builder, IEnumerable<T>)

Check whether this set is a proper subset of the provided collection.

public static bool IsProperSubsetOf<T>(this ValueSet<T>.Builder builder, IEnumerable<T> other)

Parameters

builder ValueSet<T>.Builder
other IEnumerable<T>

Returns

bool

Type Parameters

T

Remarks

Warning

In the worst case scenario this ends up allocating a temporary copy of the other collection.

IsProperSupersetOf<T>(ValueSet<T>, IEnumerable<T>)

Check whether this set is a proper superset of the provided collection.

public static bool IsProperSupersetOf<T>(this ValueSet<T> set, IEnumerable<T> other)

Parameters

set ValueSet<T>
other IEnumerable<T>

Returns

bool

Type Parameters

T

Remarks

Warning

In the worst case scenario this ends up allocating a temporary copy of the other collection.

IsProperSupersetOf<T>(Builder, IEnumerable<T>)

Check whether this set is a proper superset of the provided collection.

public static bool IsProperSupersetOf<T>(this ValueSet<T>.Builder builder, IEnumerable<T> other)

Parameters

builder ValueSet<T>.Builder
other IEnumerable<T>

Returns

bool

Type Parameters

T

Remarks

Warning

In the worst case scenario this ends up allocating a temporary copy of the other collection.

IsSubsetOf<T>(ValueSet<T>, IEnumerable<T>)

Check whether this set is a subset of the provided collection.

public static bool IsSubsetOf<T>(this ValueSet<T> set, IEnumerable<T> other)

Parameters

set ValueSet<T>
other IEnumerable<T>

Returns

bool

Type Parameters

T

Remarks

Warning

In the worst case scenario this ends up allocating a temporary copy of the other collection.

IsSubsetOf<T>(Builder, IEnumerable<T>)

Check whether this set is a subset of the provided collection.

public static bool IsSubsetOf<T>(this ValueSet<T>.Builder builder, IEnumerable<T> other)

Parameters

builder ValueSet<T>.Builder
other IEnumerable<T>

Returns

bool

Type Parameters

T

Remarks

Warning

In the worst case scenario this ends up allocating a temporary copy of the other collection.

IsSupersetOf<T>(ValueSet<T>, IEnumerable<T>)

Check whether this set is a superset of the provided collection.

public static bool IsSupersetOf<T>(this ValueSet<T> set, IEnumerable<T> other)

Parameters

set ValueSet<T>
other IEnumerable<T>

Returns

bool

Type Parameters

T

IsSupersetOf<T>(Builder, IEnumerable<T>)

Check whether this set is a superset of the provided collection.

public static bool IsSupersetOf<T>(this ValueSet<T>.Builder builder, IEnumerable<T> other)

Parameters

builder ValueSet<T>.Builder
other IEnumerable<T>

Returns

bool

Type Parameters

T

Overlaps<T>(ValueSet<T>, IEnumerable<T>)

Check whether this set and the provided collection share any common elements.

public static bool Overlaps<T>(this ValueSet<T> set, IEnumerable<T> other)

Parameters

set ValueSet<T>
other IEnumerable<T>

Returns

bool

Type Parameters

T

Overlaps<T>(Builder, IEnumerable<T>)

Check whether this set and the provided collection share any common elements.

public static bool Overlaps<T>(this ValueSet<T>.Builder builder, IEnumerable<T> other)

Parameters

builder ValueSet<T>.Builder
other IEnumerable<T>

Returns

bool

Type Parameters

T

RemoveRange<TKey, TValue>(Builder, IEnumerable<TKey>)

Remove the provided keys from the dictionary.

public static ValueDictionary<TKey, TValue>.Builder RemoveRange<TKey, TValue>(this ValueDictionary<TKey, TValue>.Builder builder, IEnumerable<TKey> keys) where TKey : notnull

Parameters

builder ValueDictionary<TKey, TValue>.Builder
keys IEnumerable<TKey>

Returns

ValueDictionary<TKey, TValue>.Builder

Type Parameters

TKey
TValue

Remarks

This overload is an extension method to avoid call site ambiguity.

SetEquals<T>(ValueSet<T>, IEnumerable<T>)

Check whether this set and the provided collection contain the same elements, ignoring duplicates and the order of the elements.

public static bool SetEquals<T>(this ValueSet<T> set, IEnumerable<T> other)

Parameters

set ValueSet<T>
other IEnumerable<T>

Returns

bool

Type Parameters

T

Remarks

Warning

In the worst case scenario this ends up allocating a temporary copy of the other collection.

SetEquals<T>(Builder, IEnumerable<T>)

Check whether this set and the provided collection contain the same elements, ignoring duplicates and the order of the elements.

public static bool SetEquals<T>(this ValueSet<T>.Builder builder, IEnumerable<T> other)

Parameters

builder ValueSet<T>.Builder
other IEnumerable<T>

Returns

bool

Type Parameters

T

Remarks

Warning

In the worst case scenario this ends up allocating a temporary copy of the other collection.

SetItems<TKey, TValue>(Builder, IEnumerable<KeyValuePair<TKey, TValue>>)

Sets the specified key/value pairs in the dictionary, possibly overwriting existing values for the keys.

public static ValueDictionary<TKey, TValue>.Builder SetItems<TKey, TValue>(this ValueDictionary<TKey, TValue>.Builder builder, IEnumerable<KeyValuePair<TKey, TValue>> items) where TKey : notnull

Parameters

builder ValueDictionary<TKey, TValue>.Builder
items IEnumerable<KeyValuePair<TKey, TValue>>

Returns

ValueDictionary<TKey, TValue>.Builder

Type Parameters

TKey
TValue

Remarks

When the same key appears multiple times in the items, the last value overwrites any earlier values.

This overload is an extension method to avoid call site ambiguity.

SymmetricExceptWith<T>(Builder, IEnumerable<T>)

Remove all elements that appear in both thisand the other collection.

public static ValueSet<T>.Builder SymmetricExceptWith<T>(this ValueSet<T>.Builder builder, IEnumerable<T> other)

Parameters

builder ValueSet<T>.Builder
other IEnumerable<T>

Returns

ValueSet<T>.Builder

Type Parameters

T

Remarks

Warning

In the worst case scenario this ends up allocating a temporary copy of the other collection.

ToValueDictionaryAsync<TKey, TValue>(IAsyncEnumerable<TValue>, Func<TValue, TKey>, CancellationToken)

Asynchronously creates a ValueDictionary<TKey, TValue> from an IEnumerable<T> according to specified key selector function.

public static Task<ValueDictionary<TKey, TValue>> ToValueDictionaryAsync<TKey, TValue>(this IAsyncEnumerable<TValue> items, Func<TValue, TKey> keySelector, CancellationToken cancellationToken = default) where TKey : notnull

Parameters

items IAsyncEnumerable<TValue>

Elements that will becomes the values of the dictionary.

keySelector Func<TValue, TKey>

A function to extract a key from each element.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

Task<ValueDictionary<TKey, TValue>>

Type Parameters

TKey
TValue

Exceptions

ArgumentException

The keySelector produced a duplicate key.

ToValueDictionaryAsync<TSource, TKey, TValue>(IAsyncEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TValue>, CancellationToken)

Asynchronously creates a ValueDictionary<TKey, TValue> from an IEnumerable<T> according to specified key selector and element selector functions.

public static Task<ValueDictionary<TKey, TValue>> ToValueDictionaryAsync<TSource, TKey, TValue>(this IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TValue> valueSelector, CancellationToken cancellationToken = default) where TKey : notnull

Parameters

source IAsyncEnumerable<TSource>

Elements to feed into the selector functions.

keySelector Func<TSource, TKey>

A function to extract a key from each element.

valueSelector Func<TSource, TValue>

A transform function to produce a result element value from each element.

cancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

Task<ValueDictionary<TKey, TValue>>

Type Parameters

TSource
TKey
TValue

Exceptions

ArgumentException

The keySelector produced a duplicate key.

ToValueDictionaryBuilder<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>>)

Copy the items into a new ValueDictionary<TKey, TValue>.Builder.

public static ValueDictionary<TKey, TValue>.Builder ToValueDictionaryBuilder<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> items) where TKey : notnull

Parameters

items IEnumerable<KeyValuePair<TKey, TValue>>

Returns

ValueDictionary<TKey, TValue>.Builder

Type Parameters

TKey
TValue

Remarks

The capacity of the returned builder may be larger than the size of the input collection. How much larger exactly is undefined.

Exceptions

ArgumentException

items contains duplicate keys.

ToValueDictionary<TKey, TValue>(IAsyncEnumerable<KeyValuePair<TKey, TValue>>, CancellationToken)

Asynchronously copy the items into a new ValueDictionary<TKey, TValue>.

public static Task<ValueDictionary<TKey, TValue>> ToValueDictionary<TKey, TValue>(this IAsyncEnumerable<KeyValuePair<TKey, TValue>> items, CancellationToken cancellationToken = default) where TKey : notnull

Parameters

items IAsyncEnumerable<KeyValuePair<TKey, TValue>>
cancellationToken CancellationToken

Returns

Task<ValueDictionary<TKey, TValue>>

Type Parameters

TKey
TValue

Exceptions

ArgumentException

items contains duplicate keys.

ToValueDictionary<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>>)

Copy the items into a new ValueDictionary<TKey, TValue>.

public static ValueDictionary<TKey, TValue> ToValueDictionary<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> items) where TKey : notnull

Parameters

items IEnumerable<KeyValuePair<TKey, TValue>>

Returns

ValueDictionary<TKey, TValue>

Type Parameters

TKey
TValue

Exceptions

ArgumentException

items contains duplicate keys.

ToValueDictionary<TKey, TValue>(IEnumerable<TValue>, Func<TValue, TKey>)

Creates a ValueDictionary<TKey, TValue> from an IEnumerable<T> according to specified key selector function.

public static ValueDictionary<TKey, TValue> ToValueDictionary<TKey, TValue>(this IEnumerable<TValue> items, Func<TValue, TKey> keySelector) where TKey : notnull

Parameters

items IEnumerable<TValue>

Elements that will becomes the values of the dictionary.

keySelector Func<TValue, TKey>

A function to extract a key from each element.

Returns

ValueDictionary<TKey, TValue>

Type Parameters

TKey
TValue

Exceptions

ArgumentException

The keySelector produced a duplicate key.

ToValueDictionary<TSource, TKey, TValue>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TValue>)

Creates a ValueDictionary<TKey, TValue> from an IEnumerable<T> according to specified key selector and element selector functions.

public static ValueDictionary<TKey, TValue> ToValueDictionary<TSource, TKey, TValue>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector, Func<TSource, TValue> valueSelector) where TKey : notnull

Parameters

source IEnumerable<TSource>

Elements to feed into the selector functions.

keySelector Func<TSource, TKey>

A function to extract a key from each element.

valueSelector Func<TSource, TValue>

A transform function to produce a result element value from each element.

Returns

ValueDictionary<TKey, TValue>

Type Parameters

TSource
TKey
TValue

Exceptions

ArgumentException

The keySelector produced a duplicate key.

ToValueListAsync<T>(IAsyncEnumerable<T>, CancellationToken)

Asynchronously copy the items into a new ValueList<T>.

public static Task<ValueList<T>> ToValueListAsync<T>(this IAsyncEnumerable<T> items, CancellationToken cancellationToken = default)

Parameters

items IAsyncEnumerable<T>
cancellationToken CancellationToken

Returns

Task<ValueList<T>>

Type Parameters

T

ToValueListBuilder<T>(IEnumerable<T>)

Copy the items into a new ValueList<T>.Builder.

public static ValueList<T>.Builder ToValueListBuilder<T>(this IEnumerable<T> items)

Parameters

items IEnumerable<T>

Returns

ValueList<T>.Builder

Type Parameters

T

Remarks

The capacity of the returned builder may be larger than the size of the input collection. How much larger exactly is undefined.

ToValueList<T>(IEnumerable<T>)

Copy the items into a new ValueList<T>.

public static ValueList<T> ToValueList<T>(this IEnumerable<T> items)

Parameters

items IEnumerable<T>

Returns

ValueList<T>

Type Parameters

T

ToValueSetAsync<T>(IAsyncEnumerable<T>, CancellationToken)

Asynchronously copy the items into a new ValueSet<T>.

public static Task<ValueSet<T>> ToValueSetAsync<T>(this IAsyncEnumerable<T> items, CancellationToken cancellationToken = default)

Parameters

items IAsyncEnumerable<T>
cancellationToken CancellationToken

Returns

Task<ValueSet<T>>

Type Parameters

T

ToValueSetBuilder<T>(IEnumerable<T>)

Copy the items into a new ValueSet<T>.Builder.

public static ValueSet<T>.Builder ToValueSetBuilder<T>(this IEnumerable<T> items)

Parameters

items IEnumerable<T>

Returns

ValueSet<T>.Builder

Type Parameters

T

Remarks

The capacity of the returned builder may be larger than the size of the input collection. How much larger exactly is undefined.

ToValueSet<T>(IEnumerable<T>)

Copy the items into a new ValueSet<T>.

public static ValueSet<T> ToValueSet<T>(this IEnumerable<T> items)

Parameters

items IEnumerable<T>

Returns

ValueSet<T>

Type Parameters

T

UnionWith<T>(Builder, IEnumerable<T>)

Add all elements from the other collection.

public static ValueSet<T>.Builder UnionWith<T>(this ValueSet<T>.Builder builder, IEnumerable<T> other)

Parameters

builder ValueSet<T>.Builder
other IEnumerable<T>

Returns

ValueSet<T>.Builder

Type Parameters

T