All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
as_arraylist Struct Reference

Detailed Description

An dynamic array implementation for as_list.

as_arryalist can either be initialize on the stack or the heap.

For stack allocation, you have two choices:

The key differences between the two is as_arraylist_inita() can't be dynamically resized and is solely on the stack.

The following is using a as_arraylist_inita():

#define as_arraylist_inita(__list, __n)

You will notice that the code is quite similar to as_arraylist_init():

as_arraylist_init(&list, 2, 0);
AS_EXTERN as_arraylist * as_arraylist_init(as_arraylist *list, uint32_t capacity, uint32_t block_size)

If you need a new heap allocated list, then use as_arraylist_new():

AS_EXTERN as_arraylist * as_arraylist_new(uint32_t capacity, uint32_t block_size)

When you are finished using the list, then you should release the list and associated resources, using as_arraylist_destroy():

AS_EXTERN void as_arraylist_destroy(as_arraylist *list)

The as_arraylist is a subtype of as_list. This allows you to alternatively use as_list functions, by typecasting as_arraylist to as_list.

as_list * l = (as_list *) as_arraylist_init(&list, 3, 0);
static void as_list_destroy(as_list *list)
Definition as_list.h:510
static int as_list_append_int64(as_list *list, int64_t value)
Definition as_list.h:1117

Each of the as_list functions proxy to the as_arraylist functions. So, calling as_list_destroy() is equivalent to calling as_arraylist_destroy().

Definition at line 95 of file as_arraylist.h.

#include "as_arraylist.h"

+ Inheritance diagram for as_arraylist:
+ Collaboration diagram for as_arraylist:

Data Fields

uint32_t block_size
 
uint32_t capacity
 
as_val ** elements
 
bool free
 
uint32_t size
 
- Data Fields inherited from as_list
uint32_t flags
 
const struct as_list_hooks_s * hooks
 
- Data Fields inherited from as_val
uint32_t count
 
bool free
 
as_val_t type
 

Related Symbols

(Note that these are not member symbols.)

AS_EXTERN int as_arraylist_append (as_arraylist *list, as_val *value)
 
static int as_arraylist_append_as_double (as_arraylist *list, as_double *value)
 
static int as_arraylist_append_bytes (as_arraylist *list, as_bytes *value)
 
AS_EXTERN int as_arraylist_append_double (as_arraylist *list, double value)
 
AS_EXTERN int as_arraylist_append_int64 (as_arraylist *list, int64_t value)
 
static int as_arraylist_append_integer (as_arraylist *list, as_integer *value)
 
static int as_arraylist_append_list (as_arraylist *list, as_list *value)
 
static int as_arraylist_append_map (as_arraylist *list, as_map *value)
 
AS_EXTERN int as_arraylist_append_str (as_arraylist *list, const char *value)
 
static int as_arraylist_append_string (as_arraylist *list, as_string *value)
 
AS_EXTERN int as_arraylist_concat (as_arraylist *list, const as_arraylist *list2)
 
AS_EXTERN void as_arraylist_destroy (as_arraylist *list)
 
AS_EXTERN as_arraylistas_arraylist_drop (const as_arraylist *list, uint32_t n)
 
AS_EXTERN bool as_arraylist_foreach (const as_arraylist *list, as_list_foreach_callback callback, void *udata)
 
AS_EXTERN as_valas_arraylist_get (const as_arraylist *list, uint32_t index)
 
static as_doubleas_arraylist_get_as_double (const as_arraylist *list, uint32_t index)
 
static as_bytesas_arraylist_get_bytes (const as_arraylist *list, uint32_t index)
 
AS_EXTERN double as_arraylist_get_double (const as_arraylist *list, uint32_t index)
 
AS_EXTERN int64_t as_arraylist_get_int64 (const as_arraylist *list, uint32_t index)
 
static as_integeras_arraylist_get_integer (const as_arraylist *list, uint32_t index)
 
static as_listas_arraylist_get_list (const as_arraylist *list, uint32_t index)
 
static as_mapas_arraylist_get_map (const as_arraylist *list, uint32_t index)
 
AS_EXTERN char * as_arraylist_get_str (const as_arraylist *list, uint32_t index)
 
static as_stringas_arraylist_get_string (const as_arraylist *list, uint32_t index)
 
AS_EXTERN uint32_t as_arraylist_hashcode (const as_arraylist *list)
 
