BIS fnc removeIndex: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (1 revision)
m (Some wiki formatting)
 
(28 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|= Comments
|game1= arma2
____________________________________________________________________________________________
|version1= 1.00


| arma2 |= Game name
|game2= arma2oa
|version2= 1.50


|1.00|= Game version
|game3= tkoh
____________________________________________________________________________________________
|version3= 1.00


| <pre>
|game4= arma3
/************************************************************
|version4= 0.50
Remove Index


Parameters: [array, index, <end index>] OR [array, [indexes]]
|gr1= Arrays


Takes an array, and returns a new array with the specified index(es)
|descr= Takes an array, and returns a new array with the specified index(es) removed.
removed.
This takes the array passed in the first parameter, and returns an array that has the index number in the second parameter removed.
If a third parameter is passed, then a range of indexes will be removed.
Alternatively, an array of indices to remove can be passed in the second parameter.


This takes the array passed in the first parameter, and returns
{{Feature|arma3|Use [[deleteAt]] or [[deleteRange]] instead.}}
an array that has the index number in the second parameter removed.


If a third parameter is passed, then a range of indexes will be removed.
|s1= [array, startIndex, endIndex] call [[BIS_fnc_removeIndex]]


Alternatively, you can pass an array of indexes to remove in the
|p1= array: [[Array]]
second parameter.


This function doesn't touch the original array (that is passed as a parameter).
|p2= startIndex: [[Number]] - start index to be removed, if {{Link|#Parameter 3}} is not provided, only this index is removed


Examples:
|p3= endIndex: [[Number]] - (Optional, default [[Nothing]]) -  end index, if provided the indexs from startIndex to endIndex will be removed


_array = [1,["b"],"c",[4],"d"];
|r1= [[Array]] - new array with new values


[_array, 2]       call BIS_fnc_removeIndex; //returns: [1,["b"],[4],"d"]
|s2= [array, indices] call [[BIS_fnc_removeIndex]]
[_array, [0,1,3]] call BIS_fnc_removeIndex; //returns: ["c","d"]
[_array, 2, 3]    call BIS_fnc_removeIndex; //returns: [1,["b"],"d"]
************************************************************/


</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
|p21= array: [[Array]]
____________________________________________________________________________________________


| <!-- [] call [[BIS_fnc_removeIndex]]; --> |= Syntax
|p22= indices: [[Array]] of [[Number]]s - indices to be removed


|p1= |= Parameter 1
|r2= [[Array]] - new array with new values


| |= Return value
|x1= <sqf>
____________________________________________________________________________________________
private _array = [0,1,2,3,4];
[array, 0] call BIS_fnc_removeIndex; // returns [1,2,3,4]
</sqf>


|x1= <code></code> |=
|x2= <sqf>
____________________________________________________________________________________________
private _array = [0,1,2,3,4];
[_array, 0, 4] call BIS_fnc_removeIndex; // returns []
</sqf>


| |= See also
|x3= <sqf>
private _array = [0,1,2,3,4];
[_array, [0,4]] call BIS_fnc_removeIndex; // returns [1,2,3]
</sqf>


|seealso= [[deleteAt]] [[deleteRange]]
}}
}}
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style="display:none">Bottom Section</h3>
[[Category:Function Group: Arrays|{{uc:removeIndex}}]]
[[Category:Functions|{{uc:removeIndex}}]]
[[Category:{{Name|arma2}}: Functions|{{uc:removeIndex}}]]
[[Category:{{Name|arma2oa}}: Functions|{{uc:removeIndex}}]]
[[Category:{{Name|tkoh}}: Functions|{{uc:removeIndex}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:removeIndex}}]]

Latest revision as of 11:34, 1 July 2022

Hover & click on the images for description

Description

Description:
Takes an array, and returns a new array with the specified index(es) removed. This takes the array passed in the first parameter, and returns an array that has the index number in the second parameter removed. If a third parameter is passed, then a range of indexes will be removed. Alternatively, an array of indices to remove can be passed in the second parameter.
Arma 3
Use deleteAt or deleteRange instead.
Execution:
call
Groups:
Arrays

Syntax

Syntax:
[array, startIndex, endIndex] call BIS_fnc_removeIndex
Parameters:
array: Array
startIndex: Number - start index to be removed, if Parameter 3 is not provided, only this index is removed
endIndex: Number - (Optional, default Nothing) - end index, if provided the indexs from startIndex to endIndex will be removed
Return Value:
Array - new array with new values

Alternative Syntax

Syntax:
[array, indices] call BIS_fnc_removeIndex
Parameters:
array: Array
indices: Array of Numbers - indices to be removed
Return Value:
Array - new array with new values

Examples

Example 1:
private _array = [0,1,2,3,4]; [array, 0] call BIS_fnc_removeIndex; // returns [1,2,3,4]
Example 2:
private _array = [0,1,2,3,4]; [_array, 0, 4] call BIS_fnc_removeIndex; // returns []
Example 3:
private _array = [0,1,2,3,4]; [_array, [0,4]] call BIS_fnc_removeIndex; // returns [1,2,3]

Additional Information

See also:
deleteAt deleteRange

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note