Class ArrayExtensions
Array Based Extension Methods
Inheritance
Namespace: GDX
Syntax
[VisualScriptingCompatible((short)2)]
public static class ArrayExtensions
Methods
| Improve this Doc View SourceClear<T>(T[])
Set all elements in an array to the default values.
Declaration
public static void Clear<T>(this T[] targetArray)
Parameters
Type | Name | Description |
---|---|---|
T[] | targetArray | The array to be defaulted. |
Type Parameters
Name | Description |
---|---|
T | The type of the array. |
Remarks
This does not alter the targetArray
's length.
ContainsItem<T>(T[], T)
Does targetArray
contain targetValue
?
Declaration
public static bool ContainsItem<T>(this T[] targetArray, T targetValue)
where T : class
Parameters
Type | Name | Description |
---|---|---|
T[] | targetArray | The System.Array to look in. |
T | targetValue | The target item to look for. |
Returns
Type | Description |
---|---|
System.Boolean | true/false |
Type Parameters
Name | Description |
---|---|
T | The type of the System.Array. |
ContainsReference<T>(T[], T)
Does targetArray
contain targetItem
?
Declaration
public static bool ContainsReference<T>(this T[] targetArray, T targetItem)
where T : class
Parameters
Type | Name | Description |
---|---|---|
T[] | targetArray | The System.Array to look in. |
T | targetItem | The target item to look for. |
Returns
Type | Description |
---|---|
System.Boolean | true/false |
Type Parameters
Name | Description |
---|---|
T | The type of the System.Array. |
Remarks
Ignores equality check and end up comparing object pointers.
ContainsValue<T>(T[], T)
Does targetArray
contain targetValue
?
Declaration
public static bool ContainsValue<T>(this T[] targetArray, T targetValue)
where T : IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
T[] | targetArray | The System.Array to look in. |
T | targetValue | The target value to look for. |
Returns
Type | Description |
---|---|
System.Boolean | true/false |
Type Parameters
Name | Description |
---|---|
T | The type of the System.Array. |
FirstIndexOf<T>(T[], T)
Find the first index of targetItem
in targetArray
.
Declaration
public static int FirstIndexOf<T>(this T[] targetArray, T targetItem)
where T : IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
T[] | targetArray | The array which to look in. |
T | targetItem | The object to be found. |
Returns
Type | Description |
---|---|
System.Int32 | The index of |
Type Parameters
Name | Description |
---|---|
T | The type of the array. |
Remarks
This will work for System.String comparisons.
FirstIndexOfItem<T>(T[], T)
Find the first index of targetItem
in targetArray
.
Declaration
public static int FirstIndexOfItem<T>(this T[] targetArray, T targetItem)
where T : class
Parameters
Type | Name | Description |
---|---|---|
T[] | targetArray | The array which to look in. |
T | targetItem | The object to be found. |
Returns
Type | Description |
---|---|
System.Int32 | The index of |
Type Parameters
Name | Description |
---|---|
T | The type of the array. |
Remarks
Ignores equality check and end up comparing object pointers. Do NOT use this for System.String types.
FirstIndexOfValue<T>(T[], T)
Find the first index of targetValue
in targetArray
.
Declaration
public static int FirstIndexOfValue<T>(this T[] targetArray, T targetValue)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T[] | targetArray | The array which to look in. |
T | targetValue | The value to be found. |
Returns
Type | Description |
---|---|
System.Int32 | The index of |
Type Parameters
Name | Description |
---|---|
T | The type of the array. |
LastIndexOf<T>(T[], T)
Find the last index of targetItem
in targetArray
.
Declaration
public static int LastIndexOf<T>(this T[] targetArray, T targetItem)
where T : IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
T[] | targetArray | The array which to look in. |
T | targetItem | The object to be found. |
Returns
Type | Description |
---|---|
System.Int32 | The index of |
Type Parameters
Name | Description |
---|---|
T | The type of the array. |
Remarks
This will work for System.String comparisons.
LastIndexOfItem<T>(T[], T)
Find the last index of targetItem
in targetArray
.
Declaration
public static int LastIndexOfItem<T>(this T[] targetArray, T targetItem)
where T : class
Parameters
Type | Name | Description |
---|---|---|
T[] | targetArray | The array which to look in. |
T | targetItem | The object to be found. |
Returns
Type | Description |
---|---|
System.Int32 | The index of |
Type Parameters
Name | Description |
---|---|
T | The type of the array. |
LastIndexOfValue<T>(T[], T)
Find the last index of targetValue
in targetArray
.
Declaration
public static int LastIndexOfValue<T>(this T[] targetArray, T targetValue)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
T[] | targetArray | The array which to look in. |
T | targetValue | The value to be found. |
Returns
Type | Description |
---|---|
System.Int32 | The index of |
Type Parameters
Name | Description |
---|---|
T | The type of the array. |