| GL Studio C++ Runtime API

Public Member Functions | Public Attributes | Protected Attributes | List of all members
List_c Class Reference

`#include <list.h>`

Inheritance diagram for List_c:

## Public Member Functions
int | IsEmpty ()
void | Empty ()
ListItem * | First ()
ListItem * | Last ()
ListItem * | Nth (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

  data | Pointer to the data to be added
  size | Size of the data to be added
  priority | Sorting 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

  pNewNode | A previously allocated list node containing the data to add
  priority | Sorting 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

  func | ListIterator function to call
  data | Data 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

  element | The 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

  data | Pointer to the data to insert
  size | Size 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

  data | Pointer to the data to insert
  size | Size of the data to insert
  parentPtr | Will 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

  pNewNode | A 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

  func | ListIterator function to call
  data | Data 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

  where | The 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

  where | The zero based index
  data | Pointer to the data to insert
  size | Size of the data to insert
  parentPtr | Will 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

  after | Pointer to the list element to insert after
  data | Pointer to the data to insert
  size | Size of the data to insert
  parentPtr | Will 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

  after | Pointer to the list element to insert after
  pNewNode | A previously allocated ListItem to insert

## ◆ InsertBefore()

void InsertBefore | ( | ListItem * | before,
|  | ListItem * | pNewNode
| ) |  |

Inserts the given list element before the specified list element

Parameters

  before | Pointer to the list element to insert before
  pNewNode | A 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

  func | ListIterator function to call
  data | Data that will be supplied to each call of the list iterator function
  direction | Which 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

  where | 0 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

  data | Pointer to the data to insert
  size | Size 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

  data | Pointer to the data to insert
  size | Size of the data to insert
  parentPtr | Will 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

  pNewNode | A previously allocated ListItem to insert

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

- list.h