-
Notifications
You must be signed in to change notification settings - Fork 18
Map natives
native Map:map_new(bool:ordered=false);
#define map_new_args(%0) map_new_args_packed(_PP@TAGGED_PACK(%0))
#define map_new_args_str(%0) map_new_args_str_packed(_PP@TAGGED1_PACK(%0))
#define map_new_args_var(%0) map_new_args_var_packed(_PP@TAGGED1_PACK(%0))
#define map_new_str_args(%0) map_new_str_args_packed(_PP@TAGGED2_PACK(%0))
native Map:map_new_str_args_str(arg0[], arg1[], ...);
native Map:map_new_str_args_var(arg0[], ConstVariantTag:arg1, {_,VariantTags}:...);
#define map_new_var_args(%0) map_new_var_args_packed(_PP@TAGGED2_PACK(%0))
native Map:map_new_var_args_str(ConstVariantTag:arg0, arg1[], {_,VariantTags}:...);
native Map:map_new_var_args_var(ConstVariantTag:arg0, ConstVariantTag:arg1, ConstVariantTag:...);
Creates a new map, optionally from the argument list, each key followed by its value.
native map_delete(Map:map);
Deletes a map and frees its memory. Must be called when you are done with the object.
native map_delete_deep(Map:map);
Deletes a map and frees its memory, together with the resources it may contain.
native Map:map_clone(Map:map);
Clones a map and all the data it contains (deep copy).
native bool:map_valid(Map:map);
Returns true if the map pointer is valid.
native map_clear(Map:map);
Removes all pairs in the map.
native map_clear_deep(Map:map);
Removes all pairs in the map and frees all memory owned by them.
native map_set_ordered(Map:map, bool:ordered);
Changes the internal structure of the map. An ordered map uses a binary search tree to find the elements, whereas an unordered map is a hash table.
native bool:map_is_ordered(Map:map);
Returns true if the map is ordered, or false if the map is unordered.
native map_size(Map:map);
Returns the number of records in a map.
native map_capacity(Map:map);
Returns the number of new records that can be added to the map before all iterators that point inside are invalidated. This value is not usable for ordered map.
native map_reserve(Map:map, capacity);
Resizes the internal buffer to hold capacity
records. If the new capacity is larger than the old one, all iterators that point inside the map are invalidated.
native bool:map_add(Map:map, AnyTag:key, AnyTag:value, TagTag:key_tag_id=tagof(key), TagTag:value_tag_id=tagof(value));
native bool:map_add_arr(Map:map, AnyTag:key, const AnyTag:value[], value_size=sizeof(value), TagTag:key_tag_id=tagof(key), TagTag:value_tag_id=tagof(value));
native bool:map_add_str(Map:map, AnyTag:key, const value[], TagTag:key_tag_id=tagof(key));
native bool:map_add_str_s(Map:map, AnyTag:key, ConstStringTag:value, TagTag:key_tag_id=tagof(key));
native bool:map_add_var(Map:map, AnyTag:key, ConstVariantTag:value, TagTag:key_tag_id=tagof(key));
native bool:map_arr_add(Map:map, const AnyTag:key[], AnyTag:value, key_size=sizeof(key), TagTag:key_tag_id=tagof(key), TagTag:value_tag_id=tagof(value));
native bool:map_arr_add_arr(Map:map, const AnyTag:key[], const AnyTag:value[], key_size=sizeof(key), value_size=sizeof(value), TagTag:key_tag_id=tagof(key), TagTag:value_tag_id=tagof(value));
native bool:map_arr_add_str(Map:map, const AnyTag:key[], const value[], key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native bool:map_arr_add_str_s(Map:map, const AnyTag:key[], ConstStringTag:value, key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native bool:map_arr_add_var(Map:map, const AnyTag:key[], ConstVariantTag:value, key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native bool:map_str_add(Map:map, const key[], AnyTag:value, TagTag:value_tag_id=tagof(value));
native bool:map_str_add_arr(Map:map, const key[], const AnyTag:value[], value_size=sizeof(value), TagTag:value_tag_id=tagof(value));
native bool:map_str_add_str(Map:map, const key[], const value[]);
native bool:map_str_add_str_s(Map:map, const key[], ConstStringTag:value);
native bool:map_str_add_var(Map:map, const key[], ConstVariantTag:value);
native bool:map_str_s_add(Map:map, ConstStringTag:key, AnyTag:value, TagTag:value_tag_id=tagof(value));
native bool:map_str_s_add_arr(Map:map, ConstStringTag:key, const AnyTag:value[], value_size=sizeof(value), TagTag:value_tag_id=tagof(value));
native bool:map_str_s_add_str(Map:map, ConstStringTag:key, const value[]);
native bool:map_str_s_add_str_s(Map:map, ConstStringTag:key, ConstStringTag:value);
native bool:map_str_s_add_var(Map:map, ConstStringTag:key, VariantTag:value);
native bool:map_var_add(Map:map, ConstVariantTag:key, AnyTag:value, TagTag:value_tag_id=tagof(value));
native bool:map_var_add_arr(Map:map, ConstVariantTag:key, const AnyTag:value[], value_size=sizeof(value), TagTag:value_tag_id=tagof(value));
native bool:map_var_add_str(Map:map, ConstVariantTag:key, const value[]);
native bool:map_var_add_str_s(Map:map, VariantTag:key, ConstStringTag:value);
native bool:map_var_add_var(Map:map, ConstVariantTag:key, ConstVariantTag:value);
#define map_add_args(%0,%1) map_add_args_packed(%0,_PP@TAGGED_PACK(%1))
#define map_add_args_str(%0,%1) map_add_args_str_packed(%0,_PP@TAGGED1_PACK(%1))
#define map_add_args_var(%0,%1) map_add_args_var_packed(%0,_PP@TAGGED1_PACK(%1))
#define map_add_str_args(%0,%1) map_add_str_args_packed(%0,_PP@TAGGED2_PACK(%1))
native map_add_str_args_str(Map:map, arg0[], arg1[], ...);
native map_add_str_args_var(Map:map, arg0[], ConstVariantTag:arg1, {_,VariantTags}:...);
#define map_add_var_args(%0,%1) map_add_var_args_packed(%0,_PP@TAGGED2_PACK(%1))
native map_add_var_args_str(Map:map, ConstVariantTag:arg0, arg1[], {_,VariantTags}:...);
native map_add_var_args_var(Map:map, ConstVariantTag:arg0, ConstVariantTag:arg1, ConstVariantTag:...);
Creates a new record the map, specifying the key and the value. Returns true if the insertion was successful (i.e. no record with the same key was present). The key and the value can be constructed from a single cell, an array, a string, or a variant.
native map_add_map(Map:map, Map:other, bool:overwrite);
Copies the records from other
to map
. If overwrite
is true, it will overwrite the values if they are paired with a key from other
. Returns the number of newly added pairs.
native bool:map_remove(Map:map, AnyTag:key, TagTag:key_tag_id=tagof(key));
native bool:map_arr_remove(Map:map, const AnyTag:key[], key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native bool:map_str_remove(Map:map, const key[]);
native bool:map_str_s_remove(Map:map, ConstStringTag:key);
native bool:map_var_remove(Map:map, ConstVariantTag:key);
native bool:map_remove_deep(Map:map, AnyTag:key, TagTag:key_tag_id=tagof(key));
native bool:map_arr_remove_deep(Map:map, const AnyTag:key[], key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native bool:map_str_remove_deep(Map:map, const key[]);
native bool:map_str_s_remove_deep(Map:map, ConstStringTag:key);
native bool:map_var_remove_deep(Map:map, ConstVariantTag:key);
Removes a record from a map, specified by its key. Returns true if the record was removed, false otherwise.
native map_remove_if(Map:map, Expression:pred);
native map_remove_if_deep(Map:map, Expression:pred);
Removes all records in the map that satisfy pred
.
native bool:map_has_key(Map:map, AnyTag:key, TagTag:key_tag_id=tagof(key));
native bool:map_has_arr_key(Map:map, const AnyTag:key[], key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native bool:map_has_str_key(Map:map, const key[]);
native bool:map_has_str_s_key(Map:map, ConstStringTag:key);
native bool:map_has_var_key(Map:map, ConstVariantTag:key);
Determines whether a record specified by its key exists in a map.
native map_get(Map:map, AnyTag:key, offset=0, TagTag:key_tag_id=tagof(key));
native map_get_arr(Map:map, AnyTag:key, AnyTag:value[], value_size=sizeof(value), TagTag:key_tag_id=tagof(key));
native map_get_str(Map:map, AnyTag:key, value[], value_size=sizeof(value), TagTag:key_tag_id=tagof(key)) = map_get_arr;
native String:map_get_str_s(Map:map, AnyTag:key, TagTag:key_tag_id=tagof(key));
native Variant:map_get_var(Map:map, AnyTag:key, TagTag:key_tag_id=tagof(key));
native bool:map_get_safe(Map:map, AnyTag:key, &AnyTag:value, offset=0, TagTag:key_tag_id=tagof(key), TagTag:value_tag_id=tagof(value));
native map_get_arr_safe(Map:map, AnyTag:key, AnyTag:value[], value_size=sizeof(value), TagTag:key_tag_id=tagof(key), TagTag:value_tag_id=tagof(value));
native map_get_str_safe(Map:map, AnyTag:key, value[], value_size=sizeof(value), TagTag:key_tag_id=tagof(key));
native String:map_get_str_safe_s(Map:map, AnyTag:key, TagTag:key_tag_id=tagof(key));
native map_arr_get(Map:map, const AnyTag:key[], offset=0, key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native map_arr_get_arr(Map:map, const AnyTag:key[], AnyTag:value[], value_size=sizeof(value), key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native map_arr_get_str(Map:map, const AnyTag:key[], AnyTag:value[], value_size=sizeof(value), key_size=sizeof(key), TagTag:key_tag_id=tagof(key)) = map_arr_get_arr;
native String:map_arr_get_str_s(Map:map, const AnyTag:key[], key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native Variant:map_arr_get_var(Map:map, const AnyTag:key[], key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native bool:map_arr_get_safe(Map:map, const AnyTag:key[], &AnyTag:value, offset=0, key_size=sizeof(key), TagTag:key_tag_id=tagof(key), TagTag:value_tag_id=tagof(value));
native map_arr_get_arr_safe(Map:map, const AnyTag:key[], AnyTag:value[], value_size=sizeof(value), key_size=sizeof(key), TagTag:key_tag_id=tagof(key), TagTag:value_tag_id=tagof(value));
native map_arr_get_str_safe(Map:map, const AnyTag:key[], value[], value_size=sizeof(value), key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native String:map_arr_get_str_safe_s(Map:map, const AnyTag:key[], key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native map_str_get(Map:map, const key[], offset=0);
native map_str_get_arr(Map:map, const key[], AnyTag:value[], value_size=sizeof(value));
native map_str_get_str(Map:map, const key[], value[], value_size=sizeof(value)) = map_str_get_arr;
native String:map_str_get_str_s(Map:map, const key[]);
native Variant:map_str_get_var(Map:map, const key[]);
native bool:map_str_get_safe(Map:map, const key[], &AnyTag:value, offset=0, TagTag:value_tag_id=tagof(value));
native map_str_s_get(Map:map, ConstStringTag:key, offset=0);
native map_str_s_get_arr(Map:map, ConstStringTag:key, AnyTag:value[], value_size=sizeof(value));
native String:map_str_s_get_str_s(Map:map, ConstStringTag:key);
native Variant:map_str_s_get_var(Map:map, ConstStringTag:key);
native bool:map_str_s_get_safe(Map:map, ConstStringTag:key, &AnyTag:value, offset=0, TagTag:value_tag_id=tagof(value));
native map_str_s_get_arr_safe(Map:map, ConstStringTag:key, AnyTag:value[], value_size=sizeof(value), TagTag:value_tag_id=tagof(value));
native map_str_s_get_str_safe(Map:map, ConstStringTag:key, value[], value_size=sizeof(value));
native String:map_str_s_get_str_safe_s(Map:map, ConstStringTag:key);
native map_str_get_arr_safe(Map:map, const key[], AnyTag:value[], value_size=sizeof(value), TagTag:value_tag_id=tagof(value));
native map_str_get_str_safe(Map:map, const key[], value[], value_size=sizeof(value));
native String:map_str_get_str_safe_s(Map:map, const key[]);
native map_var_get(Map:map, ConstVariantTag:key, offset=0);
native map_var_get_arr(Map:map, ConstVariantTag:key, AnyTag:value[], value_size=sizeof(value));
native map_var_get_str(Map:map, ConstVariantTag:key, AnyTag:value[], value_size=sizeof(value)) = map_var_get_arr;
native String:map_var_get_str_s(Map:map, ConstVariantTag:key);
native Variant:map_var_get_var(Map:map, ConstVariantTag:key);
native bool:map_var_get_safe(Map:map, ConstVariantTag:key, &AnyTag:value, offset=0, TagTag:value_tag_id=tagof(value));
native map_var_get_arr_safe(Map:map, ConstVariantTag:key, AnyTag:value[], value_size=sizeof(value), TagTag:value_tag_id=tagof(value));
native map_var_get_str_safe(Map:map, ConstVariantTag:key, value[], value_size=sizeof(value));
native String:map_var_get_str_safe_s(Map:map, ConstVariantTag:key);
Obtains the value specified by its key from a map.
native map_set(Map:map, AnyTag:key, AnyTag:value, TagTag:key_tag_id=tagof(key), TagTag:value_tag_id=tagof(value));
native map_set_arr(Map:map, AnyTag:key, const AnyTag:value[], value_size=sizeof(value), TagTag:key_tag_id=tagof(key), TagTag:value_tag_id=tagof(value));
native map_set_str(Map:map, AnyTag:key, const value[], TagTag:key_tag_id=tagof(key));
native map_set_str_s(Map:map, AnyTag:key, ConstStringTag:value, TagTag:key_tag_id=tagof(key));
native map_set_var(Map:map, AnyTag:key, ConstVariantTag:value, TagTag:key_tag_id=tagof(key));
TagTag:value_tag_id=tagof(value));
native map_arr_set(Map:map, const AnyTag:key[], AnyTag:value, key_size=sizeof(key), TagTag:key_tag_id=tagof(key), TagTag:value_tag_id=tagof(value));
native map_arr_set_arr(Map:map, const AnyTag:key[], const AnyTag:value[], value_size=sizeof(value), key_size=sizeof(key), TagTag:key_tag_id=tagof(key), TagTag:value_tag_id=tagof(value));
native map_arr_set_str(Map:map, const AnyTag:key[], const value[], key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native map_arr_set_str_s(Map:map, const AnyTag:key[], ConstStringTag:value, key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native map_arr_set_var(Map:map, const AnyTag:key[], ConstVariantTag:value, key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native map_str_set(Map:map, const key[], AnyTag:value, TagTag:value_tag_id=tagof(value));
native map_str_set_arr(Map:map, const key[], const AnyTag:value[], value_size=sizeof(value), TagTag:value_tag_id=tagof(value));
native map_str_set_str(Map:map, const key[], const value[]);
native map_str_set_str_s(Map:map, const key[], ConstStringTag:value);
native map_str_set_var(Map:map, const key[], ConstVariantTag:value);
native map_str_s_set(Map:map, ConstStringTag:key, AnyTag:value, TagTag:value_tag_id=tagof(value));
native map_str_s_set_arr(Map:map, ConstStringTag:key, const AnyTag:value[], value_size=sizeof(value), TagTag:value_tag_id=tagof(value));
native map_str_s_set_str(Map:map, ConstStringTag:key, const value[]);
native map_str_s_set_str_s(Map:map, ConstStringTag:key, ConstStringTag:value);
native map_str_s_set_var(Map:map, ConstStringTag:key, VariantTag:value);
native map_var_set(Map:map, ConstVariantTag:key, AnyTag:value, TagTag:value_tag_id=tagof(value));
native map_var_set_arr(Map:map, ConstVariantTag:key, const AnyTag:value[], value_size=sizeof(value), TagTag:value_tag_id=tagof(value));
native map_var_set_str(Map:map, ConstVariantTag:key, const value[]);
native map_var_set_str_s(Map:map, VariantTag:key, ConstStringTag:value);
native map_var_set_var(Map:map, ConstVariantTag:key, ConstVariantTag:value);
Sets the value for a specific key in a map, or adds a new one if it doesn't exist.
native map_set_cell(Map:map, AnyTag:key, offset, AnyTag:value, TagTag:key_tag_id=tagof(key));
native bool:map_set_cell_safe(Map:map, AnyTag:key, offset, AnyTag:value, TagTag:key_tag_id=tagof(key), native map_arr_set_cell(Map:map, const AnyTag:key[], offset, AnyTag:value, key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native bool:map_arr_set_cell_safe(Map:map, const AnyTag:key[], offset, AnyTag:value, key_size=sizeof(key), TagTag:key_tag_id=tagof(key), TagTag:value_tag_id=tagof(value));
native map_str_set_cell(Map:map, const key[], offset, AnyTag:value);
native bool:map_str_set_cell_safe(Map:map, const key[], offset, AnyTag:value, TagTag:value_tag_id=tagof(value));
native map_str_s_set_cell(Map:map, ConstStringTag:key, offset, AnyTag:value);
native bool:map_str_s_set_cell_safe(Map:map, ConstStringTag:key, offset, AnyTag:value, TagTag:value_tag_id=tagof(value));
native map_var_set_cell(Map:map, ConstVariantTag:key, offset, AnyTag:value);
native bool:map_var_set_cell_safe(Map:map, ConstVariantTag:key, offset, AnyTag:value, TagTag:value_tag_id=tagof(value));
Sets the value of a single cell in an array specified by its key in a map.
native map_key_at(Map:map, index, offset=0);
native map_arr_key_at(Map:map, index, AnyTag:key[], key_size=sizeof(key));
native Variant:map_var_key_at(Map:map, index);
native bool:map_key_at_safe(Map:map, index, &AnyTag:key, offset=0, TagTag:key_tag_id=tagof(key));
native map_arr_key_at_safe(Map:map, index, AnyTag:key[], key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
Returns the key located at a specific numerical index in a map. Not very good for enumerating.
native map_value_at(Map:map, index, offset=0);
native map_arr_value_at(Map:map, index, AnyTag:value[], value_size=sizeof(value));
native Variant:map_var_value_at(Map:map, index);
native bool:map_value_at_safe(Map:map, index, &AnyTag:value, offset=0, TagTag:value_tag_id=tagof(value));
native map_arr_value_at_safe(Map:map, index, AnyTag:value[], value_size=sizeof(value), TagTag:key_tag_id=tagof(value));
Returns the value located at a specific numerical index in a map.
native map_count(Map:map, AnyTag:value, TagTag:tag_id=tagof(value));
native map_count_arr(Map:map, const AnyTag:value[], size=sizeof(value), TagTag:tag_id=tagof(value));
native map_count_str(Map:map, const value[]);
native map_count_str_s(Map:map, ConstStringTag:value);
native map_count_var(Map:map, ConstVariantTag:value);
Counts the number of values in the map.
native map_count_if(Map:map, Expression:pred);
Counts the number of records in the map that satisfy pred
.
native map_tagof(Map:map, AnyTag:key, TagTag:key_tag_id=tagof(key));
native map_arr_tagof(Map:map, const AnyTag:key[], key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native map_str_tagof(Map:map, const key[]);
native map_str_s_tagof(Map:map, ConstStringTag:key);
native map_var_tagof(Map:map, ConstVariantTag:key);
Returns the tag of a value specified by its key in a map.
native map_sizeof(Map:map, AnyTag:key, TagTag:key_tag_id=tagof(key));
native map_arr_sizeof(Map:map, const AnyTag:key[], key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native map_str_sizeof(Map:map, const key[]);
native map_str_s_sizeof(Map:map, ConstStringTag:key);
native map_var_sizeof(Map:map, ConstVariantTag:key);
Returns the size of a value specified by its key in a map.
native Iter:map_iter(Map:map, index=0);
Creates a new iterator pointing at the first key-value pair in the map (unordered).
native Iter:map_iter_at(Map:map, AnyTag:key, TagTag:key_tag_id=tagof(key));
native Iter:map_iter_at_arr(Map:map, const AnyTag:key[], key_size=sizeof(key), TagTag:key_tag_id=tagof(key));
native Iter:map_iter_at_str(Map:map, const key[]);
native Iter:map_iter_at_str_s(Map:map, ConstStringTag:key);
native Iter:map_iter_at_var(Map:map, ConstVariantTag:key);
Creates a new iterator pointing at a record identified by its key.