-
Notifications
You must be signed in to change notification settings - Fork 19
Pool natives
native Pool:pool_new(capacity=-1, bool:ordered=false);
Creates a new pool, optionally with an initial capacity.
native pool_delete(Pool:pool);
Deletes a pool and frees its memory. Required after you're done with the object.
native pool_delete_deep(Pool:pool);
Deletes a pool and frees its memory together with all resources it may contain.
native bool:pool_valid(Pool:pool);
Returns true if the pool pointer is valid.
native pool_clear(Pool:pool);
Removes all elements in the pool.
native pool_clear_deep(Pool:pool);
Removes all elements in the pool and frees all memory owned by them.
native Pool:pool_clone(Pool:pool);
Clones a pool and all the data it contains (deep copy).
native pool_set_ordered(Pool:pool, bool:ordered);
Changes the internal structure of the pool. An ordered pool uses a tree to mark unused ranges of slots, whereas an unordered map uses a linked list.
native bool:pool_is_ordered(Pool:pool);
Returns true if the pool is ordered, or false if the pool is unordered.
native pool_size(Pool:pool);
Returns the number of elements in the pool.
native pool_capacity(Pool:pool);
Returns the capacity of the pool, i.e. the number of elements that can be added without enlarging the internal buffer and invalidating iterators.
native pool_add(Pool:pool, AnyTag:value, TagTag:tag_id=tagof(value));
native pool_add_arr(Pool:pool, const AnyTag:value[], size=sizeof(value), TagTag:tag_id=tagof(value));
native pool_add_str(Pool:pool, const value[]);
native pool_add_str_s(Pool:pool, ConstStringTag:value);
native pool_add_var(Pool:pool, ConstVariantTag:value);
Adds a new elements to a pool, constructed either from a single value, an array, a string, or a variant. Returns the index of the element.
native bool:pool_remove(Pool:pool, index);
Removes an element from the pool at a specific index. A gap will be created at the index. Returns true if the element was removed, or false if there was no element at that index.
native bool:pool_remove_deep(Pool:pool, index);
Removes an element from the pool at a specific index, and frees all resources held by the element. A gap will be created at the index. Returns true if the element was removed, or false if there was no element at that index.
native bool:pool_has(Pool:pool, index);
Returns true if the pool contains an element at the specific index, false otherwise.
native pool_get(Pool:pool, index, offset=0);
native pool_get_arr(Pool:pool, index, AnyTag:value[], size=sizeof(value));
native pool_get_str(Pool:pool, index, value[], size=sizeof(value)) = pool_get_arr;
native String:pool_get_str_s(Pool:pool, index);
native Variant:pool_get_var(Pool:pool, index);
native bool:pool_get_safe(Pool:pool, index, &AnyTag:value, offset=0, TagTag:tag_id=tagof(value));
native pool_get_arr_safe(Pool:pool, index, AnyTag:value[], size=sizeof(value), TagTag:tag_id=tagof(value));
native pool_get_str_safe(Pool:pool, index, value[], size=sizeof(value));
native String:pool_get_str_safe_s(Pool:pool, index);
Returns the value of an element in a pool at a specific index. The safe
versions check the tag of the output. Other semantics same as for variants.
native pool_set(Pool:pool, index, AnyTag:value, TagTag:tag_id=tagof(value));
native pool_set_arr(Pool:pool, index, const AnyTag:value[], size=sizeof(value), TagTag:tag_id=tagof(value));
native pool_set_str(Pool:pool, index, const value[]);
native pool_set_str_s(Pool:pool, index, ConstStringTag:value);
native pool_set_var(Pool:pool, index, ConstVariantTag:value);
Replaces a value at a specific position in a pool with a new one. If there is no value at the specific index, the new value is inserted there.
native pool_set_cell(Pool:pool, index, offset, AnyTag:value);
native bool:pool_set_cell_safe(Pool:pool, index, offset, AnyTag:value, TagTag:tag_id=tagof(value));
Sets the value of a single cell in an array stored in the pool. The safe
version checks if the tags are compatible.
native pool_resize(Pool:pool, newsize);
Changes the capacity of the pool to newsize
. Elements at indices starting from newsize
will be removed from the pool.
native pool_reserve(Pool:pool, capacity);
Increases the capacity of the pool.
native pool_find(Pool:pool, AnyTag:value, TagTag:tag_id=tagof(value));
native pool_find_arr(Pool:pool, const AnyTag:value[], size=sizeof(value), TagTag:tag_id=tagof(value));
native pool_find_str(Pool:pool, const value[]);
native pool_find_str_s(Pool:pool, ConstStringTag:value);
native pool_find_var(Pool:pool, ConstVariantTag:value);
Finds the first element equal to value
in the pool and returns its index. Returns -1 if the element was not found.
native pool_find_if(Pool:pool, Expression:pred);
Finds the first element that satisfies pred
, and returns its index, or -1 if no such element is present in the pool.
native pool_count(Pool:pool, AnyTag:value, TagTag:tag_id=tagof(value));
native pool_count_arr(Pool:pool, const AnyTag:value[], size=sizeof(value), TagTag:tag_id=tagof(value));
native pool_count_str(Pool:pool, const value[]);
native pool_count_str_s(Pool:pool, ConstStringTag:value);
native pool_count_var(Pool:pool, ConstVariantTag:value);
Counts the number of occurences of a specific element.
native pool_count_if(Pool:pool, Expression:pred);
Counts the number of elements in the pool that satisfy pred
.
native pool_tagof(Pool:pool, index);
Returns the tag of an element in the pool.
native pool_sizeof(Pool:pool, index);
Returns the size of an element in the pool.
native Iter:pool_iter(Pool:pool, index=0);
Creates a new iterator pointing to an element in the pool.
native Iter:pool_iter_at(Pool:pool, index);
Creates a new iterator pointing to a specific element in the pool.