All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Data Structures | Enumerations | Functions
as_arraylist.h File Reference
#include <aerospike/as_integer.h>
#include <aerospike/as_string.h>
#include <aerospike/as_bytes.h>
#include <aerospike/as_list.h>
#include <aerospike/as_map.h>
#include <aerospike/as_val.h>
#include <stdbool.h>
#include <stdint.h>
+ Include dependency graph for as_arraylist.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  as_arraylist
 

Enumerations

enum  as_arraylist_status { AS_ARRAYLIST_OK = 0, AS_ARRAYLIST_ERR_ALLOC = 1, AS_ARRAYLIST_ERR_MAX = 2, AS_ARRAYLIST_ERR_INDEX = 3 }
 

Functions

int as_arraylist_append (as_arraylist *list, as_val *value)
 
static int as_arraylist_append_bytes (as_arraylist *list, as_bytes *value)
 
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)
 
int as_arraylist_append_str (as_arraylist *list, const char *value)
 
static int as_arraylist_append_string (as_arraylist *list, as_string *value)
 
int as_arraylist_concat (as_arraylist *list, const as_arraylist *list2)
 
void as_arraylist_destroy (as_arraylist *list)
 
as_arraylistas_arraylist_drop (const as_arraylist *list, uint32_t n)
 
bool as_arraylist_foreach (const as_arraylist *list, as_list_foreach_callback callback, void *udata)
 
as_valas_arraylist_get (const as_arraylist *list, uint32_t index)
 
static as_bytesas_arraylist_get_bytes (const as_arraylist *list, uint32_t index)
 
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)
 
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)
 
uint32_t as_arraylist_hashcode (const as_arraylist *list)
 
as_valas_arraylist_head (const as_arraylist *list)
 
as_arraylistas_arraylist_init (as_arraylist *list, uint32_t capacity, uint32_t block_size)
 
int as_arraylist_insert (as_arraylist *list, uint32_t index, as_val *value)
 
static int as_arraylist_insert_bytes (as_arraylist *list, uint32_t index, as_bytes *value)
 
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)
 
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_arraylistas_arraylist_new (uint32_t capacity, uint32_t block_size)
 
int as_arraylist_prepend (as_arraylist *list, as_val *value)
 
static int as_arraylist_prepend_bytes (as_arraylist *list, as_bytes *value)
 
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)
 
int as_arraylist_prepend_str (as_arraylist *list, const char *value)
 
static int as_arraylist_prepend_string (as_arraylist *list, as_string *value)
 
int as_arraylist_remove (as_arraylist *list, uint32_t index)
 
int as_arraylist_set (as_arraylist *list, uint32_t index, as_val *value)
 
static int as_arraylist_set_bytes (as_arraylist *list, uint32_t index, as_bytes *value)
 
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)
 
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)
 
uint32_t as_arraylist_size (const as_arraylist *list)
 
as_arraylistas_arraylist_tail (const as_arraylist *list)
 
as_arraylistas_arraylist_take (const as_arraylist *list, uint32_t n)
 
int as_arraylist_trim (as_arraylist *list, uint32_t index)
 

Enumeration Type Documentation

Status codes for various as_arraylist operations.

Enumerator
AS_ARRAYLIST_OK 

Normal operation.

AS_ARRAYLIST_ERR_ALLOC 

Unable to expand capacity, because cf_realloc() failed.

AS_ARRAYLIST_ERR_MAX 

Unable to expand capacity, because as_arraylist.block_size is 0.

AS_ARRAYLIST_ERR_INDEX 

Illegal array index.

Definition at line 135 of file as_arraylist.h.

Function Documentation

int as_arraylist_append ( as_arraylist list,
as_val value 
)

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.
static int as_arraylist_append_bytes ( as_arraylist list,
as_bytes value 
)
inlinestatic

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 738 of file as_arraylist.h.

References as_arraylist::as_arraylist_append().

int as_arraylist_append_int64 ( as_arraylist list,
int64_t  value 
)

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.
static int as_arraylist_append_integer ( as_arraylist list,
as_integer value 
)
inlinestatic

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 710 of file as_arraylist.h.

References as_arraylist::as_arraylist_append().

static int as_arraylist_append_list ( as_arraylist list,
as_list value 
)
inlinestatic

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 752 of file as_arraylist.h.

References as_arraylist::as_arraylist_append().

static int as_arraylist_append_map ( as_arraylist list,
as_map value 
)
inlinestatic

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 766 of file as_arraylist.h.

References as_arraylist::as_arraylist_append().

int as_arraylist_append_str ( as_arraylist list,
const char *  value 
)

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.
static int as_arraylist_append_string ( as_arraylist list,
as_string value 
)
inlinestatic

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 724 of file as_arraylist.h.

References as_arraylist::as_arraylist_append().

int as_arraylist_concat ( as_arraylist list,
const as_arraylist list2 
)

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.
void as_arraylist_destroy ( as_arraylist list)

Destoy the list and release resources.

Parameters
listThe list to destroy.
as_arraylist * as_arraylist_drop ( const as_arraylist list,
uint32_t  n 
)

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.
bool as_arraylist_foreach ( const as_arraylist list,
as_list_foreach_callback  callback,
void *  udata 
)

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_val * as_arraylist_get ( const as_arraylist list,
uint32_t  index 
)

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.
static as_bytes * as_arraylist_get_bytes ( const as_arraylist list,
uint32_t  index 
)
inlinestatic

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 392 of file as_arraylist.h.

