User manual:   Main Page   Overview   Installation   User Interface   Tutorial   Example   FAQ   Version Updates
Reference manual:   Class List   Class Members   Globals, enums and defines

LinkedList< T > Class Template Reference

Defines a template for a linked list. More...

List of all members.

Public Methods

 LinkedList ()
 LinkedList (const LinkedList< T > &list)
 ~LinkedList ()
void operator= (LinkedList< T > &list)
bool empty () const
long size () const
bool contains (const T &value)
bool contains (const T &value, iterator &iter)
void clear ()
bool erase (iterator iter)
bool erase (iterator iterBegin, iterator iterEnd)
bool remove (const T &value)
bool removeAndCount (const T &value, long &count)
bool push_back_list (LinkedList< T > *list)
bool push_front (const T &value)
bool push_back (const T &value)
bool push_front_unique (const T &value)
bool push_back_unique (const T &value)
pop_front ()
pop_back ()
T & front ()
T & back ()
iterator begin ()
iterator end ()
iteratorinsertAfter (iterator *iter, const T &value)
iteratorinsertBefore (iterator *iter, const T &value)


Detailed Description

template<class T>
class LinkedList< T >

Defines a template for a linked list.

A list can only hold values of one type, T, defined when the list is created. For example, the following list:

 LinkedList<int> mylist 
can only hold values of type int


Constructor & Destructor Documentation

template<class T>
LinkedList< T >::LinkedList   [inline]
 

Constructor.

Initializes an empty list

template<class T>
LinkedList< T >::LinkedList const LinkedList< T > &    list [inline]
 

Copy constructor.

Initializes the list with a copy of list

template<class T>
LinkedList< T >::~LinkedList   [inline]
 

Destructor, clears the list and frees memory.


Member Function Documentation

template<class T>
T& LinkedList< T >::back   [inline]
 

Returns the last element of the list (without removing it).

If the list is empty, the function fails and calls exit(1)

Returns:
A reference of the last element of the list

template<class T>
iterator LinkedList< T >::begin   [inline]
 

Returns an iterator pointing to the first element of the list.

Returns:
An iterator pointing to first element of the list
See also:
Usage for begin() and end() in the documentation for LinkedList::iterator

template<class T>
void LinkedList< T >::clear   [inline]
 

Clears the list (removes all elements).

template<class T>
bool LinkedList< T >::contains const T &    value,
iterator   iter
[inline]
 

Checks if the given value is found in the list, and if so, returns an iterator pointing to it.

Parameters:
value The value to check for existence in the list
iter [output] An iterator pointing to the element in the list with the given value
Return values:
true value is found in the list
false value is not found in the list

template<class T>
bool LinkedList< T >::contains const T &    value [inline]
 

Checks if the given value is found in the list.

Parameters:
value The value to check for existence in the list
Return values:
true value is found in the list
false value is not found in the list

template<class T>
bool LinkedList< T >::empty   const [inline]
 

Checks if list is empty.

Return values:
true The list is empty
false The list is not empty (at least one element)

template<class T>
iterator LinkedList< T >::end   [inline]
 

Returns an iterator pointing to a dummy element, which is an element after the last element of the list.

Returns:
An iterator pointing to first element of the list
See also:
Usage for begin() and end() in the documentation for LinkedList::iterator

template<class T>
bool LinkedList< T >::erase iterator    iterBegin,
iterator    iterEnd
[inline]
 

Remove all elements in the list between the element pointed by iterBegin, and the element pointed by iterEnd (including both).

Parameters:
iterBegin An iterator pointing to the first element to erase
iterEnd An iterator pointing to the last element to erase
Return values:
true Elements removed succesfully
false Operation failed (iterBegin or iterEnd were not pointing to valid elements)

template<class T>
bool LinkedList< T >::erase iterator    iter [inline]
 

Remove the element pointed by iter.

