Table of Contents

Class MtArray<T>

Namespace
SharpPluginLoader.Core
Assembly
SharpPluginLoader.Core.dll

This class is a wrapper for the MtArray object in the game.

public class MtArray<T> : MtObject, IEnumerable<T>, IEnumerable where T : MtObject, new()

Type Parameters

T
Inheritance
MtArray<T>
Implements
Inherited Members

Constructors

MtArray()

Constructs a new MtArray instance with a nullptr

public MtArray()

MtArray(nint)

Constructs a new MtArray instance from a native pointer.

public MtArray(nint instance)

Parameters

instance nint

The native pointer

Properties

AutoDelete

Gets whether the array auto-deletes its contents when it is destroyed.

public bool AutoDelete { get; }

Property Value

bool

Capacity

Gets the capacity of the array.

public uint Capacity { get; }

Property Value

uint

IsEmpty

Gets whether the array is empty.

public bool IsEmpty { get; }

Property Value

bool

this[int]

Gets the value at the given index.

public T? this[int index] { get; set; }

Parameters

index int

The index of the object to retrieve

Property Value

T

The object at the index

Exceptions

IndexOutOfRangeException

Thrown if the provided index is out of bounds

Length

Gets the length of the array.

public uint Length { get; }

Property Value

uint

Methods

Clear(bool)

Clears the array.

public void Clear(bool freeMem = false)

Parameters

freeMem bool

Whether to free the memory used by the array

Contains(T)

Checks if the array contains the given item.

public bool Contains(T item)

Parameters

item T

The item to check for

Returns

bool

True if the array contains the item

Remarks

This function does a reference comparison.

Erase(int)

Erases the item at the given index from the array.

public void Erase(int index)

Parameters

index int

Erase(T)

Erases the given item from the array.

public void Erase(T item)

Parameters

item T

The item to erase

Find(Func<T, bool>)

Finds the first item in the array that matches the given predicate.

public T? Find(Func<T, bool> predicate)

Parameters

predicate Func<T, bool>

The predicate to match

Returns

T

The first item that matches the predicate, or null if none match

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

GetEnumerator()

Gets an enumerator for the array.

public IEnumerator<T> GetEnumerator()

Returns

IEnumerator<T>

The enumerator

Insert(int, T)

Inserts an item into the array at the given index.

public void Insert(int index, T item)

Parameters

index int

The index to insert the item at

item T

The item to insert

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

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

Push(T?)

Adds an item to the end of the array.

public void Push(T? item)

Parameters

item T

The item to add