docs.unity.cn
    Show / Hide Table of Contents

    Struct FixedList32Bytes<T>

    An unmanaged, resizable list whose content is all stored directly in the 32-byte struct. Useful for small lists.

    Namespace: Unity.Collections
    Syntax
    public struct FixedList32Bytes<T> : INativeList<T>, IIndexable<T>, IEnumerable<T>, IEquatable<FixedList32Bytes<T>>, IComparable<FixedList32Bytes<T>>, IEquatable<FixedList64Bytes<T>>, IComparable<FixedList64Bytes<T>>, IEquatable<FixedList128Bytes<T>>, IComparable<FixedList128Bytes<T>>, IEquatable<FixedList512Bytes<T>>, IComparable<FixedList512Bytes<T>>, IEquatable<FixedList4096Bytes<T>>, IComparable<FixedList4096Bytes<T>> where T : struct
    Type Parameters
    Name Description
    T

    The type of the elements.

    Constructors

    FixedList32Bytes(FixedList128Bytes<T>)

    Initializes and returns an instance of FixedList32Bytes with content copied from another list.

    Declaration
    public FixedList32Bytes(in FixedList128Bytes<T> other)
    Parameters
    Type Name Description
    FixedList128Bytes<T> other

    The list to copy.

    FixedList32Bytes(FixedList4096Bytes<T>)

    Initializes and returns an instance of FixedList32Bytes with content copied from another list.

    Declaration
    public FixedList32Bytes(in FixedList4096Bytes<T> other)
    Parameters
    Type Name Description
    FixedList4096Bytes<T> other

    The list to copy.

    FixedList32Bytes(FixedList512Bytes<T>)

    Initializes and returns an instance of FixedList32Bytes with content copied from another list.

    Declaration
    public FixedList32Bytes(in FixedList512Bytes<T> other)
    Parameters
    Type Name Description
    FixedList512Bytes<T> other

    The list to copy.

    FixedList32Bytes(FixedList64Bytes<T>)

    Initializes and returns an instance of FixedList32Bytes with content copied from another list.

    Declaration
    public FixedList32Bytes(in FixedList64Bytes<T> other)
    Parameters
    Type Name Description
    FixedList64Bytes<T> other

    The list to copy.

    Properties

    Capacity

    The number of elements that can fit in this list.

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

    The number of elements that can fit in this list.

    Implements
    INativeList<T>.Capacity
    Remarks

    The capacity of a FixedList cannot be changed. The setter is included only for conformity with INativeList<T>.

    IsEmpty

    Whether this list is empty.

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

    True if this list is empty.

    Implements
    INativeList<T>.IsEmpty

    Item[Int32]

    The element at a given index.

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

    An index.

    Property Value
    Type Description
    T

    The value to store at the index.

    Implements
    INativeList<T>.Item[Int32]

    Length

    The current number of items in this list.

    Declaration
    public int Length { get; set; }
    Property Value
    Type Description
    Int32

    The current number of items in this list.

    Implements
    IIndexable<T>.Length

    Methods

    Add(T)

    Appends an element to the end of this list. Increments the length by 1.

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

    The element to append at the end of the list.

    Remarks

    The same as AddNoResize(T). Remember that a fixed list is never resized.

    AddNoResize(T)

    Appends an element to the end of this list. Increments the length by 1.

    Declaration
    public void AddNoResize(in T item)
    Parameters
    Type Name Description
    T item

    The element to append at the end of the list.

    Remarks

    The same as Add(T). Included only for consistency with the other list types.

    AddRange(Void*, Int32)

    Appends elements from a buffer to the end of this list. Increments the length by the number of appended elements.

    Declaration
    public void AddRange(void *ptr, int length)
    Parameters
    Type Name Description
    Void* ptr

    A buffer.

    Int32 length

    The number of elements from the buffer to append.

    Remarks

    The same as AddRangeNoResize(Void*, Int32). Remember that a fixed list is never resized.

    AddRangeNoResize(Void*, Int32)

    Appends elements from a buffer to the end of this list. Increments the length by the number of appended elements.

    Declaration
    public void AddRangeNoResize(void *ptr, int length)
    Parameters
    Type Name Description
    Void* ptr

    A buffer.

    Int32 length

    The number of elements from the buffer to append.

    Remarks

    The same as AddRange(Void*, Int32). Included only for consistency with the other list types.

    Clear()

    Sets the length to 0.

    Declaration
    public void Clear()
    Implements
    INativeList<T>.Clear()
    Remarks

    Does not zero out the bytes.

    CompareTo(FixedList128Bytes<T>)

    Returns a number denoting whether this list should be placed before or after another list in a sort.

    Declaration
    public int CompareTo(FixedList128Bytes<T> other)
    Parameters
    Type Name Description
    FixedList128Bytes<T> other

    A list to to compare with.

    Returns
    Type Description
    Int32

    An integer denoting the respective sort position of the list relative to the other:

    0 denotes that both lists should have the same position in a sort. -1 denotes that this list should precede the other list in a sort. +1 denotes that this list should follow the other list in a sort.

    CompareTo(FixedList32Bytes<T>)

    Returns a number denoting whether this list should be placed before or after another list in a sort.

    Declaration
    public int CompareTo(FixedList32Bytes<T> other)
    Parameters
    Type Name Description
    FixedList32Bytes<T> other

    A list to to compare with.

    Returns
    Type Description
    Int32

    An integer denoting the respective sort position of the list relative to the other:

    0 denotes that both lists should have the same position in a sort. -1 denotes that this list should precede the other list in a sort. +1 denotes that this list should follow the other list in a sort.

    CompareTo(FixedList4096Bytes<T>)

    Returns a number denoting whether this list should be placed before or after another list in a sort.

    Declaration
    public int CompareTo(FixedList4096Bytes<T> other)
    Parameters
    Type Name Description
    FixedList4096Bytes<T> other

    A list to to compare with.

    Returns
    Type Description
    Int32

    An integer denoting the respective sort position of the list relative to the other:

    0 denotes that both lists should have the same position in a sort. -1 denotes that this list should precede the other list in a sort. +1 denotes that this list should follow the other list in a sort.

    CompareTo(FixedList512Bytes<T>)

    Returns a number denoting whether this list should be placed before or after another list in a sort.

    Declaration
    public int CompareTo(FixedList512Bytes<T> other)
    Parameters
    Type Name Description
    FixedList512Bytes<T> other

    A list to to compare with.

    Returns
    Type Description
    Int32

    An integer denoting the respective sort position of the list relative to the other:

    0 denotes that both lists should have the same position in a sort. -1 denotes that this list should precede the other list in a sort. +1 denotes that this list should follow the other list in a sort.

    CompareTo(FixedList64Bytes<T>)

    Returns a number denoting whether this list should be placed before or after another list in a sort.

    Declaration
    public int CompareTo(FixedList64Bytes<T> other)
    Parameters
    Type Name Description
    FixedList64Bytes<T> other

    A list to to compare with.

    Returns
    Type Description
    Int32

    An integer denoting the respective sort position of the list relative to the other:

    0 denotes that both lists should have the same position in a sort. -1 denotes that this list should precede the other list in a sort. +1 denotes that this list should follow the other list in a sort.

    ElementAt(Int32)

    Returns the element at a given index.

    Declaration
    public T ElementAt(int index)
    Parameters
    Type Name Description
    Int32 index

    An index.

    Returns
    Type Description
    T

    The list element at the index.

    Implements
    IIndexable<T>.ElementAt(Int32)

    Equals(Object)

    Returns true if the list is equal to an object.

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

    An object to compare for equality.

    Returns
    Type Description
    Boolean

    True if the list is equal to the object.

    Remarks

    Two lists are equal if their length and bytes are equal.

    A FixedListN<T> can only be equal to another FixedListN<T> with the same N and T.

    Equals(FixedList128Bytes<T>)

    Returns true if this list and another list are equal.

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

    The list to compare for equality.

    Returns
    Type Description
    Boolean

    True if the two lists are equal.

    Remarks

    Two lists are equal if their length and bytes are equal.

    Equals(FixedList32Bytes<T>)

    Returns true if this list and another list are equal.

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

    The list to compare for equality.

    Returns
    Type Description
    Boolean

    True if the two lists are equal.

    Remarks

    Two lists are equal if their length and bytes are equal.

    Equals(FixedList4096Bytes<T>)

    Returns true if this list and another list are equal.

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

    The list to compare for equality.

    Returns
    Type Description
    Boolean

    True if the two lists are equal.

    Remarks

    Two lists are equal if their length and bytes are equal.

    Equals(FixedList512Bytes<T>)

    Returns true if this list and another list are equal.

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

    The list to compare for equality.

    Returns
    Type Description
    Boolean

    True if the two lists are equal.

    Remarks

    Two lists are equal if their length and bytes are equal.

    Equals(FixedList64Bytes<T>)

    Returns true if this list and another list are equal.

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

    The list to compare for equality.

    Returns
    Type Description
    Boolean

    True if the two lists are equal.

    Remarks

    Two lists are equal if their length and bytes are equal.

    GetEnumerator()

    Returns an enumerator for iterating over the elements of this list.

    Declaration
    public FixedList32Bytes<T>.Enumerator GetEnumerator()
    Returns
    Type Description
    FixedList32Bytes.Enumerator<>

    An enumerator for iterating over the elements of this list.

    GetHashCode()

    Returns the hash code of this list.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    The hash code of this list.

    Remarks

    Only the content of the list (the bytes of the elements) are included in the hash. Any bytes beyond the length are not part of the hash.

    Insert(Int32, T)

    Inserts a single element at an index. Increments the length by 1.

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

    The index at which to insert the element.

    T item

    The element to insert.

    InsertRangeWithBeginEnd(Int32, Int32)

    Shifts elements toward the end of this list, increasing its length.

    Declaration
    public void InsertRangeWithBeginEnd(int begin, int end)
    Parameters
    Type Name Description
    Int32 begin

    The index of the first element that will be shifted up.

    Int32 end

    The index where the first shifted element will end up.

    Remarks

    Right-shifts elements in the list so as to create 'free' slots at the beginning or in the middle.

    The length is increased by end - begin.

    If end equals begin, the method does nothing.

    The element at index begin will be copied to index end, the element at index begin + 1 will be copied to end + 1, and so forth.

    The indexes begin up to end are not cleared: they will contain whatever values they held prior.

    RemoveAt(Int32)

    Removes the element at an index. Shifts everything above the index down by one and decrements the length by 1.

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

    The index of the element to remove.

    Remarks

    If you don't care about preserving the order of the elements, RemoveAtSwapBack is a more efficient way to remove an element.

    RemoveAtSwapBack(Int32)

    Copies the last element of this list to an index. Decrements the length by 1.

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

    The index to overwrite with the last element.

    Remarks

    Useful as a cheap way to remove elements from a list when you don't care about preserving order.

    RemoveRange(Int32, Int32)

    Removes N elements of a range. Shifts everything above the range down by N and decrements the length by N.

    Declaration
    public void RemoveRange(int index, int count)
    Parameters
    Type Name Description
    Int32 index

    The first index of the range to remove.

    Int32 count

    The number of elements to remove.

    Remarks

    If you don't care about preserving the order of the elements, RemoveAtSwapBack is a more efficient way to remove elements.

    RemoveRangeSwapBack(Int32, Int32)

    Copies the last N elements of this list to a range in this list. Decrements the length by N.

    Declaration
    public void RemoveRangeSwapBack(int index, int count)
    Parameters
    Type Name Description
    Int32 index

    The first index of the destination range.

    Int32 count

    The number of elements to copy and the amount by which to decrement the length.

    Remarks

    Copies the last count-numbered elements to the range starting at index.

    Useful as a cheap way to remove elements from a list when you don't care about preserving order.

    Does nothing if the count is less than 1.

    RemoveRangeSwapBackWithBeginEnd(Int32, Int32)

    Copies the last N elements of this list to a range in this list. Decrements the length by N.

    Declaration
    public void RemoveRangeSwapBackWithBeginEnd(int begin, int end)
    Parameters
    Type Name Description
    Int32 begin

    The first index of the item to remove.

    Int32 end

    The index past-the-last item to remove.

    RemoveRangeWithBeginEnd(Int32, Int32)

    Removes N elements of a range. Shifts everything above the range down by N and decrements the length by N.

    Declaration
    public void RemoveRangeWithBeginEnd(int begin, int end)
    Parameters
    Type Name Description
    Int32 begin

    The first index of the item to remove.

    Int32 end

    The index past-the-last item to remove.

    Remarks

    This method of removing item(s) is useful only in case when list is ordered and user wants to preserve order in list after removal In majority of cases is not important and user should use more performant RemoveRangeSwapBackWithBeginEnd.

    ToArray()

    Returns a managed array that is a copy of this list.

    Declaration
    public T[] ToArray()
    Returns
    Type Description
    T[]

    A managed array that is a copy of this list.

    ToNativeArray(AllocatorManager.AllocatorHandle)

    Returns an array that is a copy of this list.

    Declaration
    public NativeArray<T> ToNativeArray(AllocatorManager.AllocatorHandle allocator)
    Parameters
    Type Name Description
    AllocatorManager.AllocatorHandle allocator

    The allocator to use.

    Returns
    Type Description
    NativeArray<T>

    An array that is a copy of this list.

    Operators

    Equality(FixedList32Bytes<T>, FixedList128Bytes<T>)

    Returns true if two lists are equal.

    Declaration
    public static bool operator ==(in FixedList32Bytes<T> a, in FixedList128Bytes<T> b)
    Parameters
    Type Name Description
    FixedList32Bytes<T> a

    The first list to compare for equality.

    FixedList128Bytes<T> b

    The second list to compare for equality.

    Returns
    Type Description
    Boolean

    True if the two lists are equal.

    Remarks

    Two lists are equal if their length and bytes are equal.

    Equality(FixedList32Bytes<T>, FixedList32Bytes<T>)

    Returns true if two lists are equal.

    Declaration
    public static bool operator ==(in FixedList32Bytes<T> a, in FixedList32Bytes<T> b)
    Parameters
    Type Name Description
    FixedList32Bytes<T> a

    The first list to compare for equality.

    FixedList32Bytes<T> b

    The second list to compare for equality.

    Returns
    Type Description
    Boolean

    True if the two lists are equal.

    Remarks

    Two lists are equal if their length and bytes are equal.

    Equality(FixedList32Bytes<T>, FixedList4096Bytes<T>)

    Returns true if two lists are equal.

    Declaration
    public static bool operator ==(in FixedList32Bytes<T> a, in FixedList4096Bytes<T> b)
    Parameters
    Type Name Description
    FixedList32Bytes<T> a

    The first list to compare for equality.

    FixedList4096Bytes<T> b

    The second list to compare for equality.

    Returns
    Type Description
    Boolean

    True if the two lists are equal.

    Remarks

    Two lists are equal if their length and bytes are equal.

    Equality(FixedList32Bytes<T>, FixedList512Bytes<T>)

    Returns true if two lists are equal.

    Declaration
    public static bool operator ==(in FixedList32Bytes<T> a, in FixedList512Bytes<T> b)
    Parameters
    Type Name Description
    FixedList32Bytes<T> a

    The first list to compare for equality.

    FixedList512Bytes<T> b

    The second list to compare for equality.

    Returns
    Type Description
    Boolean

    True if the two lists are equal.

    Remarks

    Two lists are equal if their length and bytes are equal.

    Equality(FixedList32Bytes<T>, FixedList64Bytes<T>)

    Returns true if two lists are equal.

    Declaration
    public static bool operator ==(in FixedList32Bytes<T> a, in FixedList64Bytes<T> b)
    Parameters
    Type Name Description
    FixedList32Bytes<T> a

    The first list to compare for equality.

    FixedList64Bytes<T> b

    The second list to compare for equality.

    Returns
    Type Description
    Boolean

    True if the two lists are equal.

    Remarks

    Two lists are equal if their length and bytes are equal.

    Implicit(FixedList128Bytes<T> to FixedList32Bytes<T>)

    Returns a new list that is a copy of another list.

    Declaration
    public static implicit operator FixedList32Bytes<T>(in FixedList128Bytes<T> other)
    Parameters
    Type Name Description
    FixedList128Bytes<T> other

    The list to copy.

    Returns
    Type Description
    FixedList32Bytes<T>

    A new list that is a copy of the other.

    Implicit(FixedList4096Bytes<T> to FixedList32Bytes<T>)

    Returns a new list that is a copy of another list.

    Declaration
    public static implicit operator FixedList32Bytes<T>(in FixedList4096Bytes<T> other)
    Parameters
    Type Name Description
    FixedList4096Bytes<T> other

    The list to copy.

    Returns
    Type Description
    FixedList32Bytes<T>

    A new list that is a copy of the other.

    Implicit(FixedList512Bytes<T> to FixedList32Bytes<T>)

    Returns a new list that is a copy of another list.

    Declaration
    public static implicit operator FixedList32Bytes<T>(in FixedList512Bytes<T> other)
    Parameters
    Type Name Description
    FixedList512Bytes<T> other

    The list to copy.

    Returns
    Type Description
    FixedList32Bytes<T>

    A new list that is a copy of the other.

    Implicit(FixedList64Bytes<T> to FixedList32Bytes<T>)

    Returns a new list that is a copy of another list.

    Declaration
    public static implicit operator FixedList32Bytes<T>(in FixedList64Bytes<T> other)
    Parameters
    Type Name Description
    FixedList64Bytes<T> other

    The list to copy.

    Returns
    Type Description
    FixedList32Bytes<T>

    A new list that is a copy of the other.

    Inequality(FixedList32Bytes<T>, FixedList128Bytes<T>)

    Returns true if two lists are unequal.

    Declaration
    public static bool operator !=(in FixedList32Bytes<T> a, in FixedList128Bytes<T> b)
    Parameters
    Type Name Description
    FixedList32Bytes<T> a

    The first list to compare for inequality.

    FixedList128Bytes<T> b

    The second list to compare for inequality.

    Returns
    Type Description
    Boolean

    True if the two lists are unequal.

    Remarks

    Two lists are equal if their length and bytes are equal.

    Inequality(FixedList32Bytes<T>, FixedList32Bytes<T>)

    Returns true if two lists are unequal.

    Declaration
    public static bool operator !=(in FixedList32Bytes<T> a, in FixedList32Bytes<T> b)
    Parameters
    Type Name Description
    FixedList32Bytes<T> a

    The first list to compare for inequality.

    FixedList32Bytes<T> b

    The second list to compare for inequality.

    Returns
    Type Description
    Boolean

    True if the two lists are unequal.

    Remarks

    Two lists are equal if their length and bytes are equal.

    Inequality(FixedList32Bytes<T>, FixedList4096Bytes<T>)

    Returns true if two lists are unequal.

    Declaration
    public static bool operator !=(in FixedList32Bytes<T> a, in FixedList4096Bytes<T> b)
    Parameters
    Type Name Description
    FixedList32Bytes<T> a

    The first list to compare for inequality.

    FixedList4096Bytes<T> b

    The second list to compare for inequality.

    Returns
    Type Description
    Boolean

    True if the two lists are unequal.

    Remarks

    Two lists are equal if their length and bytes are equal.

    Inequality(FixedList32Bytes<T>, FixedList512Bytes<T>)

    Returns true if two lists are unequal.

    Declaration
    public static bool operator !=(in FixedList32Bytes<T> a, in FixedList512Bytes<T> b)
    Parameters
    Type Name Description
    FixedList32Bytes<T> a

    The first list to compare for inequality.

    FixedList512Bytes<T> b

    The second list to compare for inequality.

    Returns
    Type Description
    Boolean

    True if the two lists are unequal.

    Remarks

    Two lists are equal if their length and bytes are equal.

    Inequality(FixedList32Bytes<T>, FixedList64Bytes<T>)

    Returns true if two lists are unequal.

    Declaration
    public static bool operator !=(in FixedList32Bytes<T> a, in FixedList64Bytes<T> b)
    Parameters
    Type Name Description
    FixedList32Bytes<T> a

    The first list to compare for inequality.

    FixedList64Bytes<T> b

    The second list to compare for inequality.

    Returns
    Type Description
    Boolean

    True if the two lists are unequal.

    Remarks

    Two lists are equal if their length and bytes are equal.

    Back to top Copyright © 2020 Unity Technologies
    Generated by DocFX
    on Wednesday, September 29, 2021