tac0S
Template Affectional Command Operating System
Public Member Functions | List of all members
List Class Reference

Public Member Functions

 List ()
 List::List Initialize a list, empty to start with. Elements can now be added to the list.
 
 ~List ()
 List::~List Prepare a list for deallocation. If the list still contains any ListElements, de-allocate them. However, note that we do not de-allocate the "items" on the list – this module allocates and de-allocates the ListElements to keep track of each item, but a given item may be on multiple lists, so we can't de-allocate them here.
 
void Prepend (void *item)
 List::Prepend Put an "item" on the front of the list. More...
 
void Append (void *item)
 List::Append Append an "item" to the end of the list. More...
 
void * Remove ()
 List::Remove Remove the first "item" from the front of the list. More...
 
void Mapcar (VoidFunctionPtr func)
 List::Mapcar Apply a function to each item on the list, by walking through the list, one element at a time. More...
 
bool IsEmpty ()
 List::IsEmpty. More...
 
void SortedInsert (void *item, long long sortKey)
 List::SortedInsert Insert an "item" into a list, so that the list elements are sorted in increasing order by "sortKey". More...
 
void * SortedRemove (long long *keyPtr)
 List::SortedRemove Remove the first "item" from the front of a sorted list. More...
 
void * get (unsigned int index)
 List::get Get an object at the place "i". More...
 
unsigned int size ()
 List::size Return the size of the current list. More...
 
bool removeElement (void *ElementAdress)
 List::removeElemen Remove the element where the index is equal to the ElementAdress parameter. More...
 

Member Function Documentation

void List::Append ( void *  item)

List::Append Append an "item" to the end of the list.

Allocate a ListElement to keep track of the item. If the list is empty, then this will be the only element. Otherwise, put it at the end.

Parameters
itemis the thing to put on the list, it can be a pointer to anything.
void * List::get ( unsigned int  index)

List::get Get an object at the place "i".

Parameters
int index: the place where it should be
Returns
"void *" : return the adress of the object, null if impossible
bool List::IsEmpty ( )

List::IsEmpty.

Returns
Returns TRUE if the list is empty (has no items).
void List::Mapcar ( VoidFunctionPtr  func)

List::Mapcar Apply a function to each item on the list, by walking through the list, one element at a time.

Unlike LISP, this mapcar does not return anything!

Parameters
funcis the procedure to apply to each element of the list.
void List::Prepend ( void *  item)

List::Prepend Put an "item" on the front of the list.

Allocate a ListElement to keep track of the item. If the list is empty, then this will be the only element. Otherwise, put it at the beginning.

Parameters
itemis the thing to put on the list, it can be a pointer to anything.
void * List::Remove ( )

List::Remove Remove the first "item" from the front of the list.

Returns:

Returns
Pointer to removed item, NULL if nothing on the list.
bool List::removeElement ( void *  ElementAdress)

List::removeElemen Remove the element where the index is equal to the ElementAdress parameter.

Parameters
ElementAdressvoid *
Returns
unsigned int List::size ( )

List::size Return the size of the current list.

Returns
"unsigned int" : the size of the list
void List::SortedInsert ( void *  item,
long long  sortKey 
)

List::SortedInsert Insert an "item" into a list, so that the list elements are sorted in increasing order by "sortKey".

Allocate a ListElement to keep track of the item. If the list is empty, then this will be the only element. Otherwise, walk through the list, one element at a time, to find where the new item should be placed.

Parameters
itemis the thing to put on the list, it can be a pointer to anything.
sortKeyis the priority of the item.
void * List::SortedRemove ( long long *  keyPtr)

List::SortedRemove Remove the first "item" from the front of a sorted list.

Returns:

Returns
Pointer to removed item, NULL if nothing on the list. Sets *keyPtr to the priority value of the removed item (this is needed by interrupt.cc, for instance).

@param "keyPtr" is a pointer to the location in which to store the priority of the removed item.


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