AS_EXTERN as_valas_arraylist_head (const as_arraylist *list)
 
AS_EXTERN as_arraylistas_arraylist_init (as_arraylist *list, uint32_t capacity, uint32_t block_size)
 
#define as_arraylist_inita(__list, __n)
 
AS_EXTERN int as_arraylist_insert (as_arraylist *list, uint32_t index, as_val *value)
 
static int as_arraylist_insert_as_double (as_arraylist *list, uint32_t index, as_double *value)
 
static int as_arraylist_insert_bytes (as_arraylist *list, uint32_t index, as_bytes *value)
 
AS_EXTERN int as_arraylist_insert_double (as_arraylist *list, uint32_t index, double value)
 
AS_EXTERN int as_arraylist_insert_int64 (as_arraylist *list, uint32_t index, int64_t value)
 
static int as_arraylist_insert_integer (as_arraylist *list, uint32_t index, as_integer *value)
 
static int as_arraylist_insert_list (as_arraylist *list, uint32_t index, as_list *value)
 
static int as_arraylist_insert_map (as_arraylist *list, uint32_t index, as_map *value)
 
AS_EXTERN int as_arraylist_insert_str (as_arraylist *list, uint32_t index, const char *value)
 
static int as_arraylist_insert_string (as_arraylist *list, uint32_t index, as_string *value)
 
AS_EXTERN as_arraylistas_arraylist_new (uint32_t capacity, uint32_t block_size)
 
AS_EXTERN int as_arraylist_prepend (as_arraylist *list, as_val *value)
 
static int as_arraylist_prepend_as_double (as_arraylist *list, as_double *value)
 
static int as_arraylist_prepend_bytes (as_arraylist *list, as_bytes *value)
 
AS_EXTERN int as_arraylist_prepend_double (as_arraylist *list, double value)
 
AS_EXTERN int as_arraylist_prepend_int64 (as_arraylist *list, int64_t value)
 
static int as_arraylist_prepend_integer (as_arraylist *list, as_integer *value)
 
static int as_arraylist_prepend_list (as_arraylist *list, as_list *value)
 
static int as_arraylist_prepend_map (as_arraylist *list, as_map *value)
 
AS_EXTERN int as_arraylist_prepend_str (as_arraylist *list, const char *value)
 
static int as_arraylist_prepend_string (as_arraylist *list, as_string *value)
 
AS_EXTERN int as_arraylist_remove (as_arraylist *list, uint32_t index)
 
AS_EXTERN int as_arraylist_set (as_arraylist *list, uint32_t index, as_val *value)
 
static int as_arraylist_set_as_double (as_arraylist *list, uint32_t index, as_double *value)
 
static int as_arraylist_set_bytes (as_arraylist *list, uint32_t index, as_bytes *value)
 
AS_EXTERN int as_arraylist_set_double (as_arraylist *list, uint32_t index, double value)
 
AS_EXTERN int as_arraylist_set_int64 (as_arraylist *list, uint32_t index, int64_t value)
 
static int as_arraylist_set_integer (as_arraylist *list, uint32_t index, as_integer *value)
 
static int as_arraylist_set_list (as_arraylist *list, uint32_t index, as_list *value)
 
static int as_arraylist_set_map (as_arraylist *list, uint32_t index, as_map *value)
 
AS_EXTERN int as_arraylist_set_str (as_arraylist *list, uint32_t index, const char *value)
 
static int as_arraylist_set_string (as_arraylist *list, uint32_t index, as_string *value)
 
AS_EXTERN uint32_t as_arraylist_size (const as_arraylist *list)
 
AS_EXTERN as_arraylistas_arraylist_tail (const as_arraylist *list)
 
AS_EXTERN as_arraylistas_arraylist_take (const as_arraylist *list, uint32_t n)
 
AS_EXTERN int as_arraylist_trim (as_arraylist *list, uint32_t index)
 

Friends And Related Symbol Documentation

◆ as_arraylist_append()

AS_EXTERN int as_arraylist_append ( as_arraylist * list,
as_val * value )
related

Add the value to the end of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_append_as_double()

static int as_arraylist_append_as_double ( as_arraylist * list,
as_double * value )
related

Add an as_double to the end of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 862 of file as_arraylist.h.

References as_arraylist_append().

◆ as_arraylist_append_bytes()

static int as_arraylist_append_bytes ( as_arraylist * list,
as_bytes * value )
related

