Struct FixedList512Bytes<T>
An unmanaged, resizable list whose content is all stored directly in the 512-byte struct. Useful for small lists.
Namespace: Unity.Collections
Assembly: Unity.Collections.dll
Syntax
[Serializable]
public struct FixedList512Bytes<T> : INativeList<T>, IIndexable<T> where T : unmanaged
Type Parameters
Name | Description |
---|---|
T | The type of the elements. |
Constructors
FixedList512Bytes(in FixedList128Bytes<T>)
Initializes and returns an instance of FixedList512Bytes with content copied from another list.
Declaration
public FixedList512Bytes(in FixedList128Bytes<T> other)
Parameters
Type | Name | Description |
---|---|---|
FixedList128Bytes<T> | other | The list to copy. |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Throws if the other list's length exceeds the capacity of FixedList512Bytes<T>. |
FixedList512Bytes(in FixedList32Bytes<T>)
Initializes and returns an instance of FixedList512Bytes with content copied from another list.
Declaration
public FixedList512Bytes(in FixedList32Bytes<T> other)
Parameters
Type | Name | Description |
---|---|---|
FixedList32Bytes<T> | other | The list to copy. |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Throws if the other list's length exceeds the capacity of FixedList512Bytes<T>. |
FixedList512Bytes(in FixedList4096Bytes<T>)
Initializes and returns an instance of FixedList512Bytes with content copied from another list.
Declaration
public FixedList512Bytes(in FixedList4096Bytes<T> other)
Parameters
Type | Name | Description |
---|---|---|
FixedList4096Bytes<T> | other | The list to copy. |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Throws if the other list's length exceeds the capacity of FixedList512Bytes<T>. |
FixedList512Bytes(in FixedList64Bytes<T>)
Initializes and returns an instance of FixedList512Bytes with content copied from another list.
Declaration
public FixedList512Bytes(in FixedList64Bytes<T> other)
Parameters
Type | Name | Description |
---|---|---|
FixedList64Bytes<T> | other | The list to copy. |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Throws if the other list's length exceeds the capacity of FixedList512Bytes<T>. |
Properties
Capacity
The number of elements that can fit in this list.
Declaration
public int Capacity { get; set; }
Property Value
Type | Description |
---|---|
int | The number of elements that can fit in this list. |
Remarks
The capacity of a FixedList cannot be changed. The setter is included only for conformity with INativeList<T>.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if the new value does not match the current capacity. |
IsEmpty
Whether this list is empty.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
bool | True if this list is empty. |
this[int]
The element at a given index.
Declaration
public T this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | index | An index. |
Property Value
Type | Description |
---|---|
T | The value to store at the index. |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Thrown if the index is out of bounds. |
Length
The current number of items in this list.
Declaration
public int Length { get; set; }
Property Value
Type | Description |
---|---|
int | The current number of items in this list. |
Methods
Add(in 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(in T). Remember that a fixed list is never resized.
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Thrown if the append exceeds the capacity. |
AddNoResize(in 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(in T). Included only for consistency with the other list types.
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Thrown if the append exceeds the capacity. |
AddRange(void*, int)
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. |
int | length | The number of elements from the buffer to append. |
Remarks
The same as AddRangeNoResize(void*, int). Remember that a fixed list is never resized.
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Thrown if the append exceeds the capacity. |
AddRangeNoResize(void*, int)
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. |
int | length | The number of elements from the buffer to append. |
Remarks
The same as AddRange(void*, int). Included only for consistency with the other list types.
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Thrown if the append exceeds the capacity. |
Clear()
Sets the length to 0.
Declaration
public void 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 |
---|---|
int | An integer denoting the respective sort position of the list relative to the other:
|
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 |
---|---|
int | An integer denoting the respective sort position of the list relative to the other:
|
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 |
---|---|
int | An integer denoting the respective sort position of the list relative to the other:
|
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 |
---|---|
int | An integer denoting the respective sort position of the list relative to the other:
|
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 |
---|---|
int | An integer denoting the respective sort position of the list relative to the other:
|
ElementAt(int)
Returns the element at a given index.
Declaration
public ref T ElementAt(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | An index. |
Returns
Type | Description |
---|---|
T | The list element at the index. |
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 |
---|---|
bool | True if the list is equal to the object. |
Overrides
Remarks
Two lists are equal if their length and bytes are equal.
A FixedList*N*<T> can only be equal to another FixedList*N*<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 |
---|---|
bool | 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 |
---|---|
bool | 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 |
---|---|
bool | 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 |
---|---|
bool | 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 |
---|---|
bool | 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 FixedList512Bytes<T>.Enumerator GetEnumerator()
Returns
Type | Description |
---|---|
FixedList512Bytes<T>.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 |
---|---|
int | The hash code of this list. |
Overrides
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(int, in 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 |
---|---|---|
int | index | The index at which to insert the element. |
T | item | The element to insert. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if the index is out of bounds. |
InsertRangeWithBeginEnd(int, int)
Shifts elements toward the end of this list, increasing its length.
Declaration
public void InsertRangeWithBeginEnd(int begin, int end)
Parameters
Type | Name | Description |
---|---|---|
int | begin | The index of the first element that will be shifted up. |
int | 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.
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Thrown if the new length exceeds the capacity. |
RemoveAt(int)
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 |
---|---|---|
int | 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.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if the index is out of bounds. |
RemoveAtSwapBack(int)
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 |
---|---|---|
int | 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.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if the index is out of bounds. |
RemoveRange(int, int)
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 |
---|---|---|
int | index | The first index of the range to remove. |
int | 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.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if the index is out of bounds. |
RemoveRangeSwapBack(int, int)
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 |
---|---|---|
int | index | The first index of the destination range. |
int | 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.
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if the index is out of bounds. |
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(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
operator ==(in FixedList512Bytes<T>, in FixedList128Bytes<T>)
Returns true if two lists are equal.
Declaration
public static bool operator ==(in FixedList512Bytes<T> a, in FixedList128Bytes<T> b)
Parameters
Type | Name | Description |
---|---|---|
FixedList512Bytes<T> | a | The first list to compare for equality. |
FixedList128Bytes<T> | b | The second list to compare for equality. |
Returns
Type | Description |
---|---|
bool | True if the two lists are equal. |
Remarks
Two lists are equal if their length and bytes are equal.
operator ==(in FixedList512Bytes<T>, in FixedList32Bytes<T>)
Returns true if two lists are equal.
Declaration
public static bool operator ==(in FixedList512Bytes<T> a, in FixedList32Bytes<T> b)
Parameters
Type | Name | Description |
---|---|---|
FixedList512Bytes<T> | a | The first list to compare for equality. |
FixedList32Bytes<T> | b | The second list to compare for equality. |
Returns
Type | Description |
---|---|
bool | True if the two lists are equal. |
Remarks
Two lists are equal if their length and bytes are equal.
operator ==(in FixedList512Bytes<T>, in FixedList4096Bytes<T>)
Returns true if two lists are equal.
Declaration
public static bool operator ==(in FixedList512Bytes<T> a, in FixedList4096Bytes<T> b)
Parameters
Type | Name | Description |
---|---|---|
FixedList512Bytes<T> | a | The first list to compare for equality. |
FixedList4096Bytes<T> | b | The second list to compare for equality. |
Returns
Type | Description |
---|---|
bool | True if the two lists are equal. |
Remarks
Two lists are equal if their length and bytes are equal.
operator ==(in FixedList512Bytes<T>, in FixedList512Bytes<T>)
Returns true if two lists are equal.
Declaration
public static bool operator ==(in FixedList512Bytes<T> a, in FixedList512Bytes<T> b)
Parameters
Type | Name | Description |
---|---|---|
FixedList512Bytes<T> | a | The first list to compare for equality. |
FixedList512Bytes<T> | b | The second list to compare for equality. |
Returns
Type | Description |
---|---|
bool | True if the two lists are equal. |
Remarks
Two lists are equal if their length and bytes are equal.
operator ==(in FixedList512Bytes<T>, in FixedList64Bytes<T>)
Returns true if two lists are equal.
Declaration
public static bool operator ==(in FixedList512Bytes<T> a, in FixedList64Bytes<T> b)
Parameters
Type | Name | Description |
---|---|---|
FixedList512Bytes<T> | a | The first list to compare for equality. |
FixedList64Bytes<T> | b | The second list to compare for equality. |
Returns
Type | Description |
---|---|
bool | True if the two lists are equal. |
Remarks
Two lists are equal if their length and bytes are equal.
implicit operator FixedList512Bytes<T>(in FixedList128Bytes<T>)
Returns a new list that is a copy of another list.
Declaration
public static implicit operator FixedList512Bytes<T>(in FixedList128Bytes<T> other)
Parameters
Type | Name | Description |
---|---|---|
FixedList128Bytes<T> | other | The list to copy. |
Returns
Type | Description |
---|---|
FixedList512Bytes<T> | A new list that is a copy of the other. |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Throws if the other list's length exceeds the capacity of FixedList512Bytes<T>. |
implicit operator FixedList512Bytes<T>(in FixedList32Bytes<T>)
Returns a new list that is a copy of another list.
Declaration
public static implicit operator FixedList512Bytes<T>(in FixedList32Bytes<T> other)
Parameters
Type | Name | Description |
---|---|---|
FixedList32Bytes<T> | other | The list to copy. |
Returns
Type | Description |
---|---|
FixedList512Bytes<T> | A new list that is a copy of the other. |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Throws if the other list's length exceeds the capacity of FixedList512Bytes<T>. |
implicit operator FixedList512Bytes<T>(in FixedList4096Bytes<T>)
Returns a new list that is a copy of another list.
Declaration
public static implicit operator FixedList512Bytes<T>(in FixedList4096Bytes<T> other)
Parameters
Type | Name | Description |
---|---|---|
FixedList4096Bytes<T> | other | The list to copy. |
Returns
Type | Description |
---|---|
FixedList512Bytes<T> | A new list that is a copy of the other. |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Throws if the other list's length exceeds the capacity of FixedList512Bytes<T>. |
implicit operator FixedList512Bytes<T>(in FixedList64Bytes<T>)
Returns a new list that is a copy of another list.
Declaration
public static implicit operator FixedList512Bytes<T>(in FixedList64Bytes<T> other)
Parameters
Type | Name | Description |
---|---|---|
FixedList64Bytes<T> | other | The list to copy. |
Returns
Type | Description |
---|---|
FixedList512Bytes<T> | A new list that is a copy of the other. |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Throws if the other list's length exceeds the capacity of FixedList512Bytes<T>. |
operator !=(in FixedList512Bytes<T>, in FixedList128Bytes<T>)
Returns true if two lists are unequal.
Declaration
public static bool operator !=(in FixedList512Bytes<T> a, in FixedList128Bytes<T> b)
Parameters
Type | Name | Description |
---|---|---|
FixedList512Bytes<T> | a | The first list to compare for inequality. |
FixedList128Bytes<T> | b | The second list to compare for inequality. |
Returns
Type | Description |
---|---|
bool | True if the two lists are unequal. |
Remarks
Two lists are equal if their length and bytes are equal.
operator !=(in FixedList512Bytes<T>, in FixedList32Bytes<T>)
Returns true if two lists are unequal.
Declaration
public static bool operator !=(in FixedList512Bytes<T> a, in FixedList32Bytes<T> b)
Parameters
Type | Name | Description |
---|---|---|
FixedList512Bytes<T> | a | The first list to compare for inequality. |
FixedList32Bytes<T> | b | The second list to compare for inequality. |
Returns
Type | Description |
---|---|
bool | True if the two lists are unequal. |
Remarks
Two lists are equal if their length and bytes are equal.
operator !=(in FixedList512Bytes<T>, in FixedList4096Bytes<T>)
Returns true if two lists are unequal.
Declaration
public static bool operator !=(in FixedList512Bytes<T> a, in FixedList4096Bytes<T> b)
Parameters
Type | Name | Description |
---|---|---|
FixedList512Bytes<T> | a | The first list to compare for inequality. |
FixedList4096Bytes<T> | b | The second list to compare for inequality. |
Returns
Type | Description |
---|---|
bool | True if the two lists are unequal. |
Remarks
Two lists are equal if their length and bytes are equal.
operator !=(in FixedList512Bytes<T>, in FixedList512Bytes<T>)
Returns true if two lists are unequal.
Declaration
public static bool operator !=(in FixedList512Bytes<T> a, in FixedList512Bytes<T> b)
Parameters
Type | Name | Description |
---|---|---|
FixedList512Bytes<T> | a | The first list to compare for inequality. |
FixedList512Bytes<T> | b | The second list to compare for inequality. |
Returns
Type | Description |
---|---|
bool | True if the two lists are unequal. |
Remarks
Two lists are equal if their length and bytes are equal.
operator !=(in FixedList512Bytes<T>, in FixedList64Bytes<T>)
Returns true if two lists are unequal.
Declaration
public static bool operator !=(in FixedList512Bytes<T> a, in FixedList64Bytes<T> b)
Parameters
Type | Name | Description |
---|---|---|
FixedList512Bytes<T> | a | The first list to compare for inequality. |
FixedList64Bytes<T> | b | The second list to compare for inequality. |
Returns
Type | Description |
---|---|
bool | True if the two lists are unequal. |
Remarks
Two lists are equal if their length and bytes are equal.