Parameters:
iter An iterator pointing to the element to erase
Return values:
true Element removed succesfully
false Operation failed (iter was not pointing to a valid element)

template<class T>
T& LinkedList< T >::front   [inline]
 

Returns the first element of the list (without removing it).

If the list is empty, the function fails and calls exit(1)

Returns:
A reference of the first element of the list

template<class T>
iterator* LinkedList< T >::insertAfter iterator   iter,
const T &    value
[inline]
 

Inserts a new element with the given value to the list, after the element pointed to by iter.

Parameters:
iter The iterator after which the element should be added
value The value to add
Returns:
If iter is NULL, the value is not inserted and the function returns NULL; else, the function returns an iterator pointing to the element holding the new value

template<class T>
iterator* LinkedList< T >::insertBefore iterator   iter,
const T &    value
[inline]
 

Inserts a new element with the given value to the list, before the element pointed to by iter.

Parameters:
iter The iterator after which the element should be added
value The value to add
Returns:
If iter is NULL, the value is not inserted and the function returns NULL; else, the function returns an iterator pointing to the element holding the new value

template<class T>
void LinkedList< T >::operator= LinkedList< T > &    list [inline]
 

Copies all elements of list to the current list (clears current list first).

Parameters:
list The list to copy

template<class T>
T LinkedList< T >::pop_back   [inline]
 

Remove the last element of the list and return it.

If the list is already empty, the function fails and calls exit(1) (after printing an error message)

Returns:
The value of the last element of the list (which was removed)

template<class T>
T LinkedList< T >::pop_front   [inline]
 

Remove the first element of the list and return it.

If the list is already empty, the function fails and calls exit(1) (after printing an error message)

Returns:
The value of the first element of the list (which was removed)

template<class T>
bool LinkedList< T >::push_back const T &    value [inline]
 

Insert a new element with the given value to the end of the list.

Parameters:
value The value of the element to add
Return values:
true Operation succeeded
false Operation failed

template<class T>
bool LinkedList< T >::push_back_list LinkedList< T > *    list [inline]
 

Copies the given list at the end of the current list.

Parameters:
list The list to copy
Return values:
true Operation succeeded
false Operation failed (list is NULL)

template<class T>
bool LinkedList< T >::push_back_unique const T &    value [inline]
 

Insert a new element with the given value to the end of the list, only if the same value is not already contained in the list.

Parameters:
value The value of the element to add
Return values:
true Operation succeeded (element added)
false Operation failed (value already exists in the list)

template<class T>
bool LinkedList< T >::push_front const T &    value [inline]
 

Insert a new element with the given value to the head of the list.

Parameters:
value The value of the element to add
Return values:
true Operation succeeded
false Operation failed

template<class T>
bool LinkedList< T >::push_front_unique const T &    value [inline]
 

Insert a new element with the given value to the head of the list, only if the same value is not already contained in the list.

Parameters:
value The value of the element to add
Return values:
true Operation succeeded (element added)
false Operation failed (value already exists in the list)

template<class T>
bool LinkedList< T >::remove const T &    value [inline]
 

Remove all the elements in the list whose value is equal to the given value.

Parameters:
value The value to remove from the list
Return values:
true Operation succeeded
false No element was removed (none with the given value)

template<class T>
bool LinkedList< T >::removeAndCount const T &    value,
long &    count
[inline]
 

Remove all the elements in the list whose value is equal to the given value, and count the number of elements removed.

Parameters:
value The value to remove from the list
count [output] The number of elements removed from the list
Return values:
true Operation succeeded
false No element was removed (none with the given value)

template<class T>
long LinkedList< T >::size   const [inline]
 

Returns the list size (number of elements in the list).

Returns:
The list size


The documentation for this class was generated from the following file:
MeshMaker 5.2 Manual
This software library was written by Roni Raab, ronir@cs.technion.ac.il.
Last updated on May 2003.
This software is for academic and research use only.