Namespace List   Compound List   File List   Namespace Members   Compound Members  

std::vector Class Reference

List of all members.

Public Members

typedef Allocator::reference reference
typedef Allocator::const_reference const_reference
typedef Allocator::size_type size_type
typedef Allocator::difference_type difference_type
typedef T value_type
typedef Allocator allocator_type
typedef Allocator::pointer pointer
typedef Allocator::const_pointer const_pointer
typedef Allocator::pointer iterator
typedef Allocator::const_pointer const_iterator
typedef std::reverse_iterator<iterator> reverse_iterator
typedef std::reverse_iterator<const_iterator> const_reverse_iterator
explicit vector (const Allocator &alloc = Allocator())
template<class InputIterator>  vector<InputIterator> (InputIterator first, InputIterator last, const Allocator &alloc = Allocator())
explicit vector (size_type n, const T& value = T(), const Allocator &alloc= Allocator())
 ~vector ()
vector<T,Allocator>& operator= (const vector<T,Allocator> &x)
template<class InputIterator> void assign<InputIterator> (InputIterator first, InputIterator last)
allocator_type get_allocator () const
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
reverse_iterator rbegin ()
const_reverse_iterator rbegin () const
reverse_iterator rend ()
const_reverse_iterator rend () const
size_type size () const
size_type max_size () const
void resize (size_type sz, T c = T())
size_type capacity () const
bool empty () const
void reserve (size_type n)
reference operator[] (size_type n)
const_reference operator[] (size_type n) const
const_reference at (size_type n) const
reference at (size_type n)
reference front ()
const_reference front () const
reference back ()
const_reference back () const
void push_back (const T &x)
void pop_back ()
iterator insert (iterator position, const T &x = T())
void insert (iterator position, size_type n, const T& x)
template<class InputIterator> void insert<InputIterator> (iterator position, InputIterator first, InputIterator last)
iterator erase (iterator position)
iterator erase (iterator first, iterator last)
void swap (vector<T,Allocator> &x)
void clear ()


Detailed Description

template<class T, class Allocator = allocator<T>> class std::vector

A vector satisfies all of the requirements of a container and of a reversible container and of a sequence, including most of the optional sequence requirements (_lib.sequence.reqmts_). The excep- tions are the push_front and pop_front member functions, which are not provided. Descriptions are provided here only for operations on vec- tor that are not described in one of these tables or for operations where there is additional semantic information.

Member Typedef Documentation

template<class T, class Allocator = allocator<T>>
typedef Allocator::reference std::vector<T, Allocator>::reference

template<class T, class Allocator = allocator<T>>
typedef Allocator::const_reference std::vector<T, Allocator>::const_reference

template<class T, class Allocator = allocator<T>>
typedef Allocator::size_type std::vector<T, Allocator>::size_type

template<class T, class Allocator = allocator<T>>
typedef Allocator::difference_type std::vector<T, Allocator>::difference_type

template<class T, class Allocator = allocator<T>>
typedef T std::vector<T, Allocator>::value_type

template<class T, class Allocator = allocator<T>>
typedef Allocator std::vector<T, Allocator>::allocator_type

template<class T, class Allocator = allocator<T>>
typedef Allocator::pointer std::vector<T, Allocator>::pointer

template<class T, class Allocator = allocator<T>>
typedef Allocator::const_pointer std::vector<T, Allocator>::const_pointer

template<class T, class Allocator = allocator<T>>
typedef Allocator::pointer std::vector<T, Allocator>::iterator

template<class T, class Allocator = allocator<T>>
typedef Allocator::const_pointer std::vector<T, Allocator>::const_iterator

template<class T, class Allocator = allocator<T>>
typedef std::reverse_iterator<iterator> std::vector<T, Allocator>::reverse_iterator

template<class T, class Allocator = allocator<T>>
typedef std::reverse_iterator<const_iterator> std::vector<T, Allocator>::const_reverse_iterator


Member Function Documentation

template<class T, class Allocator = allocator<T>>
explicit std::vector<T, Allocator>::vector<T, Allocator> (const Allocator & alloc = Allocator())

