Navigation: Up, Table of Contents, Bibliography, Index, Title Page

list (list)

Definition

An object of the class list is a sequence that supports bidirectional iterators and allows constant time insert and erase operations anywhere within the sequence.

#include <list.h>

Types

list<T>::iterator
A mutable bidirectional iterator.

list<T>::const_iterator
A const bidirectional iterator.

Creation

list<T> L;
Introduces an empty list.

list<T> L ( list<T> q);
Copy constructor.

list<T> L ( int n, T t = T());
Introduces a list with n items, all initialized to t.

Operations

list<T> & L = list<T> L1 Assignment.
bool L == list<T> L1 Test for equality: Two lists are equal, iff they have the same size and if their corresponding elements are equal.
bool L != list<T> L1 Test for inequality.
iterator L.begin () Returns a mutable iterator referring to the first element in list L.
const_iterator L.begin () const Returns a constant iterator referring to the first element in list L.
iterator L.end () Returns a mutable iterator which is the past-end-value of list L.
const_iterator L.end () const Returns a constant iterator which is the past-end-value of list L.
bool L.empty () Returns true if L is empty.
int L.size () Returns the number of items in list L.
T& L.front () Returns a reference to the first item in list L.
T L.front () const Returns a const reference to the first item in list L.
T& L.back () Returns a reference to the last item in list L.
T L.back () const Returns a const reference to the last item in list L.

Insertion

void L.push_front ( T) Inserts an item in front of list L.
void L.push_back ( T) Inserts an item at the back of list L.
iterator L.insert ( iterator pos, T t)
Inserts a copy of t in front of iterator pos. The return value points to the inserted item.
void L.insert ( iterator pos, int n, T t = T())
Inserts n copies of t in front of iterator pos.
void
L.insert ( iterator pos,
const_iterator first,
const_iterator last)
Inserts a copy of the range [.first, last.) in front of iterator pos.

Removal

void L.pop_front () Removes the first item from list L.
void L.pop_back () Removes the last item from list L.
void L.erase ( iterator pos) Removes the item from list L, where pos refers to.
void L.erase ( iterator first, iterator last)
Removes the items in the range[.first, last.) from list L.


Next: Class declaration of vector<T>
Navigation: Up, Table of Contents, Bibliography, Index, Title Page
The CGAL Project. Mon, June 30, 1997.