blob: 82fe51dcce4020358177ead4d9621cbb834850d3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#strict 2
global func ArrayErase(array& arr, int index)
{
if(index < GetLength(arr))
{
for(var i = index; i < GetLength(arr) - 1; ++i)
{
arr[i] = arr[i + 1];
}
SetLength(arr, GetLength(arr) - 1);
}
}
global func ArrayEraseItem(array& arr, item, bool multiple)
{
var index, count = 0;
while((index = GetIndexOf2(item, arr)) != -1)
{
ArrayErase(arr, index);
if(!multiple)
{
return index;
}
++count;
}
return (!multiple && -1) || count;
}
global func ArrayInsert(array& arr, int index, value)
{
for(var i = GetLength(arr); i > index; --i)
{
arr[i] = arr[i - 1];
}
arr[index] = value;
}
// only here for backwards compatibility; use arr[] = value directly
global func ArrayAppend(array& arr, value)
{
arr[] = value;
}
global func ArrayAppendArray(array& arr, array append)
{
var i = GetLength(arr);
SetLength(arr, GetLength(arr) + GetLength(append));
for(var val in append)
{
arr[i++] = val;
}
}
|