Jump to content
code34

OO_HASHMAP - Object Oriented Hashmap

Recommended Posts

Object Oriented Hashmap
Lastest version: 0.4 by Code34

 

Like to Donate ? Donate with paypal

 



Github: https://github.com/code34/oo_hashmap.Altis
Reference: http://forums.bistudio.com/showthread.php?167980-Object-Oriented-SQF-Scripting-and-Compiling

 

 

 



Description
OO HASHMAP is a class (object oriented) that permits to replace arma array with an hashmap object :)

Features:

 

 

 

 

 

 

Licence:
Under Gpl, you can share, modify, distribute this script but don't remove the licence and the name of the original author

Readme:

 

/*
Author: code34 nicolas_boiteux@yahoo.fr
Copyright (C) 2014 Nicolas BOITEUX

CLASS OO_HASMAP OBJECT

Interface reference
http://docs.oracle.com/javase/7/docs/api/java/util/HashMap.html

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

Create an hasmap object

Usage:
put the "oo_hashmap.sqf" and the "oop.h" files in your mission directory
put this code into your mission init.sqf
call compilefinal preprocessFileLineNumbers "oo_hasmap.sqf";

See example mission in directory: init.sqf

Licence:
You can share, modify, distribute this script but don't remove the licence and the name of the original author

logs:
0.3 - OO HASHMAP
- use key string now
- use missionnamespace instead entryset array
- remove useless code
- fix test init code & add some use cases
- fix function names typo
- remove slow searchindex function
0.2 - OO HASHMAP
- add documentation
- add performance improvements
- fix clear function
0.1 - OO HASHMAP - first release


Functions

clear()
Removes all of the mappings from this map.

containsKey(key)
Returns true if this map contains a mapping for the specified key.

containsValue(value)
Returns true if this map maps one or more keys to the specified value.

entrySet()
Returns a Set view of the mappings contained in this map.

get(key)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

isEmpty()
Returns true if this map contains no key-value mappings.

keySet()
Returns a Set view of the keys contained in this map.

put(key, value)
Associates the specified value with the specified key in this map.

remove(key)
Removes the mapping for the specified key from this map if present.

size()
Returns the number of key-value mappings in this map.


Examples

call compilefinal preprocessFileLineNumbers "oo_hashmap.sqf";

private ["_map", "_size", "_i", "_key", "_value"];

_map = ["new", []] call OO_HASHMAP;

_return = "isEmpty" call _map;
diag_log format["isempty %1", _return];

["put", ["toto", [3,7]]] call _map;
["put", ["tata", "turlututu"]] call _map;
["put", ["jp", "test du hashmap"]] call _map;

_return = ["containsKey", "toto"] call _map;
diag_log format["contains key toto %1", _return];

_return = ["containsValue", ["bullshit"]] call _map;
diag_log format["contains value bullshit %1", _return];

_return = ["containsValue", [[3,7]]] call _map;
diag_log format["contains value [3,7] %1", _return];

_return = "entrySet" call _map;
diag_log format["entryset %1", _return];

_return = ["get", "toto"] call _map;
diag_log format["get toto %1", _return];

_return = "isEmpty" call _map;
diag_log format["isempty %1", _return];

_return = "keySet" call _map;
diag_log format["keySet %1", _return];

_return = "size" call _map;
diag_log format["Size %1", _return];

["put", ["toto", [8,8]]] call _map;
["put", ["toto", [4,1]]] call _map;

_return = "keySet" call _map;
diag_log format["check for toto doublon, keySet %1", _return];

_return = ["get", "toto"] call _map;
diag_log format["after toto setting, get toto %1", _return];

["remove", "tata"] call _map;
diag_log "remove tata";

_return = ["containsKey", "tata"] call _map;
diag_log format["contains key tata %1", _return];

_return = "keySet" call _map;
diag_log format["after tata remove, keySet %1", _return];

_return = "entrySet" call _map;
diag_log format["after tata remove, entryset %1", _return];

"clear" call _map;

_return = "size" call _map;
diag_log format["Size %1 after clear", _return];

_return = "IsEmpty" call _map;
diag_log format["isempty %1", _return];
  • Thanks 1

Share this post


Link to post
Share on other sites

Release frontpaged on the Armaholic homepage.

================================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites

hi :)

just release a new version

0.2 - OO HASHMAP

- add documentation

- add performance improvements

- fix clear function

Share this post


Link to post
Share on other sites

New version frontpaged on the Armaholic homepage.

================================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites

Hi guys :)

just update the hashmap object:

0.3 - OO HASHMAP

- use key string now

- use missionnamespace instead entryset array

- remove useless code

- fix test init code & add some use cases

- fix function names typo

- remove slow searchindex function

Share this post


Link to post
Share on other sites

Hi :)

just add an hotfix

0.31 - OO HASHMAP

- hotfix for multiple hashmap instance

Share this post


Link to post
Share on other sites

New version frontpaged on the Armaholic homepage.

================================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites

Hi code24,

I think to take back your code for my framework. I noticed what to do for the license and your desire to keep your name on the code.

I will of course respect this and propose you the implementation on github so that you can see if it is ok.

Share this post


Link to post
Share on other sites

Hi Redbelette

 

No probs with this, the implementation will interest me for improvement, it can be merge directly on the main branch

 

note: if you build an OO framework, i can also help you on this point by little contribution

Share this post


Link to post
Share on other sites

Hi code34,

 

I am a java developer so I don't have to worry about using the oo but this is not the case for all missions maker. So I can't do an OO framework. On the other hand, I can leave the opportunity for those who wish to do so. A good framework always says yes to the user, right?

You will find here the implementation of the "cronjob" which uses the hashmap. It works great, thank you very much;)

https://github.com/RedBelette/TGV_MissionFramework_Template/tree/master/library/function/server/cronjob

 

You will find here your oo implementation :

https://github.com/RedBelette/TGV_MissionFramework_Template/tree/master/library/hpp/oo

 

You will find here your hashmap implementation :

https://github.com/RedBelette/TGV_MissionFramework_Template/tree/master/library/script/hashmap

 

Thanks you very much for that ;)

 

RedBelette

Share this post


Link to post
Share on other sites

Hello :)

 

just release the last version of hashmap

0.4 - improve performance with native arma array function

 

you are welcome Redbelette :)

Share this post


Link to post
Share on other sites

Hi code34, i will update with the last version as soon as possible and i inform you if it's ok or not ;)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×