GL Studio C++ Runtime API
List_c Class Reference

#include <list.h>

Inheritance diagram for List_c:
TextureLoaderList

Public Member Functions

int IsEmpty ()
 
void Empty ()
 
ListItemFirst ()
 
ListItemLast ()
 
ListItemNth (int where)
 
void InsertAfter (int where, const void *data, int size, void **parentPtr)
 
void InsertAfter (ListItem *after, const void *data, int size, void **parentPtr)
 
void InsertAfter (ListItem *after, ListItem *pNewNode)
 
void InsertBefore (ListItem *before, ListItem *pNewNode)
 
void Push (const void *data, int size, void **parentPtr)
 
void Push (const void *data, int size)
 
void Push (ListItem *pNewNode)
 
void Enqueue (const void *data, int size, void **parentPtr)
 
void Enqueue (const void *data, int size)
 
void Enqueue (ListItem *pNewNode)
 
void * Dequeue ()
 
void * GetElement (int where)
 
int Count ()
 
void Delete (ListItem *element)
 
void AddNodeWithPriority (ListItem *pNewNode, int priority)
 
void AddNodeWithPriority (const void *data, int size, int priority)
 
void ForwardIterator (ListIterator func, void *data=NULL)
 
void BackwardIterator (ListIterator func, void *data=NULL)
 
void Iterator (ListIterator func, void *data, ListIteratorDirection direction)
 

Public Attributes

int _count
 Number of items in the list.
 

Protected Attributes

ListItem_pHead
 Pointer to the head (first item) of the list.
 
ListItem_pTail
 Pointer to the tail (last item) of the list.
 

Detailed Description

Implements a doubly Linked List

Member Function Documentation

◆ AddNodeWithPriority() [1/2]

void AddNodeWithPriority ( const void *  data,
int  size,
int  priority 
)

Adds a new node (item) to the list. The item position will be determined based on its priority. This method will dynamically allocate space for the data

Parameters
dataPointer to the data to be added
sizeSize of the data to be added
prioritySorting priority

◆ AddNodeWithPriority() [2/2]

void AddNodeWithPriority ( ListItem pNewNode,
int  priority 
)

Adds a new node (item) to the list. The item position will be determined based on its priority.

Parameters
pNewNodeA previously allocated list node containing the data to add
prioritySorting priority

◆ BackwardIterator()

void BackwardIterator ( ListIterator  func,
void *  data = NULL 
)

Iterates through the list in reverse order, calling the supplied function on each element and passing the supplied data to that function

Parameters
funcListIterator function to call
dataData that will be supplied to each call of the list iterator function

◆ Count()

int Count ( )
Returns
The number of items in this list

◆ Delete()

void Delete ( ListItem element)

Deletes the specified list element. Frees the data pointed to by the element.

Parameters
elementThe element to delete

◆ Dequeue()

void * Dequeue ( )

Gets a pointer to the data in the first element of the list. The list element will be freed. The user should free the data returned by this call.

Returns
Data pointed to by the first element in the list or NULL if the list is empty

◆ Empty()

void Empty ( )

Empties the list (deletes all the elements)

◆ Enqueue() [1/3]

void Enqueue ( const void *  data,
int  size 
)

Inserts the given data at the end of the list. A new ListItem will be allocated, space will be allocated for the data passed in

Parameters
dataPointer to the data to insert
sizeSize of the data to insert

◆ Enqueue() [2/3]

void Enqueue ( const void *  data,
int  size,
void **  parentPtr 
)

Inserts the given data at the end of the list. A new ListItem will be allocated, space will be allocated for the data passed in

Parameters
dataPointer to the data to insert
sizeSize of the data to insert
parentPtrWill be filled in with a pointer to the ListItem that this method allocates

◆ Enqueue() [3/3]

void Enqueue ( ListItem pNewNode)

Inserts the given list element at the end of the list

Parameters
pNewNodeA previously allocated ListItem to insert

◆ First()

ListItem * First ( )

Get a pointer to the first ListItem in the list

Returns
Pointer to the first ListItem in the list or NULL if the list is empty

◆ ForwardIterator()

void ForwardIterator ( ListIterator  func,
void *  data = NULL 
)

Iterates through the list from head to tail, calling the supplied function on each element and passing the supplied data to that function

Parameters
funcListIterator function to call
dataData that will be supplied to each call of the list iterator function

◆ GetElement()

void * GetElement ( int  where)

Gets a pointer to the data at the given "index" into the list.

Parameters
whereThe index into the list.
Returns
A pointer to the data or NULL if the index is invalid.

◆ InsertAfter() [1/3]

void InsertAfter ( int  where,
const void *  data,
int  size,
void **  parentPtr 
)

Inserts the given data at designated index in the list. If the index is greater than the list size, the element will be inserted at the end of the list A new ListItem will be allocated, space will be allocated for the data passed in

Parameters
whereThe zero based index
dataPointer to the data to insert
sizeSize of the data to insert
parentPtrWill be filled in with a pointer to the ListItem that this method allocates

◆ InsertAfter() [2/3]

void InsertAfter ( ListItem after,
const void *  data,
int  size,
void **  parentPtr 
)

Inserts the given data after the specified list item A new ListItem will be allocated, space will be allocated for the data passed in

Parameters
afterPointer to the list element to insert after
dataPointer to the data to insert
sizeSize of the data to insert
parentPtrWill be filled in with a pointer to the ListItem that this method allocates

◆ InsertAfter() [3/3]

void InsertAfter ( ListItem after,
ListItem pNewNode 
)

Inserts the given list element after the specified list element

Parameters
afterPointer to the list element to insert after
pNewNodeA previously allocated ListItem to insert

◆ InsertBefore()

void InsertBefore ( ListItem before,
ListItem pNewNode 
)

Inserts the given list element before the specified list element

Parameters
beforePointer to the list element to insert before
pNewNodeA previously allocated ListItem to insert

◆ IsEmpty()

int IsEmpty ( )

Returns whether or not the list is empty

Returns
Whether or not the list is empty

◆ Iterator()

void Iterator ( ListIterator  func,
void *  data,
ListIteratorDirection  direction 
)

Iterates through the list in the specified direction, calling the supplied function on each element and passing the supplied data to that function

Parameters
funcListIterator function to call
dataData that will be supplied to each call of the list iterator function
directionWhich directon to iterate

◆ Last()

ListItem * Last ( )

Get a pointer to the first ListItem in the list

Returns
Pointer to the first ListItem in the list or NULL if the list is empty

◆ Nth()

ListItem * Nth ( int  where)

Get a pointer to the ListItem for the Nth element

Parameters
where0 based array index
Returns
Pointer to the ListItem at that index or NULL if the list is empty

◆ Push() [1/3]

void Push ( const void *  data,
int  size 
)

Inserts the given data at the front of the list. A new ListItem will be allocated, space will be allocated for the data passed in

Parameters
dataPointer to the data to insert
sizeSize of the data to insert

◆ Push() [2/3]

void Push ( const void *  data,
int  size,
void **  parentPtr 
)

Inserts the given data at the front of the list. A new ListItem will be allocated, space will be allocated for the data passed in

Parameters
dataPointer to the data to insert
sizeSize of the data to insert
parentPtrWill be filled in with a pointer to the ListItem that this method allocates

◆ Push() [3/3]

void Push ( ListItem pNewNode)

Inserts the given list element at the front of the list

Parameters
pNewNodeA previously allocated ListItem to insert

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