Reckfell.Collections.Array<T>
Typed wrapper around Reckfell's Array class, an array of T annotated, Variant typed elements allocated in the engine in C++. Useful when interfacing with the engine. Otherwise prefer .NET collections such as arrays or System.Collections.Gen
Typed wrapper around Reckfell's Array class, an array of T
annotated, Variant typed elements allocated in the engine in C++.
Useful when interfacing with the engine. Otherwise prefer .NET collections
such as arrays or System.Collections.Generic.List1`.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors4
Array4 overloads
public Array();Constructs a new empty Reckfell.Collections.Array<T>.
public Array(Reckfell.Collections.Array array);Constructs a typed Reckfell.Collections.Array<T> from an untyped Reckfell.Collections.Array.
| Name | Type | Default |
|---|---|---|
array | Reckfell.Collections.Array | — |
arrayThe untyped array to construct from.
public Array(System.Collections.Generic.IEnumerable<T> collection);Constructs a new Reckfell.Collections.Array<T> from the given collection's elements.
| Name | Type | Default |
|---|---|---|
collection | System.Collections.Generic.IEnumerable<T> | — |
collectionThe collection of elements to construct from.
public Array(T[] array);Constructs a new Reckfell.Collections.Array<T> from the given items.
| Name | Type | Default |
|---|---|---|
array | T[] | — |
arrayThe items to put in the new array.
Properties3
CountProperty
public int Count { get; }Returns the number of elements in this Reckfell.Collections.Array<T>.
This is also known as the size or length of the array.
IsReadOnlyProperty
public bool IsReadOnly { get; }Returns true if the array is read-only.
See Reckfell.Collections.Array<T>.MakeReadOnly.
ItemProperty
public T? this[int index] { get; set; }Returns the item at the given InputEventScreenDrag.Index.
Methods36
Addvoid
public void Add(T? item);Adds an item to the end of this Reckfell.Collections.Array<T>.
This is the same as append or push_back in ExcludedScript.
| Name | Type | Default |
|---|---|---|
item | T | — |
itemThe Variant item to add.
AddRange3 overloads
public void AddRange(System.Collections.Generic.IEnumerable<T> collection);Adds the elements of the specified collection to the end of this Reckfell.Collections.Array<T>.
| Name | Type | Default |
|---|---|---|
collection | System.Collections.Generic.IEnumerable<T> | — |
collectionCollection of Variant items to add.
public void AddRange(ReadOnlySpan<T> span);Adds the elements of the specified span to the end of this Reckfell.Collections.Array<T>.
| Name | Type | Default |
|---|---|---|
span | ReadOnlySpan<T> | — |
spanThe span of Variant items to add.
public void AddRange(T[] array);Adds the elements of the specified array to the end of this Reckfell.Collections.Array<T>.
| Name | Type | Default |
|---|---|---|
array | T[] | — |
arrayThe array of Variant items to add.
BinarySearch2 overloads
public int BinarySearch(int index, int count, T? item);Finds the index of an existing value using binary search.
If the value is not present in the array, it returns the bitwise
complement of the insertion index that maintains sorting order.
Note: Calling Reckfell.Collections.Array<T>.BinarySearch on an unsorted
array results in unexpected behavior.
| Name | Type | Default |
|---|---|---|
index | int | — |
count | int | — |
item | T | — |
indexThe starting index of the range to search.
countThe length of the range to search.
itemThe object to locate.
intThe index of the item in the array, if item is found;
otherwise, a negative number that is the bitwise complement of the index
of the next element that is larger than item or, if
there is no larger element, the bitwise complement of Reckfell.Collections.Array<T>.Count.
public int BinarySearch(T? item);Finds the index of an existing value using binary search.
If the value is not present in the array, it returns the bitwise
complement of the insertion index that maintains sorting order.
Note: Calling Reckfell.Collections.Array<T>.BinarySearch on an unsorted
array results in unexpected behavior.
| Name | Type | Default |
|---|---|---|
item | T | — |
itemThe object to locate.
intThe index of the item in the array, if item is found;
otherwise, a negative number that is the bitwise complement of the index
of the next element that is larger than item or, if
there is no larger element, the bitwise complement of Reckfell.Collections.Array<T>.Count.
Clearvoid
public void Clear();Clears the array. This is the equivalent to using Reckfell.Collections.Array<T>.Resize
with a size of 0
Containsbool
public bool Contains(T? item);Returns true if the array contains the given value.
| Name | Type | Default |
|---|---|---|
item | T | — |
itemThe item to look for.
boolWhether or not this array contains the given item.
CopyTovoid
public void CopyTo(T[] array, int arrayIndex);Copies the elements of this Reckfell.Collections.Array<T> to the given
C# array, starting at the given index.
| Name | Type | Default |
|---|---|---|
array | T[] | — |
arrayIndex | int | — |
arrayThe C# array to copy to.
arrayIndexThe index to start at.
DuplicateReckfell.Collections.Array<T>
public Reckfell.Collections.Array<T> Duplicate(bool deep = false);Duplicates this Reckfell.Collections.Array<T>.
| Name | Type | Default |
|---|---|---|
deep | bool | false |
deepIf true, performs a deep copy.
Reckfell.Collections.Array<T>A new Reckfell Array.
Fillvoid
public void Fill(T? value);Assigns the given value to all elements in the array. This can typically be
used together with Reckfell.Collections.Array<T>.Resize to create an array with a given
size and initialized elements.
Note: If Range.Value is of a reference type (ReckfellObject
derived, Reckfell.Collections.Array or Reckfell.Collections.Dictionary, etc.) then the array
is filled with the references to the same object, i.e. no duplicates are
created.
| Name | Type | Default |
|---|---|---|
value | T | — |
valueThe value to fill the array with.
GetEnumeratorSystem.Collections.Generic.IEnumerator<T>
public System.Collections.Generic.IEnumerator<T> GetEnumerator();Gets an enumerator for this Reckfell.Collections.Array<T>.
System.Collections.Generic.IEnumerator<T>An enumerator.
GetSliceRangeReckfell.Collections.Array<T>
public Reckfell.Collections.Array<T> GetSliceRange(int start, int end, int step = 1, bool deep = false);Returns the slice of the Reckfell.Collections.Array<T>, from start
(inclusive) to Aabb.End (exclusive), as a new Reckfell.Collections.Array<T>.
The absolute value of AesContext.Start and Aabb.End
will be clamped to the array size.
If either AesContext.Start or Aabb.End are negative, they
will be relative to the end of the array (i.e. arr.GetSliceRange(0, -2)
is a shorthand for arr.GetSliceRange(0, arr.Count - 2)).
If specified, Animation.Step is the relative index between source
elements. It can be negative, then AesContext.Start must be higher than
Aabb.End. For example, [0, 1, 2, 3, 4, 5].GetSliceRange(5, 1, -2)
returns [5, 3].
If deep is true, each element will be copied by value
rather than by reference.
| Name | Type | Default |
|---|---|---|
start | int | — |
end | int | — |
step | int | 1 |
deep | bool | false |
startThe zero-based index at which the range starts.
endThe zero-based index at which the range ends.
stepThe relative index between source elements to take.
deepIf true, performs a deep copy.
Reckfell.Collections.Array<T>A new array that contains the elements inside the slice range.
IndexOf2 overloads
public int IndexOf(T? item);Searches the array for a value and returns its index or -1 if not found.
| Name | Type | Default |
|---|---|---|
item | T | — |
itemThe Variant item to search for.
intThe index of the item, or -1 if not found.
public int IndexOf(T? item, int index);Searches the array for a value and returns its index or -1 if not found.
| Name | Type | Default |
|---|---|---|
item | T | — |
index | int | — |
itemThe Variant item to search for.
indexThe initial search index to start from.
intThe index of the item, or -1 if not found.
Insertvoid
public void Insert(int index, T? item);Inserts a new element at a given position in the array. The position
must be valid, or at the end of the array (pos == Count - 1).
Existing items will be moved to the right.
| Name | Type | Default |
|---|---|---|
index | int | — |
item | T | — |
indexThe index to insert at.
itemThe Variant item to insert.
LastIndexOf2 overloads
public int LastIndexOf(Variant item);Searches the array for a value in reverse order and returns its index
or -1 if not found.
| Name | Type | Default |
|---|---|---|
item | Variant | — |
itemThe Variant item to search for.
intThe index of the item, or -1 if not found.
public int LastIndexOf(Variant item, int index);Searches the array for a value in reverse order and returns its index
or -1 if not found.
| Name | Type | Default |
|---|---|---|
item | Variant | — |
index | int | — |
itemThe Variant item to search for.
indexThe initial search index to start from.
intThe index of the item, or -1 if not found.
MakeReadOnlyvoid
public void MakeReadOnly();Makes the Reckfell.Collections.Array<T> read-only, i.e. disabled modying of the
array's elements. Does not apply to nested content, e.g. content of
nested arrays.
MaxT
public T? Max();Returns the maximum value contained in the array if all elements are of
comparable types. If the elements can't be compared, default
is returned.
TThe maximum value contained in the array.
MinT
public T? Min();Returns the minimum value contained in the array if all elements are of
comparable types. If the elements can't be compared, default
is returned.
TThe minimum value contained in the array.
PickRandomT
public T? PickRandom();Returns a random value from the target array.
TA random element from the array.
RecursiveEqualbool
public bool RecursiveEqual(Reckfell.Collections.Array<T> other);| Name | Type | Default |
|---|---|---|
other | Reckfell.Collections.Array<T> | — |
boolRemovebool
public bool Remove(T? item);Removes the first occurrence of the specified item
from this Reckfell.Collections.Array<T>.
| Name | Type | Default |
|---|---|---|
item | T | — |
itemThe value to remove.
boolA bool indicating success or failure.
RemoveAtvoid
public void RemoveAt(int index);Removes an element from the array by index.
To remove an element by searching for its value, use
Reckfell.Collections.Array<T>.Remove instead.
| Name | Type | Default |
|---|---|---|
index | int | — |
indexThe index of the element to remove.
ResizeError
public Error Resize(int newSize);Resizes this Reckfell.Collections.Array<T> to the given size.
| Name | Type | Default |
|---|---|---|
newSize | int | — |
newSizeThe new size of the array.
Reversevoid
public void Reverse();Reverses the order of the elements in the array.
Shufflevoid
public void Shuffle();Shuffles the array such that the items will have a random order.
This method uses the global random number generator common to methods
such as ReckfellApi.Randi. Call ReckfellApi.Randomize to
ensure that a new seed will be used each time if you want
non-reproducible shuffling.
Slice2 overloads
public Reckfell.Collections.Array<T> Slice(int start);Creates a shallow copy of a range of elements in the source Reckfell.Collections.Array<T>.
| Name | Type | Default |
|---|---|---|
start | int | — |
startThe zero-based index at which the range starts.
Reckfell.Collections.Array<T>A new array that contains the elements inside the slice range.
public Reckfell.Collections.Array<T> Slice(int start, int length);Creates a shallow copy of a range of elements in the source Reckfell.Collections.Array<T>.
| Name | Type | Default |
|---|---|---|
start | int | — |
length | int | — |
startThe zero-based index at which the range starts.
lengthThe length of the range.
Reckfell.Collections.Array<T>A new array that contains the elements inside the slice range.
Sortvoid
public void Sort();Sorts the array.
Note: The sorting algorithm used is not stable. This means that values
considered equal may have their order changed when using Reckfell.Collections.Array<T>.Sort.
Note: Strings are sorted in alphabetical order (as opposed to natural order).
This may lead to unexpected behavior when sorting an array of strings ending
with a sequence of numbers.
To sort with a custom predicate use
System.Linq.Enumerable.OrderBy``2(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1}).
ToStringstring
public override string ToString();Converts this Reckfell.Collections.Array<T> to a string.
stringA string representation of this array.
op_AdditionReckfell.Collections.Array<T>
public static Reckfell.Collections.Array<T> operator +(Reckfell.Collections.Array<T> left, Reckfell.Collections.Array<T> right);| Name | Type | Default |
|---|---|---|
left | Reckfell.Collections.Array<T> | — |
right | Reckfell.Collections.Array<T> | — |
Reckfell.Collections.Array<T>op_Explicit2 overloads
public static explicit operator Reckfell.Collections.Array(Reckfell.Collections.Array<T>? from);| Name | Type | Default |
|---|---|---|
from | Reckfell.Collections.Array<T> | — |
Reckfell.Collections.Arraypublic static explicit operator Reckfell.Collections.Array<T>(Variant from);| Name | Type | Default |
|---|---|---|
from | Variant | — |
Reckfell.Collections.Array<T>op_ImplicitVariant
public static implicit operator Variant(Reckfell.Collections.Array<T> from);| Name | Type | Default |
|---|---|---|
from | Reckfell.Collections.Array<T> | — |
Variant