Show / Hide Table of Contents

Class ListExtensions

CSharp List extension methods.

Inheritance
System.Object
ListExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ToString()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: StansAssets.Foundation.Extensions
Assembly: cs.temp.dll.dll
Syntax
public static class ListExtensions

Methods

Clone<T>(List<T>)

Creates a deep copy of the list.

Declaration
public static List<T> Clone<T>(this List<T> list)
    where T : ICloneable
Parameters
Type Name Description
List<T> list

The current list.

Returns
Type Description
List<T>

The deep copy of the current list.

Type Parameters
Name Description
T

RemoveBySwap<T>(List<T>, T)

Fast remove method with O(n) complexity. Do not use it if an elements' order matters

Declaration
public static void RemoveBySwap<T>(this List<T> list, T item)
Parameters
Type Name Description
List<T> list

The current list.

T item

An element to be removed.

Type Parameters
Name Description
T

RemoveBySwap<T>(List<T>, Int32)

Fast remove method with O(1) complexity. Do not use it if an elements' order matters

Declaration
public static void RemoveBySwap<T>(this List<T> list, int index)
Parameters
Type Name Description
List<T> list

The current list.

System.Int32 index

Index of the element.

Type Parameters
Name Description
T

RemoveBySwap<T>(List<T>, Predicate<T>)

Fast remove method with O(n) complexity. Do not use it if an elements' order matters

Declaration
public static void RemoveBySwap<T>(this List<T> list, Predicate<T> predicate)
Parameters
Type Name Description
List<T> list

The current list.

System.Predicate<T> predicate

An element evaluation predicate.

Type Parameters
Name Description
T

Resize<T>(List<T>, Int32, T)

Resizes the list. In case of increase list size - fills it with default elements.

Declaration
public static void Resize<T>(this List<T> list, int newSize, T defaultValue = null)
Parameters
Type Name Description
List<T> list

The current list.

System.Int32 newSize

The new size of the list.

T defaultValue

The default value to set as new list elements.

Type Parameters
Name Description
T

ShallowCopy<T>(List<T>)

Creates a shallow copy of the list.

Declaration
public static List<T> ShallowCopy<T>(this List<T> list)
Parameters
Type Name Description
List<T> list

The current list.

Returns
Type Description
List<T>

The shallow copy of the current list.

Type Parameters
Name Description
T
In This Article
Back to top Generated by DocFX