Add an as_bytes to the end of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 892 of file as_arraylist.h.

References as_arraylist_append().

◆ as_arraylist_append_double()

AS_EXTERN int as_arraylist_append_double ( as_arraylist * list,
double value )
related

Add a double to the end of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_append_int64()

AS_EXTERN int as_arraylist_append_int64 ( as_arraylist * list,
int64_t value )
related

Add an int64_t to the end of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_append_integer()

static int as_arraylist_append_integer ( as_arraylist * list,
as_integer * value )
related

Add an as_integer to the end of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 847 of file as_arraylist.h.

References as_arraylist_append().

◆ as_arraylist_append_list()

static int as_arraylist_append_list ( as_arraylist * list,
as_list * value )
related

Add an as_list to the end of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 907 of file as_arraylist.h.

References as_arraylist_append().

◆ as_arraylist_append_map()

static int as_arraylist_append_map ( as_arraylist * list,
as_map * value )
related

Add an as_map to the end of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 922 of file as_arraylist.h.

References as_arraylist_append().

◆ as_arraylist_append_str()

AS_EXTERN int as_arraylist_append_str ( as_arraylist * list,
const char * value )
related

Add a NULL-terminated string to the end of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_append_string()

static int as_arraylist_append_string ( as_arraylist * list,
as_string * value )
related

Add an as_string to the end of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 877 of file as_arraylist.h.

References as_arraylist_append().

◆ as_arraylist_concat()

AS_EXTERN int as_arraylist_concat ( as_arraylist * list,
const as_arraylist * list2 )
related

Append all elements of list2, in order, to list. No new list object is created.

Parameters
listThe list to append to.
list2The list from which to append.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_destroy()

AS_EXTERN void as_arraylist_destroy ( as_arraylist * list)
related

Destoy the list and release resources.

Parameters
listThe list to destroy.

◆ as_arraylist_drop()

AS_EXTERN as_arraylist * as_arraylist_drop ( const as_arraylist * list,
uint32_t n )
related

Return a new list with the first n elements removed.

Parameters
listThe list.
nThe number of elements to remove.
Returns
A new list of all elements after the first n elements.

◆ as_arraylist_foreach()

AS_EXTERN bool as_arraylist_foreach ( const as_arraylist * list,
as_list_foreach_callback callback,
void * udata )
related

Call the callback function for each element in the list.

Parameters
listThe list to iterate.
callbackThe function to call for each element in the list.
udataUser-data to be sent to the callback.
Returns
true if iteration completes fully. false if iteration was aborted.

◆ as_arraylist_get()

AS_EXTERN as_val * as_arraylist_get ( const as_arraylist * list,
uint32_t index )
related

Return the value at the specified index.

Parameters
listThe list.
indexThe index of the element.
Returns
The value at given index, if it exists. Otherwise NULL.

◆ as_arraylist_get_as_double()

static as_double * as_arraylist_get_as_double ( const as_arraylist * list,
uint32_t index )
related

Return an as_double value at the specified index of the list.

Parameters
listThe list.
indexThe index of the element.
Returns
The value at given index, if it exists. Otherwise NULL.

Definition at line 407 of file as_arraylist.h.

References as_arraylist_get(), and as_double_fromval().

◆ as_arraylist_get_bytes()

static as_bytes * as_arraylist_get_bytes ( const as_arraylist * list,
uint32_t index )
related

Return an as_bytes value at the specified index of the list.

Parameters
listThe list.
indexThe index of the element.
Returns
The value at given index, if it exists. Otherwise NULL.

Definition at line 437 of file as_arraylist.h.

References as_arraylist_get(), and as_bytes_fromval().

◆ as_arraylist_get_double()

AS_EXTERN double as_arraylist_get_double ( const as_arraylist * list,
uint32_t index )
related

Return a double value at the specified index of the list.

Parameters
listThe list.
indexThe index of the element.
Returns
The value at given index, if it exists. Otherwise NULL.

◆ as_arraylist_get_int64()

AS_EXTERN int64_t as_arraylist_get_int64 ( const as_arraylist * list,
uint32_t index )
related

Return an int64_t value at the specified index of the list.

Parameters
listThe list.
indexThe index of the element.
Returns
The value at given index, if it exists. Otherwise NULL.

◆ as_arraylist_get_integer()

static as_integer * as_arraylist_get_integer ( const as_arraylist * list,
uint32_t index )
related

Return an as_integer value at the specified index of the list.

