Return to Index
List
A templated linked list collection class. The list
is singly-linked, and can be traversed using the
first() / next() methods. The list can only
store pointers to objects. Therefore, the declaration
List‹ SomeClass › my_list;
declares a list of pointers of type SomeClass. Then, a list
traversal is of the following form:
SomeClass *ptr = my_list.first();
while (ptr) {
...
ptr = my_list.next();
}
List::List |
List::List();
Creates a new list class. |
void List::setAutoDelete |
void List::setAutoDelete(bool b);
or when the the list itself is deleted. |
Parameters: |
bool | b | Enable or disable auto-deletion. |
|
void List::clear |
void List::clear();
Empties the list of all objects, deleting them if auto-deletion is enabled. |
int List::length |
int List::length();
Returns the length of the list. |
type* List::first |
type* List::first();
Returns the first object in the collection. |
type* List::next |
type* List::next();
Returns the next object in the collection. |
void List::prepend |
void List::prepend(type* data);
Prepends an object to the beginning of the list. |
Parameters: |
type* | data | A pointer to an instance of the appropriate object type. |
|
void List::append |
void List::append(type* data);
Appends an object to the end of the list. |
Parameters: |
type* | data | A pointer to an instance of the appropriate object type. |
|
void List::insert |
void List::insert(type* data, int index);
Inserts an object into the list at the specified position. |
Parameters: |
type* | data | A pointer to an instance of the appropriate object type. |
int | index | The insertion position. |
|
type* List::find |
type* List::find(type* data);
Searchs the list for the specified object.
Returns: NULL is returned if the object is not found, but otherwise a pointer to the object. |
Parameters: |
type* | data | The object to search for. |
|
type* List::unlink |
type* List::unlink(type* data);
Unlinks an object from the list and returns a pointer to it. This is unaffected by auto-deletion. |
Parameters: |
type* | data | The object to unlink. |
|
bool List::remove |
bool List::remove(type* data);
Removes an object from the list. If auto-deletion is enabled, the object will be delete also.
Returns: Returns true if the removal succeeded. |
Parameters: |
type* | data | The object to remove. |
|
Generated automatically by docgen 0.0.1
© 2003 Aron Dobos