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);
#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
}
}
|
You should allow all of the following (<key, value>):
<string, int> <string, string> <int, string> <int, int> This would be very useful if you could make it more complete: 1. allow the scripter to set load factor, bucket count, etc. 2. set function which works like try_emplace 3. set function which sets iff the key exists |
// Get int value
new map:map = map_new();
map_emplace(map,"12","14");
new value[2];
map_find(map,"12",value,sizeof(value));
new intvalue = strval(value);
// Emplace int value
new value[2];
format(value,sizeof(value),"%d",10); // With the key you can do the same
map_emplace(map,"test",value);
|
Why you cannot use it like:
PHP Code:
2. I'll add to the next update 3. What? Explain pls |
|
If I have to convert every value to a string and vice-versa in PAWN why even use an unordered map?
Also it would be nice to be able to iterate through all elements. |
|
Hello,
nice woooorkks.. ? x) what's the interest of creating an hashed array ? its like iterator but hashed so ? |
so its an iterator system, i already used the system from y_less, its was really useful, but with a plugin it should be faster ? |
Ok
so its an iterator system, i already used the system from y_less, its was really useful, but with a plugin it should be faster ? but why hashing the data ? |