Class ArrayExtensions
Array collection extension methods and helpers.
Inheritance
Assembly: FlaxEngine.dll
File: Engine/Core/Collections/ArrayExtensions.h
Syntax
public class ArrayExtensions
Methods
All(const Array<T* , AllocationType>& obj, const Function<bool(const T* )>& predicate)
All Any operator returns true if all elements match the predicate. It does not select the element, but returns true if all elements are matching.
Declaration
public static int32 All(const Array<T* , AllocationType>& obj, const Function<bool(const T* )>& predicate)
Parameters
Array<T , AllocationType>
obj
The target collection. |
Function<bool(T )>
predicate
The prediction function. |
Returns
int32
True if all elements in the collection matches the prediction, otherwise false. |
Type Parameters
typename T
|
typename AllocationType
|
All(const Array<T, AllocationType>& obj, const Function<bool(const T& )>& predicate)
All Any operator returns true if all elements match the predicate. It does not select the element, but returns true if all elements are matching.
Declaration
public static int32 All(const Array<T, AllocationType>& obj, const Function<bool(const T& )>& predicate)
Parameters
Array<T, AllocationType>
obj
The target collection. |
Function<bool(T)>
predicate
The prediction function. |
Returns
int32
True if all elements in the collection matches the prediction, otherwise false. |
Type Parameters
typename T
|
typename AllocationType
|
Any(const Array<T, AllocationType>& obj, const Function<bool(const T& )>& predicate)
The Any operator checks, if there are any elements in the collection matching the predicate. It does not select the element, but returns true if at least one element is matched.
Declaration
public static bool Any(const Array<T, AllocationType>& obj, const Function<bool(const T& )>& predicate)
Parameters
Array<T, AllocationType>
obj
The target collection. |
Function<bool(T)>
predicate
The prediction function. |
Returns
bool
True if any element in the collection matches the prediction, otherwise false. |
Type Parameters
typename T
|
typename AllocationType
|
First(const Array<T* , AllocationType>& obj, const Function<bool(const T* )>& predicate)
Searches for the specified object using a custom query and returns it or default value.
Declaration
public static T* First(const Array<T* , AllocationType>& obj, const Function<bool(const T* )>& predicate)
Parameters
Array<T , AllocationType>
obj
The target collection. |
Function<bool(T )>
predicate
The prediction function. Should return true for the target element to find. |
Returns
T
The first found item or default value if nothing found. |
Type Parameters
typename T
|
typename AllocationType
|
First(const Array<T, AllocationType>& obj, const Function<bool(const T& )>& predicate)
Searches for the specified object using a custom query and returns it or default value.
Declaration
public static T First(const Array<T, AllocationType>& obj, const Function<bool(const T& )>& predicate)
Parameters
Array<T, AllocationType>
obj
The target collection. |
Function<bool(T)>
predicate
The prediction function. Should return true for the target element to find. |
Returns
T
The first found item or default value if nothing found. |
Type Parameters
typename T
|
typename AllocationType
|
GroupBy(const Array<TSource, AllocationType>& obj, const Function<TKey(TSource const& )>& keySelector, Array<IGrouping<TKey, TSource>, AllocationType>& result)
Groups the elements of a sequence according to a specified key selector function.
Declaration
public static void GroupBy(const Array<TSource, AllocationType>& obj, const Function<TKey(TSource const& )>& keySelector, Array<IGrouping<TKey, TSource>, AllocationType>& result)
Parameters
Array<TSource, AllocationType>
obj
The collection whose elements to group. |
Function<TKey(TSource const)>
keySelector
A function to extract the key for each element. |
Array<IGrouping<TKey, TSource>, AllocationType>
result
The result collection with groups. |
Type Parameters
typename TSource
|
typename TKey
|
typename AllocationType
|
IndexOf(const Array<T, AllocationType>& obj, const Function<bool(const T& )>& predicate)
Searches for the specified object using a custom query and returns the zero-based index of the first occurrence within the entire collection.
Declaration
public static int32 IndexOf(const Array<T, AllocationType>& obj, const Function<bool(const T& )>& predicate)
Parameters
Array<T, AllocationType>
obj
The target collection. |
Function<bool(T)>
predicate
The prediction function. Should return true for the target element to find. |
Returns
int32
The index of the element or -1 if nothing found. |
Type Parameters
typename T
|
typename AllocationType
|
RemoveAll(Array<T, AllocationType>& obj, const Function<bool(const T& )>& predicate)
Removes all the elements that match the conditions defined by the specified predicate.
Declaration
public static void RemoveAll(Array<T, AllocationType>& obj, const Function<bool(const T& )>& predicate)
Parameters
Array<T, AllocationType>
obj
The target collection to modify. |
Function<bool(T)>
predicate
A transform function that defines the conditions of the elements to remove. |
Type Parameters
typename T
|
typename AllocationType
|
RemoveAll(const Array<T, AllocationType>& obj, const Function<bool(const T& )>& predicate)
Removes all the elements that match the conditions defined by the specified predicate.
Declaration
public static Array<T, AllocationType> RemoveAll(const Array<T, AllocationType>& obj, const Function<bool(const T& )>& predicate)
Parameters
Array<T, AllocationType>
obj
The target collection to process. |
Function<bool(T)>
predicate
A transform function that defines the conditions of the elements to remove. |
Returns
Array<T, AllocationType>
The result list whose elements are the result of invoking the transform function on each element of source. |
Type Parameters
typename T
|
typename AllocationType
|
Select(const Array<TSource, AllocationType>& obj, const Function<TResult(const TSource& )>& selector)
Projects each element of a sequence into a new form.
Declaration
public static Array<TResult, AllocationType> Select(const Array<TSource, AllocationType>& obj, const Function<TResult(const TSource& )>& selector)
Parameters
Array<TSource, AllocationType>
obj
The target collection. |
Function<TResult(TSource)>
selector
A transform function to apply to each source element; the second parameter of the function represents the index of the source element. |
Returns
Array<TResult, AllocationType>
The result list whose elements are the result of invoking the transform function on each element of source. |
Type Parameters
typename TResult
|
typename TSource
|
typename AllocationType
|
Select(const Array<TSource, AllocationType>& obj, const Function<TResult(const TSource& )>& selector, Array<TResult, AllocationType>& result)
Projects each element of a sequence into a new form.
Declaration
public static void Select(const Array<TSource, AllocationType>& obj, const Function<TResult(const TSource& )>& selector, Array<TResult, AllocationType>& result)
Parameters
Array<TSource, AllocationType>
obj
The target collection. |
Function<TResult(TSource)>
selector
A transform function to apply to each source element; the second parameter of the function represents the index of the source element. |
Array<TResult, AllocationType>
result
The result list whose elements are the result of invoking the transform function on each element of source. |
Type Parameters
typename TResult
|
typename TSource
|
typename AllocationType
|
Where(const Array<T, AllocationType>& obj, const Function<bool(const T& )>& predicate)
Filters a sequence of values based on a predicate.
Declaration
public static Array<T, AllocationType> Where(const Array<T, AllocationType>& obj, const Function<bool(const T& )>& predicate)
Parameters
Array<T, AllocationType>
obj
The target collection. |
Function<bool(T)>
predicate
The prediction function. Return true for elements that should be included in result list. |
Returns
Array<T, AllocationType>
The result list with items that passed the predicate. |
Type Parameters
typename T
|
typename AllocationType
|
Where(const Array<T, AllocationType>& obj, const Function<bool(const T& )>& predicate, Array<T, AllocationType>& result)
Filters a sequence of values based on a predicate.
Declaration
public static void Where(const Array<T, AllocationType>& obj, const Function<bool(const T& )>& predicate, Array<T, AllocationType>& result)
Parameters
Array<T, AllocationType>
obj
The target collection. |
Function<bool(T)>
predicate
The prediction function. Return true for elements that should be included in result list. |
Array<T, AllocationType>
result
The result list with items that passed the predicate. |
Type Parameters
typename T
|
typename AllocationType
|