Vector(7rheolef) | rheolef-7.0 | Vector(7rheolef) |
Vector - STL vector<T> with reference counting
The class implement a reference counting wrapper for
the STL vector<T> container class, with shallow copies.
See also:
The standard template library, by Alexander Stephanov and Meng
Lee.
This class provides the full vector<T>
interface specification
an could be used instead of vector<T>.
The write accessors
T& operator[](size_type)
Vector<T>::iterator i = v.begin();
Vector<T>::iterator last = v.end();
while (i != last) { ...}
Thus, in order to encourage users to do it, we declare private
theses member functions. A synonym of operator[] is at.
template<class T> class Vector : private smart_pointer<vector_rep<T> > { public: // typedefs:
typedef iterator;
typedef const_iterator;
typedef pointer;
typedef reference;
typedef const_reference;
typedef size_type;
typedef difference_type;
typedef value_type;
typedef reverse_iterator;
typedef const_reverse_iterator; // allocation/deallocation:
explicit Vector (size_type n = 0, const T& value = T ());
Vector (const_iterator first, const_iterator last);
void reserve (size_type n);
void swap (Vector<T>& x) ; // accessors:
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;
size_type capacity () const;
bool empty () const;
void resize (size_type sz, T v = T ()); // non-standard ? private:
const_reference operator[] (size_type n) const;
reference operator[] (size_type n); public:
const_reference at (size_type n) const; // non-standard ?
reference at (size_type n);
reference front ();
const_reference front () const;
reference back ();
const_reference back () const; // insert/erase:
void push_back (const T& x);
iterator insert (iterator position, const T& x = T ());
void insert (iterator position, size_type n, const T& x);
void insert (iterator position, const_iterator first, const_iterator last);
void pop_back ();
void erase (iterator position);
void erase (iterator first, iterator last); };
Copyright (C) 2000-2018 Pierre Saramito <Pierre.Saramito@imag.fr> GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
rheolef-7.0 | rheolef-7.0 |