-
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
Add Function to retrieve all Keys in a Hash #590
Conversation
addons/hashes/CfgFunctions.hpp
Outdated
// CBA_fnc_hashGetKeys | ||
class hashGetKeys | ||
{ | ||
description = "Returns all the Keys in a Hash"; |
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.
Returns all the Keys in a Hash .
addons/hashes/fnc_hashGetKeys.sqf
Outdated
Function: CBA_fnc_hashGetKeys | ||
|
||
Description: | ||
Returns all the Keys in a Hash |
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.
Same as above.
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.
Please add 2 or 3 examples to test_hashes.sqf
. Thanks.
My imagination to make up tests is not that good. |
test fails, because of this line: |
Also put a period after "Returns all the Keys in a Hash" while you're at it. Thanks. |
All the pointy things! |
execVM "\x\cba\addons\hashes\test_hashes.sqf"
|
addons/hashes/test_hashes.sqf
Outdated
[_hash, "123", 1] call CBA_fnc_hashSet; | ||
[_hash, "124", 2] call CBA_fnc_hashSet; | ||
[_hash, 125, 3] call CBA_fnc_hashSet; | ||
_keys = [_hash] call CBA_fnc_hashSize; |
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.
CBA_fnc_hashGetKeys
addons/hashes/test_hashes.sqf
Outdated
[_hash, "124", 2] call CBA_fnc_hashSet; | ||
[_hash, 125, 3] call CBA_fnc_hashSet; | ||
_keys = [_hash] call CBA_fnc_hashSize; | ||
TEST_OP(_keys,isEqualTo,[ARR_3("123","124",125)],"hashSize"); |
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.
"hashGetKeys"
Should this function be called |
I thought about that. But with getKeys it's more clear that you get something IMO. |
Thats what you get for copy pasting stuff. |
|
addons/hashes/fnc_hashGetKeys.sqf
Outdated
// ----------------------------------------------------------------------------- | ||
params [["_hash", [[], []], [[]]]]; | ||
|
||
(_hash select HASH_KEYS) |
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.
newline @ EOF
Should this array be copied?
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.
What?! I swear I have asked if you think it should be copied. Apparently I thought of it but never did it. My brain is smoosh. Yeah.. Copy is probably better But there may also be a use for byref
89ae448
to
8c708ea
Compare
Should finally be all fine now. Except maybe renaming it to hashKeys. Your decision. |
Now you put two newlines at the end. |
I'd prefer |
Add pointy things Add Tests
I'll never make a small CBA function again. It's too much hassle ^^ |
addons/hashes/test_hashes.sqf
Outdated
[_hash, "124", 2] call CBA_fnc_hashSet; | ||
[_hash, 125, 3] call CBA_fnc_hashSet; | ||
_keys = [_hash] call CBA_fnc_hashKeys; | ||
TEST_OP(_keys,isEqualTo,[ARR_3("123","124",125)],"hashGetKeys"); |
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.
hashKeys
addons/hashes/test_hashes.sqf
Outdated
// Empty hash keys | ||
_hash = [] call CBA_fnc_hashCreate; | ||
_keys = [_hash] call CBA_fnc_hashKeys; | ||
TEST_OP(_keys,isEqualTo,[],"hashGetKeys"); |
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.
hashKeys
I could've fixed it all in one go if I had push access to your branch. Maybe a secondary PR next time... |
Edits from maintainers are allowed :x So you should have access |
lol |
I am currently doing
params ["", "_keys"]
to get the keys of a hash.But that might break if the internal structure changes.
So rather have a offical API function for that.