defs/si_std/list.h File Reference

Generic list container. Not meant to be used directly. More...

#include <si_sys/defs.h>
#include <si_sys/blkalloc.h>

Go to the source code of this file.

Classes

struct  sc_listNode
 Generic list node structure. More...
struct  sc_list
 Generic list object. Not meant to be used directly. More...
struct  sc_listNodeDescriptor
 List node descriptor. More...
struct  sc_listIterator
 List iterator. More...

Typedefs

typedef struct sc_listNodeAllocator sc_listNodeAllocator
List item function signatures.


typedef sc_status(* sc_listNode_constructCopyf )(void *pitem, void *pothr)
typedef sc_status(* sc_listNode_assignf )(void *pitem, void *pothr)
typedef sc_status(* sc_listNode_destructf )(void *pitem)

Functions

sc_status sc_listIterator_init (sc_listIterator *pit)
sc_status sc_listIterator_next (sc_listIterator *pit)
sc_status sc_listIterator_prev (sc_listIterator *pit)
sc_status sc_list_construct (sc_list *pl, const sc_listNodeDescriptor *ndesc, s_int32 initialCapacity, s_int32 maxCapacity)
sc_status sc_list_destruct (sc_list *pl)
sc_status sc_list_getBegin (sc_list *pl, sc_listIterator *pit)
sc_status sc_list_getEnd (sc_list *pl, sc_listIterator *pit)
sc_status sc_list_getIsEmpty (sc_list *pl, s_bool *pIsEmpty)
sc_status sc_list_clear (sc_list *pl)
sc_status sc_list_insert (sc_list *pl, sc_listIterator *it, void *nt)
sc_status sc_list_erase (sc_list *pl, sc_listIterator *it)
sc_status sc_list_remove (sc_list *pl, sc_listIterator *it)
sc_status sc_list_pushBack (sc_list *pl, void *pnt)
sc_status sc_list_pushFront (sc_list *pl, void *pnt)
sc_status sc_list_popBack (sc_list *pl, void *pnt)
sc_status sc_list_popFront (sc_list *pl, void *pnt)
sc_status sc_list_front (sc_list *pl, void **ppnt)
sc_status sc_list_back (sc_list *pl, void **ppnt)
sc_status sc_list_getSize (sc_list *pl, s_uint32 *sz)


Detailed Description

Generic list container. Not meant to be used directly.

See also:
listt.h for an implementation of typesafe lists.

Typedef Documentation

typedef sc_status(* sc_listNode_assignf)(void *pitem, void *pothr)

Item assignment operator.

Parameters:
[in] pitem The item to assign to.
[in] pothr The value to assign.

typedef sc_status(* sc_listNode_constructCopyf)(void *pitem, void *pothr)

Item copy constructor.

Parameters:
[in] pitem The item to construct.
[in] pothr The item to copy.

typedef sc_status(* sc_listNode_destructf)(void *pitem)

Item destructor.

Parameters:
[in] pitem The item to destruct.


Function Documentation

sc_status sc_list_back ( sc_list pl,
void **  ppnt 
)

Returns a pointer to the last item in the list.

An error is returned if the list is empty.

Parameters:
[in,out] pl The list
[out] ppnt The item pointer to modify.

sc_status sc_list_clear ( sc_list pl  ) 

Erases all items from the list.

Parameters:
[in,out] pl The list to clear.

sc_status sc_list_construct ( sc_list pl,
const sc_listNodeDescriptor ndesc,
s_int32  initialCapacity,
s_int32  maxCapacity 
)

Generic list container constructor.

Parameters:
[in,out] pl The list object to construct.
[in] ndesc The descriptor for the list items.
[in] initialCapacity The allocator will make sure there is enough storage for initialCapacity items to be added without allocator growth.
[in] maxCapacity The maximum number of items the list is allowed to hold. If no particular maximum is desired, set this INT_MAX.

sc_status sc_list_destruct ( sc_list pl  ) 

Generic list destructor.

Parameters:
[in,out] pl The list object to destruct.

sc_status sc_list_erase ( sc_list pl,
sc_listIterator it 
)

Erase the element 'it' from the given list.

The element is removed from the list and freed.

Parameters:
[in,out] pl The list to remove from.
[in] it The list element to remove and free.

sc_status sc_list_front ( sc_list pl,
void **  ppnt 
)

Returns a pointer to the item at the front of the list.

An error is returned if the list is empty.

Parameters:
[in,out] pl The list
[out] ppnt The item pointer to modify.

sc_status sc_list_getBegin ( sc_list pl,
sc_listIterator pit 
)

Returns an iterator positioned at the first element of the list.

If the list is empty, this will be the end of the list.

Parameters:
[in,out] pl The list.
[in,out] pit The iterator to position.

sc_status sc_list_getEnd ( sc_list pl,
sc_listIterator pit 
)

Returns an iterator positioned past the last element of the list.

Parameters:
[in,out] pl The list.
[in,out] pit The iterator to position.

sc_status sc_list_getIsEmpty ( sc_list pl,
s_bool *  pIsEmpty 
)

Returns seTrue if the list is empty and seFalse otherwise.

Parameters:
[in,out] pl The list to test.
[out] pIsEmpty On exit, set to seTrue if the list is empty, seFalse otherwise.

sc_status sc_list_getSize ( sc_list pl,
s_uint32 *  sz 
)

Returns the number of elements in the list.

Parameters:
[in,out] pl The list
[out] sz The size of the list

sc_status sc_list_insert ( sc_list pl,
sc_listIterator it,
void *  nt 
)

Inserts new item nt into the given list, after the element pointed to by 'it'.

Parameters:
[in,out] pl The list to modify.
[in] it The element after which the insert should occur.
[in] nt The new item to insert.

sc_status sc_list_popBack ( sc_list pl,
void *  pnt 
)

Pops an item from the end of the list.

An error is returned if the list is empty.

Parameters:
[in,out] pl The list to modify.
[in] pnt The item to which the popped value will be assigned.
Note:
Items are popped by value. If you want the list to refer to particular objects, consider making a list of pointer handles.

sc_status sc_list_popFront ( sc_list pl,
void *  pnt 
)

Pops an item from the front of the list.

An error is returned if the list is empty.

Parameters:
[in,out] pl The list to modify.
[in] pnt The item to which the popped value will be assigned.
Note:
Items are popped by value. If you want the list to refer to particular objects, consider making a list of pointer handles.

sc_status sc_list_pushBack ( sc_list pl,
void *  pnt 
)

Pushes a new item onto the end of the list.

Parameters:
[in,out] pl The list to modify.
[in] pnt The item to add.
Note:
Items are added by value. If you want the list to refer to particular objects, consider making a list of pointer handles.

sc_status sc_list_pushFront ( sc_list pl,
void *  pnt 
)

Pushes a new item onto the front of the list.

Parameters:
[in,out] pl The list to modify.
[in] pnt The item to add.
Note:
Items are added by value. If you want the list to refer to particular objects, consider making a list of pointer handles.

sc_status sc_list_remove ( sc_list pl,
sc_listIterator it 
)

Remove the element 'it' from the given list.

The element is removed from the list.

Parameters:
[in,out] pl The list to remove from.
[in] it The list element to remove.

sc_status sc_listIterator_init ( sc_listIterator pit  ) 

Init the iterator to NULL. In this state isEnd returns seTrue.

sc_status sc_listIterator_next ( sc_listIterator pit  ) 

Move the iterator to the next element.

sc_status sc_listIterator_prev ( sc_listIterator pit  ) 

Move the iterator to the previous element.


doxygen