|
static int | RandomIndex< T > (this T[] array) |
| Get a random index of the array More...
|
|
static T | RandomValue< T > (this T[] array) |
| Get a random value from the array More...
|
|
static bool | Contains< T > (this T[] array, T target) |
| Check if an array contains a target More...
|
|
static T [] | Add< T > (this T[] array, T item) |
| add element to array. Extends array length by 1. More...
|
|
static T [] | GetRange< T > (this T[] array, int startIndex, int endIndex=-1) |
| Get a Range of Elements in an Array. endIndex is NOT INCLUSIVE More...
|
|
static int [] | Indexes< T > (this T[] arr) |
| Gets an array of all the indexes More...
|
|
static int | BinarySearchLowerBound (this float[] array, float value) |
| Search a (ordered) float array for the first value exceeding or equal to the argument More...
|
|
static int | BinarySearchLowerBound (this double[] array, double value) |
| Search a (ordered) float array for the first value exceeding or equal to the argument More...
|
|
Definition at line 6 of file ArrayExtensions.cs.
◆ Add< T >()
static T [] BGC.Extensions.ArrayExtensions.Add< T > |
( |
this T [] |
array, |
|
|
T |
item |
|
) |
| |
|
inlinestatic |
add element to array. Extends array length by 1.
- Template Parameters
-
- Parameters
-
Definition at line 55 of file ArrayExtensions.cs.
57 T[] newArray =
new T[array.Length + 1];
58 newArray[array.Length] = item;
60 for (
int i = 0; i < array.Length; ++i)
62 newArray[i] = array[i];
◆ BinarySearchLowerBound() [1/2]
static int BGC.Extensions.ArrayExtensions.BinarySearchLowerBound |
( |
this float [] |
array, |
|
|
float |
value |
|
) |
| |
|
inlinestatic |
Search a (ordered) float array for the first value exceeding or equal to the argument
Definition at line 120 of file ArrayExtensions.cs.
123 int max = array.Length;
126 if (value < array[0])
133 guess = (max + min) / 2;
139 else if (array[guess] == value)
143 else if (value > array[guess])
◆ BinarySearchLowerBound() [2/2]
static int BGC.Extensions.ArrayExtensions.BinarySearchLowerBound |
( |
this double [] |
array, |
|
|
double |
value |
|
) |
| |
|
inlinestatic |
Search a (ordered) float array for the first value exceeding or equal to the argument
Definition at line 157 of file ArrayExtensions.cs.
160 int max = array.Length;
163 if (value < array[0])
170 guess = (max + min) / 2;
176 else if (array[guess] == value)
180 else if (value > array[guess])
◆ Contains< T >()
static bool BGC.Extensions.ArrayExtensions.Contains< T > |
( |
this T [] |
array, |
|
|
T |
target |
|
) |
| |
|
inlinestatic |
Check if an array contains a target
- Template Parameters
-
- Parameters
-
- Returns
Definition at line 37 of file ArrayExtensions.cs.
39 for (
int i = 0; i < array.Length; i++)
41 if (Equals(array[i], target))
◆ GetRange< T >()
static T [] BGC.Extensions.ArrayExtensions.GetRange< T > |
( |
this T [] |
array, |
|
|
int |
startIndex, |
|
|
int |
endIndex = -1 |
|
) |
| |
|
inlinestatic |
Get a Range of Elements in an Array. endIndex is NOT INCLUSIVE
- Template Parameters
-
- Parameters
-
array | |
startIndex | |
endIndex | |
- Returns
Definition at line 77 of file ArrayExtensions.cs.
81 endIndex = array.Length;
84 Assert.IsNotNull(array);
85 Assert.IsTrue(startIndex > -1);
86 Assert.IsTrue(endIndex >= startIndex);
87 Assert.IsFalse(startIndex > array.Length);
88 Assert.IsFalse(endIndex > array.Length);
90 T[] arr =
new T[endIndex - startIndex];
91 for (
int i = startIndex; i < endIndex; ++i)
93 arr[i - startIndex] = array[i];
◆ Indexes< T >()
static int [] BGC.Extensions.ArrayExtensions.Indexes< T > |
( |
this T [] |
arr | ) |
|
|
inlinestatic |
Gets an array of all the indexes
- Template Parameters
-
- Parameters
-
- Returns
Definition at line 105 of file ArrayExtensions.cs.
107 int[] indexes =
new int[arr.Length];
109 for (
int i = 0; i < arr.Length; ++i)
◆ RandomIndex< T >()
static int BGC.Extensions.ArrayExtensions.RandomIndex< T > |
( |
this T [] |
array | ) |
|
|
inlinestatic |
Get a random index of the array
- Template Parameters
-
- Parameters
-
- Returns
Definition at line 14 of file ArrayExtensions.cs.
16 return Random.Range(0, array.Length);
◆ RandomValue< T >()
static T BGC.Extensions.ArrayExtensions.RandomValue< T > |
( |
this T [] |
array | ) |
|
|
inlinestatic |
Get a random value from the array
- Template Parameters
-
- Parameters
-
- Returns
Definition at line 25 of file ArrayExtensions.cs.
27 return array[array.RandomIndex()];
The documentation for this class was generated from the following file: