MtArray<T>
Namespace: SharpPluginLoader.Core
This class is a wrapper for the MtArray object in the game.
public class MtArray<T> : MtObject, , System.Collections.IEnumerable
Type Parameters
T
Inheritance Object → NativeWrapper → MtObject → MtArray<T>
Implements IEnumerable<T>, IEnumerable
Properties
Length
Gets the length of the array.
public uint Length { get; private set; }
Property Value
Capacity
Gets the capacity of the array.
public uint Capacity { get; }
Property Value
AutoDelete
Gets whether the array auto-deletes its contents when it is destroyed.
public bool AutoDelete { get; }
Property Value
IsEmpty
Gets whether the array is empty.
public bool IsEmpty { get; }
Property Value
Item
public T Item { get; set; }
Property Value
T
Instance
The native pointer.
public nint Instance { get; set; }
Property Value
Constructors
MtArray(IntPtr)
Constructs a new MtArray instance from a native pointer.
public MtArray(nint instance)
Parameters
instance
IntPtr
The native pointer
MtArray()
Constructs a new MtArray instance with a nullptr
public MtArray()
Methods
Push(T)
Adds an item to the end of the array.
public void Push(T item)
Parameters
item
T
The item to add
Pop()
Removes the last item from the array and returns it.
public T Pop()
Returns
T
The removed item
Exceptions
InvalidOperationException
Thrown if the array is empty
First()
Gets the first item in the array.
public T First()
Returns
T
The first item in the array
Exceptions
InvalidOperationException
Thrown if the array is empty
Last()
Gets the last item in the array.
public T Last()
Returns
T
The last item in the array
Exceptions
InvalidOperationException
Thrown if the array is empty
Contains(T)
Checks if the array contains the given item.
public bool Contains(T item)
Parameters
item
T
The item to check for
Returns
Boolean
True if the array contains the item
Remarks:
This function does a reference comparison.
Find(Func<T, Boolean>)
Finds the first item in the array that matches the given predicate.
public T Find(Func<T, bool> predicate)
Parameters
predicate
Func<T, Boolean>
The predicate to match
Returns
T
The first item that matches the predicate, or null if none match
Clear(Boolean)
Clears the array.
public void Clear(bool freeMem)
Parameters
freeMem
Boolean
Whether to free the memory used by the array
Insert(Int32, T)
Inserts an item into the array at the given index.
public void Insert(int index, T item)
Parameters
index
Int32
The index to insert the item at
item
T
The item to insert
Erase(T)
Erases the given item from the array.
public void Erase(T item)
Parameters
item
T
The item to erase
Erase(Int32)
Erases the item at the given index from the array.
public void Erase(int index)
Parameters
index
Int32
GetEnumerator()
Gets an enumerator for the array.
public IEnumerator<T> GetEnumerator()
Returns
IEnumerator<T>
The enumerator