31.12.2017, 10:34
(
Last edited by ShapeGaz; 01/01/2018 at 08:24 PM.
)
unordered_map for SA:MP
Description
This plugin allows you working with unordered_map
Natives
PHP Code:
native map:Map_New(type);
native Map_Emplace(type, map:map, keystring[]="",keyint=0,valuestring[]="",valueint=0);
native Map_Find(type, map:map, keystring[]="", keyint=0, dest[]="", size=sizeof dest);
native Map_Size(type, map:map);
native Map_Clear(type, map:map);
native Map_Erase(type, map:map, keystring[]="", keyint=0);
native Map_Empty(type, map:map);
native Map_Load_Factor(type, map:map);
native Map_Bucket_Count(type, map:map);
PHP Code:
#include <unordered_map>
main()
{
/*
Types:
Map_SS = <string,string>
Map_II = <int,int>
Map_SI = <string, int>
Map_IS = <int,string>
*/
// example code with <string, string>
new map:Map = Map_New(Map_SS); // Create a new map
Map_Emplace(Map_SS, Map, "hello", .valuestring="hi") // Insert a new element
new value[3];
if(Map_Find(Map_SS, Map, "hello", .dest=value) != -1) // Search our element
{
printf("Value: %s",value); // Output: Value: hi
}
// example code with <int,int>
new map:Map = Map_New(Map_II);
Map_Emplace(Map_II, Map, .keyint=45, .valueint=10);
new value = Map_Find(Map_II, Map, .keyint=45);
if(value != -1)
{
printf("Value: %d", value); // Output: Value: 10
}
// example code with <string,int>
new map:Map = Map_New(Map_SI);
Map_Emplace(Map_SI, Map, "number", .valueint=15);
new value = Map_Find(Map_SI, Map, "number");
if(value != -1)
{
printf("Value: %d",value); // Output: Value: 15
}
}
1. Download unordered_map from Releases page
2. Extract unordered_map.inc to pawno/include folder
3. In your mode include unordered_map.inc
4. Extract unordered_map.dll or unordered_map.so to plugins folder
5. In the server.cfg on line plugins add unordered_map.dll or unordered_map.so
Releases:
https://github.com/AnveSamp/unordered_map/releases
Source code:
https://github.com/AnveSamp/unordered_map
Happy new year