Parameters
listThe list.
indexThe index of the element.
Returns
The value at given index, if it exists. Otherwise NULL.

Definition at line 392 of file as_arraylist.h.

References as_arraylist_get(), and as_integer_fromval().

◆ as_arraylist_get_list()

static as_list * as_arraylist_get_list ( const as_arraylist * list,
uint32_t index )
related

Return an as_list value at the specified index of the list.

Parameters
listThe list.
indexThe index of the element.
Returns
The value at given index, if it exists. Otherwise NULL.

Definition at line 452 of file as_arraylist.h.

References as_arraylist_get(), and as_list_fromval().

◆ as_arraylist_get_map()

static as_map * as_arraylist_get_map ( const as_arraylist * list,
uint32_t index )
related

Return an as_map value at the specified index of the list.

Parameters
listThe list.
indexThe index of the element.
Returns
The value at given index, if it exists. Otherwise NULL.

Definition at line 467 of file as_arraylist.h.

References as_arraylist_get(), and as_map_fromval().

◆ as_arraylist_get_str()

AS_EXTERN char * as_arraylist_get_str ( const as_arraylist * list,
uint32_t index )
related

Return a NULL-terminated value at the specified index of the list.

Parameters
listThe list.
indexThe index of the element.
Returns
The value at given index, if it exists. Otherwise NULL.

◆ as_arraylist_get_string()

static as_string * as_arraylist_get_string ( const as_arraylist * list,
uint32_t index )
related

Return an as_string value at the specified index of the list.

Parameters
listThe list.
indexThe index of the element.
Returns
The value at given index, if it exists. Otherwise NULL.

Definition at line 422 of file as_arraylist.h.

References as_arraylist_get(), and as_string_fromval().

◆ as_arraylist_hashcode()

AS_EXTERN uint32_t as_arraylist_hashcode ( const as_arraylist * list)
related

The hash value of the list.

Parameters
listThe list.
Returns
The hash value of the list.

◆ as_arraylist_head()

AS_EXTERN as_val * as_arraylist_head ( const as_arraylist * list)
related

Get the first element of the list.

Parameters
listThe list to get the first element from.
Returns
The first element of the list. Otherwise NULL.

◆ as_arraylist_init()

AS_EXTERN as_arraylist * as_arraylist_init ( as_arraylist * list,
uint32_t capacity,
uint32_t block_size )
related

Initialize a stack allocated as_arraylist, with element storage on the heap.

This differs from as_arraylist_inita(), in that as_arraylist_inita() allocates element storage on the stack.

Parameters
listThe as_list to initialize
capacityThe number of elements to allocate to the list.
block_sizeThe number of elements to grow the list by, when the capacity has been reached.
Returns
On success, the initialize list. Otherwise NULL.

◆ as_arraylist_inita

#define as_arraylist_inita ( __list,
__n )
related
Value:
as_arraylist_init((__list), 0, 0);\
(__list)->free = false;\
(__list)->capacity = (__n);\
(__list)->size = 0;\
(__list)->elements = (as_val**) alloca(sizeof(as_val*) * (__n));
uint32_t capacity
as_val ** elements
uint32_t size

Initialize a stack allocated as_arraylist, with element storage on the stack.

This differs from as_arraylist_init(), in that as_arraylist_init() allocates element storage on the heap.

Parameters
__listThe as_list to initialize
__nThe number of elements to allocate to the list.
Returns
On success, the initialize list. Otherwise NULL.

Definition at line 177 of file as_arraylist.h.

◆ as_arraylist_insert()

AS_EXTERN int as_arraylist_insert ( as_arraylist * list,
uint32_t index,
as_val * value )
related

Insert a value at the specified index of the list.

Any elements at and beyond specified index will be shifted so their indexes increase by 1. It's ok to insert beyond the current end of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to insert at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_insert_as_double()

static int as_arraylist_insert_as_double ( as_arraylist * list,
uint32_t index,
as_double * value )
related

Insert an as_double value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to insert at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 716 of file as_arraylist.h.

References as_arraylist_insert().

◆ as_arraylist_insert_bytes()

static int as_arraylist_insert_bytes ( as_arraylist * list,
uint32_t index,
as_bytes * value )
related

Insert an as_bytes value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to insert at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 748 of file as_arraylist.h.

References as_arraylist_insert().

◆ as_arraylist_insert_double()

