docs.unity3d.com
    Show / Hide Table of Contents

    Struct GrowableBuffer<T>

    A List<T>-like blittable data structure backed by native allocations

    Namespace: Unity.Media.Utilities
    Syntax
    public struct GrowableBuffer<T> : IDisposable, IEquatable<GrowableBuffer<T>>, IReadOnlyList<T>, IList<T>, IValidatable where T : struct
    Type Parameters
    Name Description
    T

    The element type

    Constructors

    GrowableBuffer(Allocator, T[])

    Create a new GrowableBuffer

    Declaration
    public GrowableBuffer(Allocator allocator, T[] source)
    Parameters
    Type Name Description
    Allocator allocator

    The native allocator to use

    T[] source

    A source array to copy

    GrowableBuffer(Allocator, IReadOnlyList<T>)

    Create a new GrowableBuffer

    Declaration
    public GrowableBuffer(Allocator allocator, IReadOnlyList<T> source)
    Parameters
    Type Name Description
    Allocator allocator

    The native allocator to use

    IReadOnlyList<T> source

    A source list to copy

    GrowableBuffer(Allocator, Int32)

    Create a new GrowableBuffer

    Declaration
    public GrowableBuffer(Allocator allocator, int initialCapacity = 16)
    Parameters
    Type Name Description
    Allocator allocator

    The native allocator to use

    Int32 initialCapacity

    The initial buffer capacity

    GrowableBuffer(Allocator, GrowableBuffer<T>)

    Create a new GrowableBuffer

    Declaration
    public GrowableBuffer(Allocator allocator, GrowableBuffer<T> source)
    Parameters
    Type Name Description
    Allocator allocator

    The native allocator to use

    GrowableBuffer<T> source

    A source buffer to copy

    Properties

    Capacity

    The allocated capacity of the buffer

    Declaration
    public int Capacity { get; }
    Property Value
    Type Description
    Int32
    Remarks
    Count

    Count

    The number of items in the buffer

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    Int32
    Remarks
    Capacity

    IsReadOnly

    Whether the buffer is read-only

    Declaration
    public bool IsReadOnly { get; }
    Property Value
    Type Description
    Boolean

    Item[Int32]

    Get an item in the buffer

    Declaration
    public T this[int index] { get; set; }
    Parameters
    Type Name Description
    Int32 index

    The index of the item to retrieve

    Property Value
    Type Description
    T

    UnsafeDataPointer

    Get a pointer to the buffer data

    Declaration
    public T**UnsafeDataPointer { get; }
    Property Value
    Type Description
    T**

    Valid

    Whether the buffer is valid

    Declaration
    public bool Valid { get; }
    Property Value
    Type Description
    Boolean
    Implements
    IValidatable.Valid

    Methods

    Add(T)

    Append an item to the end of the buffer

    Declaration
    public void Add(T item)
    Parameters
    Type Name Description
    T item

    The item to add

    AddRange(IEnumerable<T>)

    Append a group of items to the end of the buffer

    Declaration
    public void AddRange(IEnumerable<T> items)
    Parameters
    Type Name Description
    IEnumerable<T> items

    The items to add

    AddRange(IList<T>)

    Append a list of items to the end of the buffer

    Declaration
    public void AddRange(IList<T> items)
    Parameters
    Type Name Description
    IList<T> items

    The items to add

    AddRange<TList>(TList)

    Declaration
    public void AddRange<TList>(TList items)
        where TList : struct, IList<T>
    Parameters
    Type Name Description
    TList items
    Type Parameters
    Name Description
    TList

    CheckCapacity(Int32)

    Ensure that the buffer has at least the given capacity

    Declaration
    public void CheckCapacity(int newCapacity)
    Parameters
    Type Name Description
    Int32 newCapacity

    The required capacity

    Clear()

    Mark the buffer as empty

    Declaration
    public void Clear()
    Remarks

    This does not trigger deallocation

    Contains(T)

    Whether a given item is contained in the buffer

    Declaration
    public bool Contains(T item)
    Parameters
    Type Name Description
    T item

    The item to find

    Returns
    Type Description
    Boolean

    CopyTo(T[], Int32)

    Copy the buffer to an array

    Declaration
    public void CopyTo(T[] array, int arrayIndex)
    Parameters
    Type Name Description
    T[] array

    The destination array

    Int32 arrayIndex

    The array index at which to begin writing

    Dispose()

    Dispose buffer storage

    Declaration
    public void Dispose()

    Equals(Object)

    Whether this is the same buffer as another instance

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj

    The other instance to compare

    Returns
    Type Description
    Boolean

    Equals(GrowableBuffer<T>)

    Whether this is the same buffer as another instance

    Declaration
    public bool Equals(GrowableBuffer<T> other)
    Parameters
    Type Name Description
    GrowableBuffer<T> other

    The other instance to compare

    Returns
    Type Description
    Boolean

    GetEnumerator()

    Declaration
    public IEnumerator<T> GetEnumerator()
    Returns
    Type Description
    IEnumerator<T>

    GetHashCode()

    Returns a unique hash code for this buffer

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    IndexOf(T)

    Find an item in the buffer

    Declaration
    public int IndexOf(T item)
    Parameters
    Type Name Description
    T item

    The item to be found

    Returns
    Type Description
    Int32

    The index of the found item, or -1

    Insert(Int32, T)

    Insert an item into the buffer

    Declaration
    public void Insert(int index, T item)
    Parameters
    Type Name Description
    Int32 index

    The position at which to insert the item

    T item

    The item to insert

    Remarks
    Count can be provided as the index, in which case it will act like Add(T)

    Remove(T)

    Remove an item from the buffer

    Declaration
    public bool Remove(T item)
    Parameters
    Type Name Description
    T item

    The item to remove

    Returns
    Type Description
    Boolean

    Whether the item was removed from the buffer

    RemoveAt(Int32)

    Remove the item at index

    Declaration
    public void RemoveAt(int index)
    Parameters
    Type Name Description
    Int32 index

    The index of the item to remove

    Extension Methods

    GrowableBufferExtensions.ToArray<T>(GrowableBuffer<T>)
    Back to top
    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