multimap

list

The list class supports a list. Its template specification is

template <class T, class Allocator = allocator<T> > class list

Here, T is the type of data stored in the list. It has the following constructors:

explicit list(const Allocator &a = Allocator( ) );
explicit list(size_type num, const T &val = T ( ),
                               const Allocator &a = Allocator( ));
list(const list<T, Allocator> &ob);
template <class InIter>list(InIter start, InIter end,
                                const Allocator &a = Allocator( ));

The first form constructs an empty list. The second form constructs a list that has num elements with the value val. The third form constructs a list that contains the same elements as ob. The fourth form constructs a list that contains the elements in the range specified by start and end.

The following comparison operators are defined for list:

==, <, <=, !=, >, >=

list contains the following member functions:

Member

Description

template <class InIter>
  void assign(InIter start, InIter end);

Assigns the list the sequence defined by start and end.

void assign(size_type num, const T &val);

Assigns the list num elements of value val.

reference back( );
const_reference back( ) const;

Returns a reference to the last element in the list.

iterator begin( );
const_iterator begin( ) const;

Returns an iterator to the first element in the list.

void clear( );

Removes all elements from the list.

bool empty( ) const;

Returns true if the invoking list is empty and false otherwise.

iterator end( );
const_iterator end( ) const;

Returns an iterator to the end of the list.

iterator erase(iterator i);

Removes the element pointed to by i. Returns an iterator to the element after the one removed.

iterator erase(iterator start, iterator end);

Removes the elements in the range start to end. Returns an iterator to the element after the last element removed.

reference front( );
const_reference front( ) const;

Returns a reference to the first element in the list.

allocator_type get_allocator( ) const;

Returns list’s allocator.

iterator insert(iterator i,
                        const T &val = T( ));

Inserts val immediately before the element specified by i. An iterator to the element is returned.

void insert(iterator i, size_type num,
                   const T & val);

Inserts num copies of val immediately before the element specified by i.

template <class InIter>
   void insert(iterator i,
                       InIter start, InIter end);

Inserts the sequence defined by start and end immediately before the element specified by i.

size_type max_size( ) const;

Returns the maximum number of elements that the list can hold.

void merge(list<T, Allocator> &ob);
template <class Comp>
   void merge(<list<T,  Allocator> &ob,
                        Comp cmpfn);

Merges the ordered list contained in ob with the ordered invoking list. The result is ordered. After the merge, the list contained in ob is empty. In the second form, a comparison function can be specified that determines when one element is less than another.

void pop_back( );

Removes the last element in the list.

void pop_front( );

Removes the first element in the list.

void push_back(const T &val);

Adds an element with the value specified by val to the end of the list.

void push_front(const T &val);

Adds an element with the value specified by val to the front of the list.

reverse_iterator rbegin( );
const_reverse_iterator rbegin( ) const;

Returns a reverse iterator to the end of the list.

void remove(const T &val);

Removes elements with the value val from the list.

template <class UnPred>
   void Remove_if(UnPred pr);

Removes elements for which the unary predicate pr is true.

reverse_iterator rend( );
const_reverse_iterator rend( ) const;

Returns a reverse iterator to the start of the list.

void resize(size_type num, T val = T ( ));

Changes the size of the list to that specified by num. If the list must be lengthened, those elements with the value specified by val are added to the end.

void reverse( );

Reverses the invoking list.

size_type size( ) const;

Returns the number of elements currently in the list.

void sort( );
template <class Comp>
   void sort(Comp cmpfn);

Sorts the list. The second form sorts the list using the comparison function cmpfn to determine when one element is less than another.

void splice(iterator i,
                   list<T, Allocator> &ob);

The contents of ob are inserted into the invoking list at the location pointed to by i. After the operation, ob is empty.

void splice(iterator i,
                   list<T, Allocator> &ob,
                   iterator el);

The element pointed to by el is removed from the list ob and stored in the invoking list at the location pointed to by i.

void splice(iterator i,
                   list<T, Allocator> &ob,
                   iterator start, iterator end);

The range defined by start and end is removed from ob and stored in the invoking list beginning at the location pointed to by i.

void swap(list<T, Allocator> &ob);

Exchanges the elements stored in the invoking list with those in ob.

void unique( );
template <class BinPred>
  void unique(BinPred pr);

Removes duplicate elements from the invoking list. The second form uses pr to determine uniqueness.




C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net