docs.unity3d.com
    Show / Hide Table of Contents

    Class CollectionPool<TCollection, TValue>

    A generic collection pool for avoiding allocations when new empty collections are needed frequently

    Inheritance
    Object
    CollectionPool<TCollection, TValue>
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.XR.CoreUtils
    Syntax
    public static class CollectionPool<TCollection, TValue>
        where TCollection : ICollection<TValue>, new()
    Type Parameters
    Name Description
    TCollection

    The desired type of collection

    TValue

    The value type of the ICollection specified in TCollection

    Methods

    GetCollection()

    Get a collection of the given type from the pool, or create a new one if the pool is empty

    Declaration
    public static TCollection GetCollection()
    Returns
    Type Description
    TCollection

    An empty collection

    RecycleCollection(TCollection)

    Return a collection to the pool

    Declaration
    public static void RecycleCollection(TCollection collection)
    Parameters
    Type Name Description
    TCollection collection

    The collection to be added to the pool

    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023