Table of Contents

Class CollectionExtensions

Namespace
Stride.Core.Extensions
Assembly
Stride.Core.dll

An extension class for various types of collection.

public static class CollectionExtensions
Inheritance
CollectionExtensions

Methods

GetItemOrNull<T>(IList<T>, int)

Gets the item from a list at a specified index. If index is out of the list, returns null.

public static T GetItemOrNull<T>(this IList<T> list, int index) where T : class

Parameters

list IList<T>

The list.

index int

The index.

Returns

T

The item from a list at a specified index. If index is out of the list, returns null..

Type Parameters

T

Type of the item in the list

IndexOf<T>(IReadOnlyList<T>, T)

Determines the index of a specific item in the IReadOnlyList<T>.

public static int IndexOf<T>(this IReadOnlyList<T> list, T item)

Parameters

list IReadOnlyList<T>

The list.

item T

The object to locate in the IReadOnlyList<T>.

Returns

int

The index of item if found in the list; otherwise, -1.

Type Parameters

T

SwapRemoveAt<T>(IList<T>, int)

Remove an item by swapping it with the last item and removing it from the last position. This function prevents to shift values from the list on removal but does not maintain order.

public static void SwapRemoveAt<T>(this IList<T> list, int index)

Parameters

list IList<T>

The list.

index int

Index of the item to remove.

Type Parameters

T

SwapRemove<T>(IList<T>, T)

Remove an item by swapping it with the last item and removing it from the last position. This function prevents to shift values from the list on removal but does not maintain order.

public static void SwapRemove<T>(this IList<T> list, T item)

Parameters

list IList<T>

The list.

item T

The item to remove.

Type Parameters

T