References as_arraylist::as_arraylist_get(), and as_bytes::as_bytes_fromval().

int64_t as_arraylist_get_int64 ( const as_arraylist list,
uint32_t  index 
)

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.
static as_integer * as_arraylist_get_integer ( const as_arraylist list,
uint32_t  index 
)
inlinestatic

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 364 of file as_arraylist.h.

References as_arraylist::as_arraylist_get(), and as_integer::as_integer_fromval().

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

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 406 of file as_arraylist.h.

References as_arraylist::as_arraylist_get(), and as_list::as_list_fromval().

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

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 420 of file as_arraylist.h.

References as_arraylist::as_arraylist_get(), and as_map::as_map_fromval().

char * as_arraylist_get_str ( const as_arraylist list,
uint32_t  index 
)

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.
static as_string * as_arraylist_get_string ( const as_arraylist list,
uint32_t  index 
)
inlinestatic

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 378 of file as_arraylist.h.

References as_arraylist::as_arraylist_get(), and as_string::as_string_fromval().

uint32_t as_arraylist_hashcode ( const as_arraylist list)

The hash value of the list.

Parameters
listThe list.
Returns
The hash value of the list.
as_val * as_arraylist_head ( const as_arraylist list)

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 * as_arraylist_init ( as_arraylist list,
uint32_t  capacity,
uint32_t  block_size 
)

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.
int as_arraylist_insert ( as_arraylist list,
uint32_t  index,
as_val value 
)

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.
static int as_arraylist_insert_bytes ( as_arraylist list,
uint32_t  index,
as_bytes value 
)
inlinestatic

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 629 of file as_arraylist.h.

References as_arraylist::as_arraylist_insert().

int as_arraylist_insert_int64 ( as_arraylist list,
uint32_t  index,
int64_t  value 
)

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.
static int as_arraylist_insert_integer ( as_arraylist list,
uint32_t  index,
as_integer value 
)
inlinestatic

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 599 of file as_arraylist.h.

References as_arraylist::as_arraylist_insert().

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

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 644 of file as_arraylist.h.

References as_arraylist::as_arraylist_insert().

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

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 659 of file as_arraylist.h.

References as_arraylist::as_arraylist_insert().

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

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.
static int as_arraylist_insert_string ( as_arraylist list,
uint32_t  index,
as_string value 
)
inlinestatic

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 614 of file as_arraylist.h.

References as_arraylist::as_arraylist_insert().

as_arraylist * as_arraylist_new ( uint32_t  capacity,
uint32_t  block_size 
)

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.
int as_arraylist_prepend ( as_arraylist list,
as_val value 
)

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.
static int as_arraylist_prepend_bytes ( as_arraylist list,
as_bytes value 
)
inlinestatic

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 845 of file as_arraylist.h.

References as_arraylist::as_arraylist_prepend().

int as_arraylist_prepend_int64 ( as_arraylist list,
int64_t  value 
)

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.
static int as_arraylist_prepend_integer ( as_arraylist list,
as_integer value 
)
inlinestatic

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 817 of file as_arraylist.h.

References as_arraylist::as_arraylist_prepend().

static int as_arraylist_prepend_list ( as_arraylist list,
as_list value 
)
inlinestatic

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 859 of file as_arraylist.h.

References as_arraylist::as_arraylist_prepend().

static int as_arraylist_prepend_map ( as_arraylist list,
as_map value 
)
inlinestatic

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 873 of file as_arraylist.h.

References as_arraylist::as_arraylist_prepend().

int as_arraylist_prepend_str ( as_arraylist list,
const char *  value 
)

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.
static int as_arraylist_prepend_string ( as_arraylist list,
as_string value 
)
inlinestatic

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 831 of file as_arraylist.h.

References as_arraylist::as_arraylist_prepend().

int as_arraylist_remove ( as_arraylist list,
uint32_t  index 
)

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.
int as_arraylist_set ( as_arraylist list,
uint32_t  index,
as_val value 
)

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.
static int as_arraylist_set_bytes ( as_arraylist list,
uint32_t  index,
as_bytes value 
)
inlinestatic

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 511 of file as_arraylist.h.

References as_arraylist::as_arraylist_set().

int as_arraylist_set_int64 ( as_arraylist list,
uint32_t  index,
int64_t  value 
)

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.
static int as_arraylist_set_integer ( as_arraylist list,
uint32_t  index,
as_integer value 
)
inlinestatic

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 481 of file as_arraylist.h.

References as_arraylist::as_arraylist_set().

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

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 526 of file as_arraylist.h.

References as_arraylist::as_arraylist_set().

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

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 541 of file as_arraylist.h.

References as_arraylist::as_arraylist_set().

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

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.
static int as_arraylist_set_string ( as_arraylist list,
uint32_t  index,
as_string value 
)
inlinestatic

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 496 of file as_arraylist.h.

References as_arraylist::as_arraylist_set().

uint32_t as_arraylist_size ( const as_arraylist list)

The number of elements in the list.

Parameters
listThe list.
Returns
The number of elements in the list.
as_arraylist * as_arraylist_tail ( const as_arraylist list)

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 * as_arraylist_take ( const as_arraylist list,
uint32_t  n 
)

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.
int as_arraylist_trim ( as_arraylist list,
uint32_t  index 
)

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.