{		
				vec.size      = 0;
				vec.elements  = 0;
				vec.allocator = alloc;
				vec.offset    = vec.allocator.allocate(0);
			}

template<class T, class Allocator = allocator<T>>
template<class InputIterator>
std::vector<T, Allocator>::vector<T, Allocator> (InputIterator first, InputIterator last, const Allocator & alloc = Allocator())

{
				vec.size      = 0;
				vec.elements  = 0;
				vec.allocator = alloc;
				vec.offset    = vec.allocator.allocate(0);
				insert(begin(), first, last);
			}

template<class T, class Allocator = allocator<T>>
explicit std::vector<T, Allocator>::vector<T, Allocator> (size_type n, const T & value = T(), const Allocator & alloc = Allocator())

{
				vec.size      = 0;
				vec.elements  = 0;
				vec.allocator = alloc;
				vec.offset    = vec.allocator.allocate(0);
				reserve(n);
				/// TODO : insert value
			}

template<class T, class Allocator = allocator<T>>
std::vector<T, Allocator>::~vector<T, Allocator> ()

{
				vec.allocator.deallocate(vec.offset, vec.size);
			}

template<class T, class Allocator = allocator<T>>
vector<T,Allocator>& std::vector<T, Allocator>::operator=<T,Allocator> (const vector<T,Allocator>& x)

{
				vec = x.vec;
			}

template<class T, class Allocator = allocator<T>>
template<class InputIterator>
void std::vector<T, Allocator>::assign (InputIterator first, InputIterator last)

{
				erase(begin(), end());
				insert(begin(), first, last);
			}

template<class T, class Allocator = allocator<T>>
allocator_type std::vector<T, Allocator>::get_allocator () const

{
				return vec.allocator;
			}

template<class T, class Allocator = allocator<T>>
iterator std::vector<T, Allocator>::begin ()

{
				return vec.offset;
			}

template<class T, class Allocator = allocator<T>>
const_iterator std::vector<T, Allocator>::begin () const

{
				return (const_iterator)vec.offset;
			}

template<class T, class Allocator = allocator<T>>
iterator std::vector<T, Allocator>::end ()

{
				return &vec.offset[vec.elements];
			}

template<class T, class Allocator = allocator<T>>
const_iterator std::vector<T, Allocator>::end () const

{
				return &(const_iterator)vec.offset[vec.elements];
			}

template<class T, class Allocator = allocator<T>>
reverse_iterator std::vector<T, Allocator>::rbegin ()

{
				return &vec.offset[vec.elements];
			}

template<class T, class Allocator = allocator<T>>
const_reverse_iterator std::vector<T, Allocator>::rbegin () const

{
				return &(const_reverse_iterator)vec.offset[vec.elements];
			}

template<class T, class Allocator = allocator<T>>
reverse_iterator std::vector<T, Allocator>::rend ()

{
				return vec.offset;
			}

template<class T, class Allocator = allocator<T>>
const_reverse_iterator std::vector<T, Allocator>::rend () const

{
				return (const_reverse_iterator)vec.offset;
			}

template<class T, class Allocator = allocator<T>>
size_type std::vector<T, Allocator>::size () const

{
				return vec.elements;
			}

template<class T, class Allocator = allocator<T>>
size_type std::vector<T, Allocator>::max_size () const

{
				return vec.allocator.max_size;
			}

template<class T, class Allocator = allocator<T>>
void std::vector<T, Allocator>::resize (size_type sz, T c = T())

{
				if (sz > size())
					insert(end(), sz - size(), c);
				else  if (sz < size())
					erase(begin() + sz, end());	
			}

template<class T, class Allocator = allocator<T>>
size_type std::vector<T, Allocator>::capacity () const

{
				return vec.size;
			}

template<class T, class Allocator = allocator<T>>
bool std::vector<T, Allocator>::empty () const

{
				return vec.elements == 0;
			}

template<class T, class Allocator = allocator<T>>
void std::vector<T, Allocator>::reserve (size_type n)