AS_EXTERN int as_arraylist_insert_double ( as_arraylist * list,
uint32_t index,
double value )
related

Insert a double value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to insert at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_insert_int64()

AS_EXTERN int as_arraylist_insert_int64 ( as_arraylist * list,
uint32_t index,
int64_t value )
related

Insert an int64_t value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to insert at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_insert_integer()

static int as_arraylist_insert_integer ( as_arraylist * list,
uint32_t index,
as_integer * value )
related

Insert an as_integer value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to insert at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 700 of file as_arraylist.h.

References as_arraylist_insert().

◆ as_arraylist_insert_list()

static int as_arraylist_insert_list ( as_arraylist * list,
uint32_t index,
as_list * value )
related

Insert an as_list value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to insert at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 764 of file as_arraylist.h.

References as_arraylist_insert().

◆ as_arraylist_insert_map()

static int as_arraylist_insert_map ( as_arraylist * list,
uint32_t index,
as_map * value )
related

Insert an as_map value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to insert at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 780 of file as_arraylist.h.

References as_arraylist_insert().

◆ as_arraylist_insert_str()

AS_EXTERN int as_arraylist_insert_str ( as_arraylist * list,
uint32_t index,
const char * value )
related

Insert a NULL-terminated string value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to insert at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_insert_string()

static int as_arraylist_insert_string ( as_arraylist * list,
uint32_t index,
as_string * value )
related

Insert an as_string value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to insert at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 732 of file as_arraylist.h.

References as_arraylist_insert().

◆ as_arraylist_new()

AS_EXTERN as_arraylist * as_arraylist_new ( uint32_t capacity,
uint32_t block_size )
related

Create and initialize a heap allocated list as as_arraylist.

Parameters
capacityThe number of elements to allocate to the list.
block_sizeThe number of elements to grow the list by, when the capacity has been reached.
Returns
On success, the new list. Otherwise NULL.

◆ as_arraylist_prepend()

AS_EXTERN int as_arraylist_prepend ( as_arraylist * list,
as_val * value )
related

Add the value to the beginning of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_prepend_as_double()

static int as_arraylist_prepend_as_double ( as_arraylist * list,
as_double * value )
related

Add an as_double to the beginning of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 1004 of file as_arraylist.h.

References as_arraylist_prepend().

◆ as_arraylist_prepend_bytes()

static int as_arraylist_prepend_bytes ( as_arraylist * list,
as_bytes * value )
related

Add an as_bytes to the beginning of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 1032 of file as_arraylist.h.

References as_arraylist_prepend().

◆ as_arraylist_prepend_double()

AS_EXTERN int as_arraylist_prepend_double ( as_arraylist * list,
double value )
related

Add a double to the beginning of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_prepend_int64()

AS_EXTERN int as_arraylist_prepend_int64 ( as_arraylist * list,
int64_t value )
related

Add an int64_t to the beginning of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_prepend_integer()

static int as_arraylist_prepend_integer ( as_arraylist * list,
as_integer * value )
related

Add an as_integer to the beginning of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 989 of file as_arraylist.h.

References as_arraylist_prepend().

◆ as_arraylist_prepend_list()

static int as_arraylist_prepend_list ( as_arraylist * list,
as_list * value )
related

Add an as_list to the beginning of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 1046 of file as_arraylist.h.

References as_arraylist_prepend().

◆ as_arraylist_prepend_map()

static int as_arraylist_prepend_map ( as_arraylist * list,
as_map * value )
related

Add an as_map to the beginning of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 1060 of file as_arraylist.h.

References as_arraylist_prepend().

◆ as_arraylist_prepend_str()

AS_EXTERN int as_arraylist_prepend_str ( as_arraylist * list,
const char * value )
related

Add a NULL-terminated string to the beginning of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_prepend_string()

static int as_arraylist_prepend_string ( as_arraylist * list,
as_string * value )
related

Add an as_string to the beginning of the list.

Parameters
listThe list.
valueThe value to prepend.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 1018 of file as_arraylist.h.

References as_arraylist_prepend().

◆ as_arraylist_remove()

AS_EXTERN int as_arraylist_remove ( as_arraylist * list,
uint32_t index )
related

Remove element at specified index.

Any elements beyond specified index will be shifted so their indexes decrease by 1. The element at specified index will be destroyed.

Parameters
listThe list.
indexThe index of the element to remove.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_set()

