#include <list.h>
Public Member Functions | |
List () | |
List (const List< T > &) throw ( bad_alloc ) | |
~List () | |
unsigned | size () const |
void | clear () |
bool | empty () const |
void | push_back (const T &) throw ( bad_alloc ) |
void | push_front (const T &) throw ( bad_alloc ) |
T | pop_front () throw ( ListEmpty ) |
T | pop_back () throw ( ListEmpty ) |
T & | getFront () const throw ( ListEmpty ) |
T & | getCurrent () const throw ( ListEmpty ) |
T & | getBack () const throw ( ListEmpty ) |
void | insertBeforeCurrent (const T &) throw ( ListEmpty, bad_alloc ) |
void | insertAfterCurrent (const T &) throw ( ListEmpty, bad_alloc ) |
T | removeCurrent () throw ( ListEmpty ) |
void | setToFront () throw ( ListEmpty ) |
void | setToBack () throw ( ListEmpty ) |
void | moveForward () throw ( ListEmpty ) |
void | moveBackward () throw ( ListEmpty ) |
bool | find (const T &) throw ( ListEmpty ) |
bool | atFront () const throw ( ListEmpty ) |
bool | atBack () const throw ( ListEmpty ) |
const List< T > & | operator= (const List< T > &) throw ( bad_alloc) |
Copy constructor.
bad_alloc | if memory cannot be allocated. |
unsigned List< T >::size | ( | ) | const |
Returns the size (i.e., number of elements) of the list.
void List< T >::clear | ( | ) |
Removes the elements in the list.
bool List< T >::empty | ( | ) | const |
Returns true if the list is empty; returns false otherwise.
void List< T >::push_back | ( | const T & | object | ) | throw ( bad_alloc ) |
Adds the object to the back of the list. After adding, sets current to the new node.
object | the object to be added to the back of the list. |
bad_alloc | if memory cannot be allocated. |
void List< T >::push_front | ( | const T & | object | ) | throw ( bad_alloc ) |
Adds the object to the front of the list. After adding, sets current to the new node.
object | the object to be added to the front of the list. |
bad_alloc | if memory cannot be allocated. |
T List< T >::pop_front | ( | ) | throw ( ListEmpty ) |
Removes and returns the object at the front of the list. If current points to the front of the list, then sets current to point to the new front of the list. Otherwise, current is left unchanged.
ListEmpty | if the list is empty. |
T List< T >::pop_back | ( | ) | throw ( ListEmpty ) |
Removes and returns the object at the back of the list. If current points to the back of the list, then sets current to point to the new back of the list. Otherwise, current is left unchanged.
ListEmpty | if the list is empty. |
T & List< T >::getFront | ( | ) | const throw ( ListEmpty ) |
Gets, but does not remove, the object at the front of the list. Current is left unchanged.
ListEmpty | if the list is empty. |
T & List< T >::getCurrent | ( | ) | const throw ( ListEmpty ) |
Gets, but does not remove, the object pointed to by current.
ListEmpty | if the list is empty. |
T & List< T >::getBack | ( | ) | const throw ( ListEmpty ) |
Gets, but does not remove, the object at the back of the list. Current is left unchanged.
ListEmpty | if the list is empty. |
void List< T >::insertBeforeCurrent | ( | const T & | object | ) | throw ( ListEmpty, bad_alloc ) |
Inserts the object before the node pointed to by current. Sets current to point to the new node.
object | the object to be inserted before the current node. |
bad_alloc | if memory cannot be allocated. | |
ListEmpty | if the list is empty. |
void List< T >::insertAfterCurrent | ( | const T & | object | ) | throw ( ListEmpty, bad_alloc ) |
Inserts the object after the node pointed to by current. Sets current to point to the new node.
object | the object to be inserted after the current node. |
bad_alloc | if memory cannot be allocated. | |
ListEmpty | if the list is empty. |
T List< T >::removeCurrent | ( | ) | throw ( ListEmpty ) |
Removes and returns the object in the node pointed to by current. Sets current to the next node, if possible. Otherwise, it sets current to the previous node.
ListEmpty | if the list is empty. |
void List< T >::setToFront | ( | ) | throw ( ListEmpty ) |
Sets current to the first node in the list.
ListEmpty | if the list is empty. |
void List< T >::setToBack | ( | ) | throw ( ListEmpty ) |
Sets current to the last node in the list.
ListEmpty | if the list is empty. |
void List< T >::moveForward | ( | ) | throw ( ListEmpty ) |
Moves current to the next node in the list. If current points to the end of the list, then current is left unchanged.
ListEmpty | if the list is empty. |
void List< T >::moveBackward | ( | ) | throw ( ListEmpty ) |
Move current to the previous node in the list. If current points to the front of the list, then current is left unchanged.
ListEmpty | if the list is empty. |
bool List< T >::find | ( | const T & | object | ) | throw ( ListEmpty ) |
Returns true if the object is found in the list, and sets current to point to the node containing the found item; Returns false otherwise, leaving current unaltered.
object | the object to be found in the list. |
ListEmpty | if the list is empty. |
bool List< T >::atFront | ( | ) | const throw ( ListEmpty ) |
Returns true if current is at the front of the list; Returns false otherwise.
ListEmpty | if the list is empty. |
bool List< T >::atBack | ( | ) | const throw ( ListEmpty ) |
Returns true if current is at the back of the list; Returns false otherwise.
ListEmpty | if the list is empty. |
const List< T > & List< T >::operator= | ( | const List< T > & | list | ) | throw ( bad_alloc) |
Returns a deep copy of the list passed in as the parameter.
list | the list to be copied. |
bad_alloc | if memory cannot be allocated. |