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>(ValueListBuilder<T>, ReadOnlySpan<T>)

Add the items to the end of the list.

public static ValueListBuilder<T> AddRange<T>(this ValueListBuilder<T> builder, ReadOnlySpan<T> items)

Parameters

builder ValueListBuilder<T>
items ReadOnlySpan<T>

Returns

ValueListBuilder<T>

Type Parameters

T

Remarks

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

AddRange<TKey, TValue>(ValueDictionaryBuilder<TKey, TValue>, ReadOnlySpan<KeyValuePair<TKey, TValue>>)

Add multiple entries to the dictionary.

public static ValueDictionaryBuilder<TKey, TValue> AddRange<TKey, TValue>(this ValueDictionaryBuilder<TKey, TValue> builder, ReadOnlySpan<KeyValuePair<TKey, TValue>> items) where TKey : notnull

Parameters

builder ValueDictionaryBuilder<TKey, TValue>
items ReadOnlySpan<KeyValuePair<TKey, TValue>>

Returns

ValueDictionaryBuilder<TKey, TValue>

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>(ValueSetBuilder<T>, ReadOnlySpan<T>)

Remove the items from the set.

public static ValueSetBuilder<T> ExceptWith<T>(this ValueSetBuilder<T> builder, ReadOnlySpan<T> items)

Parameters

builder ValueSetBuilder<T>
items ReadOnlySpan<T>

Returns

ValueSetBuilder<T>

Type Parameters

T

Remarks

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

InsertRange<T>(ValueListBuilder<T>, int, ReadOnlySpan<T>)

Insert the items into the list at the specified index.

public static ValueListBuilder<T> InsertRange<T>(this ValueListBuilder<T> builder, int index, ReadOnlySpan<T> items)

Parameters

builder ValueListBuilder<T>
index int
items ReadOnlySpan<T>

Returns

ValueListBuilder<T>

Type Parameters

T

Remarks

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

RemoveRange<TKey, TValue>(ValueDictionaryBuilder<TKey, TValue>, ReadOnlySpan<TKey>)

Remove the provided keys from the dictionary.

public static ValueDictionaryBuilder<TKey, TValue> RemoveRange<TKey, TValue>(this ValueDictionaryBuilder<TKey, TValue> builder, ReadOnlySpan<TKey> keys) where TKey : notnull

Parameters

builder ValueDictionaryBuilder<TKey, TValue>
keys ReadOnlySpan<TKey>

Returns

ValueDictionaryBuilder<TKey, TValue>

Type Parameters

TKey
TValue

Remarks

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

SetItems<TKey, TValue>(ValueDictionaryBuilder<TKey, TValue>, ReadOnlySpan<KeyValuePair<TKey, TValue>>)

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

public static ValueDictionaryBuilder<TKey, TValue> SetItems<TKey, TValue>(this ValueDictionaryBuilder<TKey, TValue> builder, ReadOnlySpan<KeyValuePair<TKey, TValue>> items) where TKey : notnull

Parameters

builder ValueDictionaryBuilder<TKey, TValue>
items ReadOnlySpan<KeyValuePair<TKey, TValue>>

Returns

ValueDictionaryBuilder<TKey, TValue>

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.

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

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

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

Parameters

items IEnumerable<KeyValuePair<TKey, TValue>>

Returns

ValueDictionaryBuilder<TKey, TValue>

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.

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

Copy the items into a new ValueDictionaryBuilder<TKey, TValue> with a minimum capacity of minimumCapacity.

public static ValueDictionaryBuilder<TKey, TValue> ToValueDictionaryBuilder<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> items, int minimumCapacity) where TKey : notnull

Parameters

items IEnumerable<KeyValuePair<TKey, TValue>>
minimumCapacity int

Returns

ValueDictionaryBuilder<TKey, TValue>

Type Parameters

TKey
TValue

Remarks

This is functionally equivalent to:

items.ToValueDictionaryBuilder().EnsureCapacity(minimumCapacity)

but without unnecessary intermediate copies.

Available on .NET Standard 2.1 and .NET Core 2.1 and higher.

Exceptions

ArgumentOutOfRangeException

minimumCapacity is less than 0.

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

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

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

ToValueListBuilder<T>(IEnumerable<T>)

Copy the items into a new ValueListBuilder<T>.

public static ValueListBuilder<T> ToValueListBuilder<T>(this IEnumerable<T> items)

Parameters

items IEnumerable<T>

Returns

ValueListBuilder<T>

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.

ToValueListBuilder<T>(IEnumerable<T>, int)

Copy the items into a new ValueListBuilder<T> with a minimum capacity of minimumCapacity.

public static ValueListBuilder<T> ToValueListBuilder<T>(this IEnumerable<T> items, int minimumCapacity)

Parameters

items IEnumerable<T>
minimumCapacity int

Returns

ValueListBuilder<T>

Type Parameters

T

Remarks

This is functionally equivalent to:

items.ToValueListBuilder().EnsureCapacity(minimumCapacity)

but without unnecessary intermediate copies.

Exceptions

ArgumentOutOfRangeException

minimumCapacity is less than 0.

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

ToValueSetBuilder<T>(IEnumerable<T>)

Copy the items into a new ValueSetBuilder<T>.

public static ValueSetBuilder<T> ToValueSetBuilder<T>(this IEnumerable<T> items)

Parameters

items IEnumerable<T>

Returns

ValueSetBuilder<T>

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.

ToValueSetBuilder<T>(IEnumerable<T>, int)

Copy the items into a new ValueSetBuilder<T> with a minimum capacity of minimumCapacity.

public static ValueSetBuilder<T> ToValueSetBuilder<T>(this IEnumerable<T> items, int minimumCapacity)

Parameters

items IEnumerable<T>
minimumCapacity int

Returns

ValueSetBuilder<T>

Type Parameters

T

Remarks

This is functionally equivalent to:

items.ToValueSetBuilder().EnsureCapacity(minimumCapacity)

but without unnecessary intermediate copies.

Available on .NET Standard 2.1 and .NET Core 2.1 and higher.

Exceptions

ArgumentOutOfRangeException

minimumCapacity is less than 0.

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>(ValueSetBuilder<T>, ReadOnlySpan<T>)

Add the items to the set.

public static ValueSetBuilder<T> UnionWith<T>(this ValueSetBuilder<T> builder, ReadOnlySpan<T> items)

Parameters

builder ValueSetBuilder<T>
items ReadOnlySpan<T>

Returns

ValueSetBuilder<T>

Type Parameters

T

Remarks

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