Method RemoveSwapBack
RemoveSwapBack<T>(List<T>, T)
Finds and removes the first occurrence of a particular value in the list.
Declaration
public static bool RemoveSwapBack<T>(this List<T> list, T value)
Parameters
Type | Name | Description |
---|---|---|
List<T> | list | The list to search. |
T | value | The value to locate and remove. |
Returns
Type | Description |
---|---|
bool | Returns true if an element was removed. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the list. |
Remarks
If found, the first occurrence of the value is overwritten by the last element of the list, and the list's length is decremented by one.
RemoveSwapBack<T>(List<T>, Predicate<T>)
Finds and removes the first value which satisfies a predicate.
Declaration
public static bool RemoveSwapBack<T>(this List<T> list, Predicate<T> matcher)
Parameters
Type | Name | Description |
---|---|---|
List<T> | list | The list to search. |
Predicate<T> | matcher | The predicate for testing the elements of the list. |
Returns
Type | Description |
---|---|
bool | Returns true if an element was removed. |
Type Parameters
Name | Description |
---|---|
T | The type of elements in the list. |
Remarks
The first value satisfying the predicate is overwritten by the last element of the list, and the list's length is decremented by one.