Class ListExtensions
Extension methods for List<T> objects.
Inherited Members
Namespace: Unity.XR.CoreUtils
Syntax
public static class ListExtensions
Methods
EnsureCapacity<T>(List<T>, Int32)
Ensures that the capacity of this list is at least as large the given value.
Declaration
public static void EnsureCapacity<T>(this List<T> list, int capacity)
Parameters
Type | Name | Description |
---|---|---|
List<T> | list | The list whose capacity will be ensured. |
Int32 | capacity | The minimum number of elements the list storage must contain. |
Type Parameters
Name | Description |
---|---|
T | The list element type. |
Remarks
Increases the capacity of the list, if necessary, but doe not decrease the capacity if it already exceeds the specified value.
Fill<T>(List<T>, Int32)
Fills the list with default objects of type T
.
Declaration
public static List<T> Fill<T>(this List<T> list, int count)
where T : new()
Parameters
Type | Name | Description |
---|---|---|
List<T> | list | The list to populate. |
Int32 | count | The number of items to add to the list. |
Returns
Type | Description |
---|---|
List<T> | The list that was filled. |
Type Parameters
Name | Description |
---|---|
T | The type of objects in this list. |
SwapAtIndices<T>(List<T>, Int32, Int32)
Swaps the elements at first
and second
with minimal copying.
Works for any type of List<T>.
Declaration
public static void SwapAtIndices<T>(this List<T> list, int first, int second)
Parameters
Type | Name | Description |
---|---|---|
List<T> | list | The list to perform the swap on. |
Int32 | first | The index of the first item to swap. |
Int32 | second | The index of the second item to swap. |
Type Parameters
Name | Description |
---|---|
T | The type of list items to swapped. |