Skip to content

IListEx ​

Provides extension methods for System.Collections.Generic.IList<1 to perform common operations such as compaction, shuffling, hashing, union, and formatting utilities.

Kind: Static class

Namespace: CrowdControl.Common

Public Static Functions

void

CompactNotNullElements<TValue>(IList arr)

Compacts the list by replacing null elements with the next non-null element to the right. This operation iterates once and sets each null element to the value of its immediate successor.

void

Add<K>(IList> list, K value, Delegate action)

Adds a tuple of (, System.Action) to the list using a provided delegate.

void

Shuffle<TValue>(IList list)

Randomly shuffles the elements of the list in-place using the Fisher–Yates algorithm.

TValue

TakeRandom<TValue>(IList list)

Returns a random element from the list.

int

SequenceHash<TValue>(IList sequence)

Computes a hash code for the sequence by aggregating the hash codes of its elements.

TValue[]

WithoutNullElements<TValue>(IList arr)

Creates a new array containing only the non-null elements from the source list.

string

ToHexString(IList bytes)

Converts a list of bytes into its uppercase hexadecimal string representation without separators.

void

Reverse(IList bytes)

Reverses the order of bytes in the list in-place.

void

UnionWith<TValue>(IList list, IEnumerable other)

Adds elements from other to list that are not already present, functioning as a union operation while preserving the original list.