-
Notifications
You must be signed in to change notification settings - Fork 148
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
Update some array functions #635
Conversation
approx 10x faster
added a new feature, removed the old warning
addons/arrays/fnc_findMin.sqf
Outdated
|
||
[_min, _array find _min] | ||
private _max = selectMin _array; | ||
[_max, _array find _max] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable name should still be _min
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c&p, fixed
addons/arrays/fnc_shuffle.sqf
Outdated
[] + _this; | ||
}; | ||
}; | ||
_this params [["_array",[],[[]]],["_inPlace",false,[false]]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The _this
is superfluous as it's the variable used by the default unary syntax of params
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just personal style, the compiler is adding it anyways
I can remove it, if you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Arma compiler does not add _this
to the unary syntax of params
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I don't know why I was thinking this.
addons/arrays/fnc_select.sqf
Outdated
} forEach _array; | ||
|
||
_result | ||
_array select {_x call _filterCode} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the function no longer support _forEachIndex
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh, I remember. I'll remove.
This reverts commit 68a3a6e.
Re |
So mark them as deprecated and revert fc75b17 too? |
I'd say yes. |
addons/arrays/fnc_shuffle.sqf
Outdated
If (_inPlace) then { | ||
for "_size" from (count _tempArray) to 1 step -1 do { | ||
_array set [_size-1,(_tempArray deleteAt (floor random _size))]; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we still return the array here?
^ please change the tests in a separate pull request. This is to make sure that potential errors aren't missed. |
This reverts commit 7fb6a3b.
Alright. |
|
This pull request drops support for the deprecated syntax of the function: // Support the deprecated parameter style: [1, 2, 3, 4, 5] call CBA_fnc_shuffle.
_tempArray = if (count _this != 1) then {
WARNING("CBA_fnc_shuffle requires an array as first parameter, not just a direct array: " + str _this);
[] + _this;
} else {
if (IS_ARRAY(_this select 0)) then {
[] + (_this select 0); // Correct params passed.
} else {
WARNING("CBA_fnc_shuffle requires an array as first parameter, not just a direct array: " + str _this);
[] + _this;
};
}; |
fix some spacing - OCD
* new shuffle test #635 * Keeping the old test
select update