AG_LIST(3)

NAME
AG_List - agar variable array structure

SYNOPSIS

    #include <agar/core/list.h>

DESCRIPTION
The AG_List structure describes an ordered list of AG_Variable(3) items. It is defined as follows:

    typedef struct ag_list {
    	int n;			/* Element count */
    	AG_Variable *v;		/* Items */
    } AG_List;

INTERFACE
AG_List * AG_ListNew(void)

AG_List * AG_ListDup(const AG_List *L)

int AG_ListDestroy(AG_List *L)

int AG_ListAppend(AG_List *L, const AG_Variable *V)

int AG_ListPrepend(AG_List *L, const AG_Variable *V)

int AG_ListInsert(AG_List *L, int idx, const AG_Variable *V)

int AG_ListRemove(AG_List *L, int idx)

int AG_ListClear(AG_List *L)

The AG_ListNew() function allocates and initializes a new, empty AG_List. AG_ListNew() returns a pointer to the new list or NULL on failure. AG_ListDup() duplicates an existing list L. AG_ListDestroy() frees all resources allocated by a list.

AG_ListAppend() appends a copy of variable V to the list. AG_ListPrepend() inserts at the beginning of the list. AG_ListInsert() inserts at a specified position idx. AG_ListAppend(), AG_ListPrepend() and AG_ListInsert() return the index of the new list entry or -1 on failure.

AG_ListRemove() removes the element at index idx from the list, returning 1 on success or -1 if the given index is invalid. AG_ListClear() removes all elements from the list.

SEE ALSO
AG_Intro(3), AG_List(3), AG_Tbl(3), AG_Tree(3), AG_Variable(3)

HISTORY
The AG_List interface first appeared in Agar 1.3.4