docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ListExtensions

    Extension methods for List<T> objects.

    Inheritance
    object
    ListExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.XR.CoreUtils
    Assembly: Unity.XR.CoreUtils.dll
    Syntax
    public static class ListExtensions

    Methods

    EnsureCapacity<T>(List<T>, int)

    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.

    int 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>, int)

    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.

    int 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>, int, int)

    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.

    int first

    The index of the first item to swap.

    int second

    The index of the second item to swap.

    Type Parameters
    Name Description
    T

    The type of list items to swapped.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)