docs/api/HarmonyLib.CollectionExtensions.html
General extensions for collections
System.Object
CollectionExtensions
public static class CollectionExtensions
A helper to add an item to a collection
public static IEnumerable<T> AddItem<T>(this IEnumerable<T> sequence, T item)
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | sequence |
The collection
| | T | item |
The item to add
|
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<T> |
The collection containing the item
|
| Name | Description |
|---|---|
| T |
The inner type of the collection
|
A helper to add items to an array
public static T[] AddRangeToArray<T>(this T[] sequence, T[] items)
| Type | Name | Description |
|---|---|---|
| T[] | sequence |
The array
| | T[] | items |
The items to add
|
| Type | Description |
|---|---|
| T[] |
The array containing the items
|
| Name | Description |
|---|---|
| T |
The inner type of the collection
|
A helper to add an item to an array
public static T[] AddToArray<T>(this T[] sequence, T item)
| Type | Name | Description |
|---|---|---|
| T[] | sequence |
The array
| | T | item |
The item to add
|
| Type | Description |
|---|---|
| T[] |
The array containing the item
|
| Name | Description |
|---|---|
| T |
The inner type of the collection
|
A simple way to execute code for every element in a collection
public static void Do<T>(this IEnumerable<T> sequence, Action<T> action)
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | sequence |
The collection
| | System.Action<T> | action |
The action to execute
|
| Name | Description |
|---|---|
| T |
The inner type of the collection
|
A simple way to execute code for elements in a collection matching a condition
public static void DoIf<T>(this IEnumerable<T> sequence, Func<T, bool> condition, Action<T> action)
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<T> | sequence |
The collection
| | System.Func<T, System.Boolean> | condition |
The predicate
| | System.Action<T> | action |
The action to execute
|
| Name | Description |
|---|---|
| T |
The inner type of the collection
|