{
				if (capacity() < n ) {
					pointer tmp = new T[n]; //	vec.allocator.allocate(n);
					memcpy(tmp, vec.offset, vec.elements * sizeof(T));

					delete [] vec.offset;
//					vec.allocator.deallocate(vec.offset, vec.size;

					vec.offset = tmp;
					vec.size   = n;					
				}
			}

template<class T, class Allocator = allocator<T>>
reference std::vector<T, Allocator>::operator[] (size_type n)

{
				return vec.offset[n];
			}

template<class T, class Allocator = allocator<T>>
const_reference std::vector<T, Allocator>::operator[] (size_type n) const

{
				return vec.offset[n];
			}

template<class T, class Allocator = allocator<T>>
const_reference std::vector<T, Allocator>::at (size_type n) const

{
				if (n >= vec.elements)
					throw out_of_range("argument out of range");
				return vec.offset[n];		
			}

template<class T, class Allocator = allocator<T>>
reference std::vector<T, Allocator>::at (size_type n)

{
				if (n >= vec.elements)				
					throw out_of_range("argument out of range");
				return vec.offset[n];			
			}

template<class T, class Allocator = allocator<T>>
reference std::vector<T, Allocator>::front ()

{
				return &vec.offset[n];
			}

template<class T, class Allocator = allocator<T>>
const_reference std::vector<T, Allocator>::front () const

{
				return &vec.offset[n];
			}

template<class T, class Allocator = allocator<T>>
reference std::vector<T, Allocator>::back ()

{
				return &vec.offset[vec.elements - 1];
			}

template<class T, class Allocator = allocator<T>>
const_reference std::vector<T, Allocator>::back () const

{
				return &vec.offset[vec.elements - 1];
			}

template<class T, class Allocator = allocator<T>>
void std::vector<T, Allocator>::push_back (const T & x)

{
				insert(end(), x);
			}

template<class T, class Allocator = allocator<T>>
void std::vector<T, Allocator>::pop_back ()

{
				erase(end() - 1); 
			}

template<class T, class Allocator = allocator<T>>
iterator std::vector<T, Allocator>::insert (iterator position, const T & x = T())

{
				size_type n = position - begin();
				insert(position, (size_type)1, x);
				return begin() + n;
			}

template<class T, class Allocator = allocator<T>>
void std::vector<T, Allocator>::insert (iterator position, size_type n, const T & x)

{				
				while (n--) {
					if (vec.size == vec.elements) {
						size_type st = position - begin();
						reserve(vec.size*2+1);
						position = begin() + st;
					}

					for (iterator i = end() - 1 ; i > position; i--) 
						*i = *(i - 1);
					*position = x;
					vec.elements++;
				}
			}

template<class T, class Allocator = allocator<T>>
template<class InputIterator>
void std::vector<T, Allocator>::insert (iterator position, InputIterator first, InputIterator last)

{				
				while (first != last)
					insert(position, 1, *--last);
			}

template<class T, class Allocator = allocator<T>>
iterator std::vector<T, Allocator>::erase (iterator position)

{
				for (iterator x = position  ; x < end() - 1; x++)
					*x = *(x + 1);
				vec.elements--;
				return position;				
			}

template<class T, class Allocator = allocator<T>>
iterator std::vector<T, Allocator>::erase (iterator first, iterator last)

{
				for (iterator x = last  ; x < end() - 1; x++)
					*first++ = *(x + 1);
				vec.elements -= last - first;
				return last;
			}

template<class T, class Allocator = allocator<T>>
void std::vector<T, Allocator>::swap (vector<T,Allocator>& x)

{
				Vec tmp = x.vec;
				x.vec = vec;
				vec = tmp;
			}

template<class T, class Allocator = allocator<T>>
void std::vector<T, Allocator>::clear ()

{
				erase(begin(), end());
			}

The documentation for this classwas generated from the following file:
Generated at Thu Sep 16 12:20:57 1999 for FREE_C++_STANDARD_LIBRARY by doxygen  written by Dimitri van Heesch, © 1997-1999