Additional static functions used to extend existing Array support inside of Unity.
More...
|
static bool | Add< T > (ref T[] array, T newObject, bool forceUnique) |
| Add a unique item to an array. More...
|
|
static bool | Add< T > (ref T[] array, T newObject) |
| Add an item to an array. More...
|
|
static bool | AddAt< T > (ref T[] array, int position, T newObject, bool forceUnique) |
| Add a unique item to an array. More...
|
|
static bool | Contains< T > (ref T[] array, T targetObject) |
| Determine if the specified array contains the targetObject. More...
|
|
static bool | Remove< T > (ref T[] array, T oldObject) |
| Removes all references for an object from array. More...
|
|
static bool | RemoveAt< T > (ref T[] array, int index) |
| Removes an object in an array at the provided index. More...
|
|
Additional static functions used to extend existing Array support inside of Unity.
Definition at line 36 of file Array.cs.
static bool Hydrogen.Array.Add< T > |
( |
ref T[] |
array, |
|
|
T |
newObject, |
|
|
bool |
forceUnique |
|
) |
| |
|
static |
Add a unique item to an array.
- Returns
true
, if something was added, false
otherwise.
- Parameters
-
array | The source array |
newObject | Object to be added. |
forceUnique | Should it check to see if there is an existing reference in the array? |
- Template Parameters
-
Definition at line 46 of file Array.cs.
48 return AddAt (ref array, array.Length, newObject, forceUnique);
static bool Hydrogen.Array.Add< T > |
( |
ref T[] |
array, |
|
|
T |
newObject |
|
) |
| |
|
static |
Add an item to an array.
- Returns
- Was anything added?
- Parameters
-
array | The source array |
newObject | Object to be added. |
- Template Parameters
-
Definition at line 58 of file Array.cs.
60 return AddAt (ref array, array.Length, newObject,
false);
static bool Hydrogen.Array.AddAt< T > |
( |
ref T[] |
array, |
|
|
int |
position, |
|
|
T |
newObject, |
|
|
bool |
forceUnique |
|
) |
| |
|
static |
Add a unique item to an array.
- Returns
true
, if something was added, false
otherwise.
- Parameters
-
array | The source array. |
position | The position (index) where to insert the object. |
newObject | Object to be added. |
forceUnique | Should it check to see if there is an existing reference in the array? |
- Template Parameters
-
Definition at line 72 of file Array.cs.
75 if (array.Length == 0) {
77 array [0] = newObject;
83 if (array.Any (t => t.Equals (newObject))) {
89 var newArray =
new T[array.Length + 1];
91 for (var x = 0; x <= array.Length; x++) {
93 newArray [x] = array [x];
94 }
else if (x == position) {
95 newArray [x] = newObject;
96 }
else if (x > position) {
97 newArray [x] = array [x - 1];
static bool Hydrogen.Array.Contains< T > |
( |
ref T[] |
array, |
|
|
T |
targetObject |
|
) |
| |
|
static |
Determine if the specified array contains the targetObject.
- Returns
true
, if something was found, false
otherwise.
- Parameters
-
array | The source array. |
targetObject | Object to test for. |
- Template Parameters
-
Definition at line 114 of file Array.cs.
116 return array.Any (t => t.Equals (targetObject));
static bool Hydrogen.Array.Remove< T > |
( |
ref T[] |
array, |
|
|
T |
oldObject |
|
) |
| |
|
static |
Removes all references for an object from array.
- Returns
true
, if something was removed, false
otherwise.
- Parameters
-
array | The source array. |
oldObject | Object to be removed. |
- Template Parameters
-
Definition at line 126 of file Array.cs.
130 if (oldObject.Equals (null)) {
134 var newArray =
new T[array.Length - 1];
138 foreach (var singleObject
in array) {
139 if (!singleObject.Equals (oldObject)) {
140 newArray [counter] = singleObject;
static bool Hydrogen.Array.RemoveAt< T > |
( |
ref T[] |
array, |
|
|
int |
index |
|
) |
| |
|
static |
Removes an object in an array at the provided index.
- Returns
true
, if something was removed, false
otherwise.
- Parameters
-
array | The source array. |
index | The index of the item to be removed. |
- Template Parameters
-
Definition at line 161 of file Array.cs.
164 if (index >= array.Length || index < 0)
167 var newArray =
new T[array.Length - 1];
170 for (
int x = 0; x < array.Length; x++) {
172 newArray [counter] = array [x];