Class ListExtensions
- Namespace
- Garyon.Extensions
- Assembly
- Garyon.dll
Provides extension methods for the List<T> class.
public static class ListExtensions
- Inheritance
-
ListExtensions
- Inherited Members
Methods
Clone<T>(List<List<T>>)
Clones a list of lists.
public static List<List<T>> Clone<T>(this List<List<T>> l)
Parameters
Returns
Type Parameters
TThe type of the list elements.
InsertAtStart<T>(List<T>, T)
Inserts an element at the start of the List<T>.
public static List<T> InsertAtStart<T>(this List<T> l, T element)
Parameters
Returns
Type Parameters
TThe type of the elements contained in the List<T>.
MoveElementToEnd<T>(List<T>, int)
Moves an element to the end of the List<T>.
public static List<T> MoveElementToEnd<T>(this List<T> l, int from)
Parameters
Returns
Type Parameters
TThe type of the elements contained in the List<T>.
MoveElementToStart<T>(List<T>, int)
Moves an element to the start of the List<T>.
public static List<T> MoveElementToStart<T>(this List<T> l, int from)
Parameters
Returns
Type Parameters
TThe type of the elements contained in the List<T>.
MoveElement<T>(List<T>, int, int)
Moves an element in the List<T> to a different position.
public static List<T> MoveElement<T>(this List<T> l, int from, int to)
Parameters
lList<T>The List<T> within which to move an element.
fromintThe index of the element to move.
tointThe new index of the element.
Returns
Type Parameters
TThe type of the elements contained in the List<T>.
RemoveRange<T>(List<T>, IEnumerable<T>)
Removes a collection of elements from a list and returns a new list that does not contain the removed elements.
public static List<T> RemoveRange<T>(this List<T> l, IEnumerable<T> elements)
Parameters
lList<T>The list whose elements to remove.
elementsIEnumerable<T>The elements to remove.
Returns
- List<T>
A new copy of the list that does not contain the removed elements.
Type Parameters
TThe type of the elements that are stored in the list.
RemoveRange<T>(List<T>, IEnumerable<T>, out int)
Removes a collection of elements from a list and returns a new list that does not contain the removed elements.
public static List<T> RemoveRange<T>(this List<T> l, IEnumerable<T> elements, out int removedElements)
Parameters
lList<T>The list whose elements to remove.
elementsIEnumerable<T>The elements to remove.
removedElementsintThe number of elements that were removed from the list.
Returns
- List<T>
A new copy of the list that does not contain the removed elements.
Type Parameters
TThe type of the elements that are stored in the list.
SetEnsureCapacity<T>(List<T>, int, T)
Sets an element to the list at the specified index, by extending the list if the count is insufficient.
public static void SetEnsureCapacity<T>(this List<T> list, int index, T element)
Parameters
listList<T>The list on which to set the element at the specified index.
indexintThe index at which to set the element.
elementTThe element to set.
Type Parameters
TThe element type.