Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 2 New Array Functions #143

Merged
merged 7 commits into from
Sep 6, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions addons/arrays/CfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ class CfgFunctions
description = "A function used to return the element counts in an array. Parameters: Array Example: _types = [0,0,1,1,1,1] call CBA_fnc_getArrayElements Returns: Array element counts (for above example, return would be [0,2,1,4]) Author: Rommel && sbsmac";
file = "\x\cba\addons\arrays\fnc_getArrayElements.sqf";
};
// CBA_fnc_getHightestVaule
class getHightestVaule
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be getHighestValue, check spelling (not just here).

{
description = "Use to find Hightest value with index in a array.";
file = "\x\cba\addons\arrays\fnc_getHightestVaule.sqf";
};
// CBA_fnc_getLowestVaule
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be getLowestValue, check spelling (not just here).

class getLowestVaule
{
description = "Use to find Hightest value with index in a Array.";
file = "\x\cba\addons\arrays\fnc_getLowestVaule.sqf";
};
// CBA_fnc_inject
class inject
{
Expand Down
32 changes: 32 additions & 0 deletions addons/arrays/fnc_getHighestValue.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* ----------------------------------------------------------------------------
Function: CBA_fnc_getHightestVaule

Description:
Use to find Hightest value with index in a Array.

Parameters:
_array: Array with Numbers

Example:
(begin example)
_array = [_array,1] call CBA_fnc_sortNestedArray
(end)

Returns:
_min: the Max Value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_max: the max value

_index: the Index of the Max Value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...index of the highest value (or "index of the max value")


Author:
joko // Jonas

---------------------------------------------------------------------------- */
#include "script_component.hpp"
SCRIPT(getLowestValue);
params ["_max"];
_index = -1;

{
if (_max < _x) then {_max = _x; _index = _forEachIndex};
} forEach _this;

[_max, _index] // Return
32 changes: 32 additions & 0 deletions addons/arrays/fnc_getLowestValue.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* ----------------------------------------------------------------------------
Function: CBA_fnc_getLowestVaule

Description:
Use to find Hightest value with index in a Array.

Parameters:
_array: Array with Numbers

Example:
(begin example)
_array = [_array,1] call CBA_fnc_sortNestedArray
(end)

Returns:
_min: the Min Value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_min: the min value

_index: the Index of the Min Value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...index of the lowest value (or "index of the min value", depending on your choice above)


Author:
joko // Jonas

---------------------------------------------------------------------------- */
#include "script_component.hpp"
SCRIPT(getLowestValue);
params ["_min"];
_index = -1;

{
if (_min > _x) then {_min = _x; _index = _forEachIndex};
} forEach _this;

[_min, _index] // Return