Class ListExtensions
List extensions.
Namespace: Unity.Collections
Syntax
public static class ListExtensions
Methods
RemoveAtSwapBack<T>(List<T>, Int32)
Truncates the list by replacing the item at the specified index with the last item in the list. The list is shortened by one.
Declaration
public static void RemoveAtSwapBack<T>(this List<T> list, int index)
Parameters
| Type | Name | Description |
|---|---|---|
| List<T> | list | List to perform removal. |
| Int32 | index | The index of the item to delete. |
Type Parameters
| Name | Description |
|---|---|
| T | Source type of elements |
RemoveSwapBack<T>(List<T>, T)
Truncates the list by replacing the item at the specified index with the last item in the list. The list is shortened by one.
Declaration
public static bool RemoveSwapBack<T>(this List<T> list, T item)
Parameters
| Type | Name | Description |
|---|---|---|
| List<T> | list | List to perform removal. |
| T | item | Item value to remove. |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if item is removed, if item was not in the container returns false. |
Type Parameters
| Name | Description |
|---|---|
| T | Source type of elements |
RemoveSwapBack<T>(List<T>, Predicate<T>)
Truncates the list by replacing the item at the specified index with the last item in the list. The list is shortened by one.
Declaration
public static bool RemoveSwapBack<T>(this List<T> list, Predicate<T> matcher)
Parameters
| Type | Name | Description |
|---|---|---|
| List<T> | list | List to perform removal. |
| Predicate<T> | matcher |
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if item is removed, if item was not in the container returns false. |
Type Parameters
| Name | Description |
|---|---|
| T | Source type of elements |
ToNativeArray<T>(List<T>, Allocator)
Convert System.Collections.Generics.List to Unity.Collections.NativeArray.
Declaration
public static NativeArray<T> ToNativeArray<T>(this List<T> list, Allocator allocator)
where T : struct
Parameters
| Type | Name | Description |
|---|---|---|
| List<T> | list | List to perform conversion. |
| Allocator | allocator | A member of the Unity.Collections.Allocator enumeration. |
Returns
| Type | Description |
|---|---|
| NativeArray<T> | A NativeArray copy of the List. |
Type Parameters
| Name | Description |
|---|---|
| T | Source type of elements |
ToNativeList<T>(List<T>, Allocator)
Convert System.Collections.Generics.List to Unity.Collections.NativeList.
Declaration
public static NativeList<T> ToNativeList<T>(this List<T> list, Allocator allocator)
where T : struct
Parameters
| Type | Name | Description |
|---|---|---|
| List<T> | list | List to perform conversion. |
| Allocator | allocator | A member of the Unity.Collections.Allocator enumeration. |
Returns
| Type | Description |
|---|---|
| NativeList<T> | A NativeList copy of the List. |
Type Parameters
| Name | Description |
|---|---|
| T | Source type of elements |