Table of Contents

Method Apply

Namespace
Gamelogic.Extensions.Algorithms
Assembly
Gamelogic.Extensions.dll

Apply<T>(IList<T>, Func<T, T>)

Applies a transformation function to each element in the list, replacing the element with the function's result.

[Version(4, 5, 0)]
public static void Apply<T>(this IList<T> list, Func<T, T> func)

Parameters

list IList<T>

The list whose elements will be transformed.

func Func<T, T>

A function that takes the current element and returns the new value to store at that position.

Type Parameters

T

The type of elements in the list.

Remarks

This method modifies the list in place. The number of elements must remain the same; if func modifies the list's structure (for example by adding or removing elements), the behavior is undefined.

Any IList<T> implementation that does not support assignment (such as read-only lists) will throw an exception.

Exceptions

ArgumentNullException

Thrown if list or func is null.