Skip to content

)}

QuaternaryList.AddIndex(string, Func) method

Defined in

Type: QuaternaryList Namespace: ReactiveList.Reactive.Collections Assembly: ReactiveList.Reactive.dll

Applies to

net11.0, net10.0, net47, net471, net472, net48, net481

public void AddIndex<TIndexKey>(string indexName, Func<T, TIndexKey> keySelector) where TIndexKey : notnull

View source (opens in a new tab)

Summary: Adds a secondary index to enable efficient lookups based on a specified key selector.

Type parameters

NameDescription
TIndexKeyThe type of the key used for indexing.

Parameters

NameTypeDescription
indexNamestring (opens in a new tab)The unique name of the index to add.
keySelectorFunc (opens in a new tab)A function that extracts the key from each item for indexing.

Remarks

The index is built and registered while every shard is write-locked, so no item is missed. An existing index with the same name is replaced. If keySelector throws while the index is built, the index is not registered. If it throws later, during a mutation, the mutation is still committed and announced, the index does not hold that item, and the exception propagates to the caller after the change is complete.

Exceptions

TypeCondition
System.ArgumentNullException (opens in a new tab)indexName or keySelector is null.