[ Maverik Level 1 functions ]

#

mav_listNew

mav_listNew, mav_listItemAdd, mav_listItemRmv, mav_listItemNext, mav_listItemContains, mav_listPointerReset, mav_listPointerPush, mav_listPointerPop, mav_listEmpty, mav_listDelete, mav_listSize

## Summary

List management functions.

## Syntax

MAV_list *mav_listNew(void);

void mav_listItemAdd(MAV_list *l, void *d);

void mav_listItemRmv(MAV_list *l, void *d);

int mav_listItemNext(MAV_list *l, void **d);

int mav_listItemContains(MAV_list *l, void *d);

void mav_listPointerReset(MAV_list *l);

void mav_listPointerPush(MAV_list *l);

void mav_listPointerPop(MAV_list *l);

void mav_listEmpty(MAV_list *l);

void mav_listDelete(MAV_list *l);

int mav_listSize(MAV_list *l);

## Description

- mav_listNew creates a new list, and returns a handle to the list. Lists preserve elements in the order in which they were inserted into the list. `MAV_list`'s are implemented as linked-lists each with its own private "list pointer", and a stack on which to save it, which can be used to conveniently step through the list (see mav_listItemNext and related functions).

- mav_listItemAdd appends item `d` to list `l`.

- mav_listItemRmv searches list `l` for item `d` and removes it from the list.

- mav_listItemNext returns, in `d`, the list item currently pointed to by the list pointer of list `l`. The return value of the function is `MAV_TRUE` if the data was successfully returned, otherwise `MAV_FALSE`. The pointer is then moved onto the next item.

- mav_listItemContains searches list `l` for item `d`. The function returns `MAV_TRUE` if the the item is located, otherwise `MAV_FALSE`.

- mav_listPointerReset sets the list pointer of list `l` to point to the beginning of the list.

- mav_listPointerPush This function pushes the list pointer for list `l` onto its stack. The value of the list pointer is unchanged.

- mav_listPointerPop pops the list pointer for list `l` from its stack.

- mav_listEmpty deletes all the linked-list nodes from list `l`. It does not, however, delete the data referenced by the nodes in the list. After calling this function, `l` refers to an empty list, which can be used again.

- mav_listDelete deletes all the nodes in list `l`. It does not, however, delete any data referenced by the nodes in the list. After calling this function, `l` is undefined.

- mav_listSize returns the number of items in list `l`.

Back to the index page.