AS_EXTERN int as_arraylist_set ( as_arraylist * list,
uint32_t index,
as_val * value )
related

Set a value at the specified index of the list.

Notice that in order to maintain proper object/memory management, we just first destroy (as_val_destroy()) the old object at element position(i) before assigning the new element. Also note that the object at element position (i) is assumed to exist, so all element positions must be appropriately initialized to zero.

Parameters
listThe list.
indexPosition in the list.
valueThe value to set at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_set_as_double()

static int as_arraylist_set_as_double ( as_arraylist * list,
uint32_t index,
as_double * value )
related

Set an as_double value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to set at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 561 of file as_arraylist.h.

References as_arraylist_set().

◆ as_arraylist_set_bytes()

static int as_arraylist_set_bytes ( as_arraylist * list,
uint32_t index,
as_bytes * value )
related

Set an as_bytes value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to set at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 593 of file as_arraylist.h.

References as_arraylist_set().

◆ as_arraylist_set_double()

AS_EXTERN int as_arraylist_set_double ( as_arraylist * list,
uint32_t index,
double value )
related

Set a double value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to set at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_set_int64()

AS_EXTERN int as_arraylist_set_int64 ( as_arraylist * list,
uint32_t index,
int64_t value )
related

Set an int64_t value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to set at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_set_integer()

static int as_arraylist_set_integer ( as_arraylist * list,
uint32_t index,
as_integer * value )
related

Set an as_integer value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to set at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 545 of file as_arraylist.h.

References as_arraylist_set().

◆ as_arraylist_set_list()

static int as_arraylist_set_list ( as_arraylist * list,
uint32_t index,
as_list * value )
related

Set an as_list value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to set at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 609 of file as_arraylist.h.

References as_arraylist_set().

◆ as_arraylist_set_map()

static int as_arraylist_set_map ( as_arraylist * list,
uint32_t index,
as_map * value )
related

Set an as_map value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to set at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 625 of file as_arraylist.h.

References as_arraylist_set().

◆ as_arraylist_set_str()

AS_EXTERN int as_arraylist_set_str ( as_arraylist * list,
uint32_t index,
const char * value )
related

Set a NULL-terminated string value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to set at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

◆ as_arraylist_set_string()

static int as_arraylist_set_string ( as_arraylist * list,
uint32_t index,
as_string * value )
related

Set an as_string value at the specified index of the list.

Parameters
listThe list.
indexPosition in the list.
valueThe value to set at the given index.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Definition at line 577 of file as_arraylist.h.

References as_arraylist_set().

◆ as_arraylist_size()

AS_EXTERN uint32_t as_arraylist_size ( const as_arraylist * list)
related

The number of elements in the list.

Parameters
listThe list.
Returns
The number of elements in the list.

◆ as_arraylist_tail()

AS_EXTERN as_arraylist * as_arraylist_tail ( const as_arraylist * list)
related

Returns a new list containing all elements other than the head

Parameters
listThe list to get the elements from.
Returns
A new list of all elements after the first element.

◆ as_arraylist_take()

AS_EXTERN as_arraylist * as_arraylist_take ( const as_arraylist * list,
uint32_t n )
related

Return a new list containing the first n elements.

Parameters
listThe list.
nThe number of elements to take.
Returns
A new list of the first n elements.

◆ as_arraylist_trim()

AS_EXTERN int as_arraylist_trim ( as_arraylist * list,
uint32_t index )
related

Delete (and destroy) all elements at and beyond specified index. Capacity is not reduced.

Parameters
listThe list to trim.
indexThe index from which to trim.
Returns
AS_ARRAYLIST_OK on success. Otherwise an error occurred.

Field Documentation

◆ block_size

uint32_t as_arraylist::block_size

Number of elements to add, when capacity is reached. If 0 (zero), then capacity can't be expanded.

Definition at line 108 of file as_arraylist.h.

◆ capacity

uint32_t as_arraylist::capacity

The total number elements allocated.

Definition at line 113 of file as_arraylist.h.

◆ elements

as_val** as_arraylist::elements

The elements of the list.

Definition at line 123 of file as_arraylist.h.

◆ free

bool as_arraylist::free

If true, then as_arraylist.elements will be freed when as_arraylist_destroy() is called.

Definition at line 129 of file as_arraylist.h.

◆ size

uint32_t as_arraylist::size

The number of elements used.

Definition at line 118 of file as_arraylist.h.


The documentation for this struct was generated from the following file: