-
Notifications
You must be signed in to change notification settings - Fork 19
Linked list natives
native LinkedList:linked_list_new();
native LinkedList:linked_list_new_arr(AnyTag:values[], size=sizeof(values), TagTag:tag_id=tagof(values));
#define linked_list_new_args(%0) linked_list_new_args_packed(_PP@TAGGED_PACK(%0))
native LinkedList:linked_list_new_args_str(arg0[], ...);
native LinkedList:linked_list_new_args_var(ConstVariantTag:arg0, ConstVariantTag:...);
Creates a new linked list, optionally from an array of values (must be properly tagged), or an argument list.
native linked_list_delete(LinkedList:linked_list);
Deletes a linked list and frees its memory. Required after you're done with the object.
native linked_list_delete_deep(LinkedList:linked_list);
Deletes a linked list and frees its memory together with all resources it may contain.
native bool:linked_list_valid(LinkedList:linked_list);
Returns true if the linked list pointer is valid.
native linked_list_clear(LinkedList:linked_list);
Removes all elements in the linked list.
native linked_list_clear_deep(LinkedList:linked_list);
Removes all elements in the linked list and frees all memory owned by them.
native LinkedList:linked_list_clone(LinkedList:linked_list);
Clones a linked list and all the data it contains (deep copy). You can use linked_list_add_linked_list
to copy only the values.
native linked_list_size(LinkedList:linked_list);
Returns the number of elements in the linked list.
native linked_list_add(LinkedList:linked_list, AnyTag:value, index=-1, TagTag:tag_id=tagof(value));
native linked_list_add_arr(LinkedList:linked_list, const AnyTag:value[], index=-1, size=sizeof(value), TagTag:tag_id=tagof(value));
native linked_list_add_str(LinkedList:linked_list, const value[], index=-1);
native linked_list_add_str_s(LinkedList:linked_list, ConstStringTag:value, index=-1);
native linked_list_add_var(LinkedList:linked_list, ConstVariantTag:value, index=-1);
Adds new elements to a linked list, constructed either from a single value, an array, a string, or a variant, or a list thereof. Optionally, index
can be used to specify the position of the new element in the list. Returns the index of the element.
#define linked_list_add_args(%0,%1) linked_list_add_args_packed(%0,_PP@TAGGED_PACK(%1))
native linked_list_add_args_str(LinkedList:linked_list, arg0[], ...);
native linked_list_add_args_var(LinkedList:linked_list, ConstVariantTag:arg0, ConstVariantTag:...);
Adds the passed arguments to the linked list as its elements. Returns the number of added elements.
native linked_list_add_linked_list(LinkedList:linked_list, LinkedList:range, index=-1);
Copies values from one linked list into another. Returns the index where the values from range
start in list
.
native linked_list_add_iter(LinkedList:linked_list, Iter:iter, index=-1);
Copies all remaining values from the iterator to the linked list. Returns the index where the values start.
native linked_list_remove(LinkedList:linked_list, index);
Removes an element from the linked list at a specific index. The following values are moved to fill the gap.
native linked_list_remove_deep(LinkedList:linked_list, index);
Removes an element from the linked list at a specific index, and frees all resources held by the element. The following values are moved to fill the gap.
native linked_list_remove_if(LinkedList:linked_list, Expression:pred);
Removes all elements that satisfy pred
.
native linked_list_remove_if_deep(LinkedList:linked_list, Expression:pred);
Removes all elements that satisfy pred
, and frees all resources held by them.
native linked_list_get(LinkedList:linked_list, index, offset=0);
native linked_list_get_arr(LinkedList:linked_list, index, AnyTag:value[], size=sizeof(value));
native linked_list_get_str(LinkedList:linked_list, index, AnyTag:value[], size=sizeof(value)) = linked_list_get_arr;
native String:linked_list_get_str_s(LinkedList:linked_list, index);
native Variant:linked_list_get_var(LinkedList:linked_list, index);
native bool:linked_list_get_safe(LinkedList:linked_list, index, &AnyTag:value, offset=0, TagTag:tag_id=tagof(value));
native linked_list_get_arr_safe(LinkedList:linked_list, index, AnyTag:value[], size=sizeof(value), TagTag:tag_id=tagof(value));
native linked_list_get_str_safe(LinkedList:linked_list, index, value[], size=sizeof(value));
native String:linked_list_get_str_safe_s(LinkedList:linked_list, index);
Returns the value of an element in a linked list, at a specific index. The safe
versions check the tag of the output. Other semantics same as for variants.
native linked_list_set(LinkedList:linked_list, index, AnyTag:value, TagTag:tag_id=tagof(value));
native linked_list_set_arr(LinkedList:linked_list, index, const AnyTag:value[], size=sizeof(value), TagTag:tag_id=tagof(value));
native linked_list_set_str(LinkedList:linked_list, index, const value[]);
native linked_list_set_str_s(LinkedList:linked_list, index, ConstStringTag:value);
native linked_list_set_var(LinkedList:linked_list, index, ConstVariantTag:value);
Replaces a value at a specific position in a linked list with a new one.
native linked_list_set_cell(LinkedList:linked_list, index, offset, AnyTag:value);
native bool:linked_list_set_cell_safe(LinkedList:linked_list, index, offset, AnyTag:value, TagTag:tag_id=tagof(value));
Sets the value of a single cell in an array stored in the linked list. The safe
version checks if the tags are compatible.
native linked_list_count(LinkedList:linked_list, AnyTag:value, TagTag:tag_id=tagof(value));
native linked_list_count_arr(LinkedList:linked_list, const AnyTag:value[], size=sizeof(value), TagTag:tag_id=tagof(value));
native linked_list_count_str(LinkedList:linked_list, const value[]);
native linked_list_count_str_s(LinkedList:linked_list, ConstStringTag:value);
native linked_list_count_var(LinkedList:linked_list, ConstVariantTag:value);
Counts the number of occurences of a specific element.
native linked_list_count_if(LinkedList:linked_list, Expression:pred);
Counts the number of elements in the linked list that satisfy pred
.
native linked_list_tagof(LinkedList:linked_list, index);
Returns the tag of an element in the linked list.
native linked_list_sizeof(LinkedList:linked_list, index);
Returns the size of an element in the linked list.
native Iter:linked_list_iter(LinkedList:linked_list, index=0);
Creates a new iterator pointing to an element in the linked list.