Class ArrayExtensions
- Namespace
- CarinaStudio
- Assembly
- CarinaStudio.AppBase.Core.dll
Extensions for array.
public static class ArrayExtensions
- Inheritance
-
ArrayExtensions
- Inherited Members
Methods
GetRangeView<T>(T[], int, int)
Get read-only view of range of source array which allows accessing elements from source array directly without copying.
public static IList<T> GetRangeView<T>(this T[] array, int start, int count)
Parameters
array
T[]Source array.
start
intStart index of range.
count
intNumber of elements needed to be included.
Returns
- IList<T>
View of range of source array.
Type Parameters
T
Type of element.
Remarks
The method is available for target framework before .NET 9.
IsEmpty<T>(T[])
Check whether the given array is empty or not.
public static bool IsEmpty<T>(this T[] array)
Parameters
array
T[]Array to check.
Returns
- bool
True if the array is empty.
Type Parameters
T
Type of element of array.
Remarks
The method is available for target framework before .NET 9.
IsNotEmpty<T>(T[]?)
Check whether the given array is not empty or not.
public static bool IsNotEmpty<T>(this T[]? array)
Parameters
array
T[]Array to check.
Returns
- bool
True if the array is not empty.
Type Parameters
T
Type of element of array.
Remarks
The method is available for target framework before .NET 9.
IsNullOrEmpty<T>(T[]?)
Check whether given array is null/empty or not.
public static bool IsNullOrEmpty<T>(this T[]? array)
Parameters
array
T[]Array to check.
Returns
- bool
True if the array is null or empty.
Type Parameters
T
Type of element of array.
Remarks
The method is available for target framework before .NET 9.
PinAs<T, TPtr>(T[], PointerAction<TPtr>)
Pin given array, get memory address of array and perform action.
public static void PinAs<T, TPtr>(this T[] array, PointerAction<TPtr> action) where TPtr : unmanaged
Parameters
array
T[]Array.
action
PointerAction<TPtr>Method to receive address of array and perform action.
Type Parameters
T
Type of array element.
TPtr
Type of pointer of pinned array element.
PinAs<T, TPtr, R>(T[], PointerInFunc<TPtr, R>)
Pin given array, get memory address of array and generate a value.
public static R PinAs<T, TPtr, R>(this T[] array, PointerInFunc<TPtr, R> func) where TPtr : unmanaged
Parameters
array
T[]Array.
func
PointerInFunc<TPtr, R>Function to receive address of array and generate value.
Returns
- R
Generated value.
Type Parameters
T
Type of array element.
TPtr
Type of pointer of pinned array element.
R
Type of generated value.
PinAs<T1, T2, TPtr1, TPtr2>((T1[], T2[]), PointerAction<TPtr1, TPtr2>)
Pin given arrays, get memory addresses of arrays and perform action.
public static void PinAs<T1, T2, TPtr1, TPtr2>(this (T1[], T2[]) arrays, PointerAction<TPtr1, TPtr2> action) where TPtr1 : unmanaged where TPtr2 : unmanaged
Parameters
arrays
(T1[], T2[])Arrays.
action
PointerAction<TPtr1, TPtr2>Method to receive addresses of arrays and perform action.
Type Parameters
T1
Type of 1st array element.
T2
Type of 2nd array element.
TPtr1
Type of 1st pointer of pinned array element.
TPtr2
Type of 2nd pointer of pinned array element.
PinAs<T1, T2, TPtr1, TPtr2, R>((T1[], T2[]), PointerInFunc<TPtr1, TPtr2, R>)
Pin given arrays, get memory addresses of arrays and generate a value.
public static R PinAs<T1, T2, TPtr1, TPtr2, R>(this (T1[], T2[]) arrays, PointerInFunc<TPtr1, TPtr2, R> func) where TPtr1 : unmanaged where TPtr2 : unmanaged
Parameters
arrays
(T1[], T2[])Arrays.
func
PointerInFunc<TPtr1, TPtr2, R>Function to receive addresses of arrays and generate value.
Returns
- R
Generated value.
Type Parameters
T1
Type of 1st array element.
T2
Type of 2nd array element.
TPtr1
Type of 1st pointer of pinned array element.
TPtr2
Type of 2nd pointer of pinned array element.
R
Type of generated value.
Pin<T>(T[], Action<IntPtr>)
Pin given array, get memory address of array and perform action.
public static void Pin<T>(this T[] array, Action<IntPtr> action)
Parameters
Type Parameters
T
Type of array element.
Pin<T1, T2>((T1[], T2[]), Action<IntPtr, IntPtr>)
Pin given arrays, get memory addresses of arrays and perform action.
public static void Pin<T1, T2>(this (T1[], T2[]) arrays, Action<IntPtr, IntPtr> action)
Parameters
arrays
(T1[], T2[])Arrays.
action
Action<IntPtr, IntPtr>Method to receive addresses of arrays and perform action.
Type Parameters
T1
Type of 1st array element.
T2
Type of 2nd array element.
Pin<T, R>(T[], Func<IntPtr, R>)
Pin given array, get memory address of array and generate a value.
public static R Pin<T, R>(this T[] array, Func<IntPtr, R> func)
Parameters
Returns
- R
Generated value.
Type Parameters
T
Type of array element.
R
Type of generated value.
Pin<T1, T2, R>((T1[], T2[]), Func<IntPtr, IntPtr, R>)
Pin given arrays, get memory addresses of arrays and generate a value.
public static R Pin<T1, T2, R>(this (T1[], T2[]) arrays, Func<IntPtr, IntPtr, R> func)
Parameters
arrays
(T1[], T2[])Arrays.
func
Func<IntPtr, IntPtr, R>Function to receive addresses of arrays and generate value.
Returns
- R
Generated value.
Type Parameters
T1
Type of 1st array element.
T2
Type of 2nd array element.
R
Type of generated value.