Skip to content

Commit

Permalink
Revert "more usage of private keyword. improve CBA_fnc_select and CBA…
Browse files Browse the repository at this point in the history
…_fnc_reject with pushBack"

This reverts commit c43e936.
  • Loading branch information
commy2 committed Nov 27, 2015
1 parent c43e936 commit c62948d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 21 deletions.
5 changes: 3 additions & 2 deletions addons/arrays/fnc_findMax.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ Author:
#include "script_component.hpp"
SCRIPT(findMax);

private ["_index"];

if (!IS_ARRAY(_this)) exitWith {nil};
if (_this isEqualTo []) exitWith {nil};

params ["_max"];

private _index = 0;
_index = 0;

{
if (isNil "_x" || {(typeName _x) != (typeName 0)}) exitWith {_max = nil; _index = nil;};
Expand Down
5 changes: 3 additions & 2 deletions addons/arrays/fnc_findMin.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ Author:
#include "script_component.hpp"
SCRIPT(findMin);

private ["_index"];

if (!IS_ARRAY(_this)) exitWith {nil};
if (_this isEqualTo []) exitWith {nil};

params ["_min"];

private _index = 0;
_index = 0;

{
if (isNil "_x" || {(typeName _x) != (typeName 0)}) exitWith {_max = nil; _index = nil;};
Expand Down
15 changes: 10 additions & 5 deletions addons/arrays/fnc_reject.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@ SCRIPT(reject);

// ----------------------------------------------------------------------------

params ["_array", "_filterCode"];

private _result = [];
private "_result";
params ["_array","_filterCode"];

_result = [];
_result resize (count _array);
_rIdx = 0;
{
if !(_x call _filterCode) then {
_result pushBack _x;
_result set [_rIdx, _x];
INC(_rIdx);
};
} forEach _array;

_result
_result resize _rIdx;

_result;
15 changes: 10 additions & 5 deletions addons/arrays/fnc_select.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@ SCRIPT(select);

// ----------------------------------------------------------------------------

params ["_array", "_filterCode"];

private _result = [];
private "_result";
params ["_array","_filterCode"];

_result = [];
_result resize (count _array);
_rIdx = 0;
{
if (_x call _filterCode) then {
_result pushBack _x;
_result set [_rIdx, _x];
INC(_rIdx);
};
} forEach _array;

_result
_result resize _rIdx;

_result;
8 changes: 4 additions & 4 deletions addons/strings/fnc_capitalize.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ Author:
SCRIPT(capitalize);

// ----------------------------------------------------------------------------

private ["_charCount","_string1","_string2"];
params ["_string"];

private _charCount = count _string;
_charCount = count _string;
if (_charCount > 0) then {
// Take first Char and Upper case
private _string1 = (toUpper _string) select [0,1];
_string1 = (toUpper _string) select [0,1];
// Take rest and lower it
private _string2 = (toLower _string) select [1];
_string2 = (toLower _string) select [1];
// Compile String
_string = _string1 + _string2;
};
Expand Down
7 changes: 4 additions & 3 deletions addons/strings/fnc_find.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ SCRIPT(find);

params ["_haystack","_needle", ["_initialIndex",0]];

private _start = -1;
private _ret = -1;
private ["_ret", "_start", "_tempString"];
_start = -1;
_ret = -1;

if (typeName _haystack != "STRING") exitWith {
-1
Expand All @@ -53,7 +54,7 @@ if(_initialIndex < 1) then {
if(_initialIndex > (count _haystack) ) exitWith {
-1
};
private _tempString = [_haystack, _initialIndex, ((count _haystack) - _initialIndex)] call CBA_fnc_substring;
_tempString = [_haystack, _initialIndex, ((count _haystack) - _initialIndex)] call CBA_fnc_substring;
_ret = _tempString find _needle;
if(_ret > -1) then {
_ret = _ret + _initialIndex;
Expand Down

1 comment on commit c62948d

@commy2
Copy link
Contributor Author

@commy2 commy2 commented on c62948d Nov 27, 2015

Choose a reason for hiding this comment

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

awww shit. confused the repositories. sry

Please sign in to comment.