Back to Harmony

Class CollectionExtensions

docs/api/HarmonyLib.CollectionExtensions.html

2.4.2.03.0 KB
Original Source

Class CollectionExtensions

General extensions for collections

Inheritance

System.Object

CollectionExtensions

Namespace : HarmonyLib
Assembly : 0Harmony.dll
Syntax
public static class CollectionExtensions

Methods

AddItem<T>(IEnumerable<T>, T)

A helper to add an item to a collection

Declaration
public static IEnumerable<T> AddItem<T>(this IEnumerable<T> sequence, T item)
Parameters
TypeNameDescription
System.Collections.Generic.IEnumerable<T>sequence

The collection

| | T | item |

The item to add

|

Returns
TypeDescription
System.Collections.Generic.IEnumerable<T>

The collection containing the item

|

Type Parameters
NameDescription
T

The inner type of the collection

|

AddRangeToArray<T>(T[], T[])

A helper to add items to an array

Declaration
public static T[] AddRangeToArray<T>(this T[] sequence, T[] items)
Parameters
TypeNameDescription
T[]sequence

The array

| | T[] | items |

The items to add

|

Returns
TypeDescription
T[]

The array containing the items

|

Type Parameters
NameDescription
T

The inner type of the collection

|

AddToArray<T>(T[], T)

A helper to add an item to an array

Declaration
public static T[] AddToArray<T>(this T[] sequence, T item)
Parameters
TypeNameDescription
T[]sequence

The array

| | T | item |

The item to add

|

Returns
TypeDescription
T[]

The array containing the item

|

Type Parameters
NameDescription
T

The inner type of the collection

|

Do<T>(IEnumerable<T>, Action<T>)

A simple way to execute code for every element in a collection

Declaration
public static void Do<T>(this IEnumerable<T> sequence, Action<T> action)
Parameters
TypeNameDescription
System.Collections.Generic.IEnumerable<T>sequence

The collection

| | System.Action<T> | action |

The action to execute

|

Type Parameters
NameDescription
T

The inner type of the collection

|

DoIf<T>(IEnumerable<T>, Func<T, Boolean>, Action<T>)

A simple way to execute code for elements in a collection matching a condition

Declaration
public static void DoIf<T>(this IEnumerable<T> sequence, Func<T, bool> condition, Action<T> action)
Parameters
TypeNameDescription
System.Collections.Generic.IEnumerable<T>sequence

The collection

| | System.Func<T, System.Boolean> | condition |

The predicate

| | System.Action<T> | action |

The action to execute

|

Type Parameters
NameDescription
T

The inner type of the collection

|