.\" .de Id .. .de Sp .if n .sp .if t .sp 0.4 .. .TH Vector 7rheolef "rheolef-6.7" "rheolef-6.7" "rheolef-6.7" .\" label: /*Class:csr .SH NAME \fBVector\fP - STL \fBvector\fP with reference counting .\" skip: @clindex Vector .SH DESCRIPTION The class implement a reference counting wrapper for the STL \fBvector\fP container class, with shallow copies. See also: \fIThe standard template library\fP, by Alexander Stephanov and Meng Lee. .PP This class provides the full \fBvector\fP interface specification an could be used instead of \fBvector\fP. .SH NOTE The write accessors .\" begin_example .Sp .nf T& operator[](size_type) .Sp .fi .\" end_example as in \fBv[i]\fP may checks the reference count for each access. For a loop, a better usage is: .\" begin_example .Sp .nf Vector::iterator i = v.begin(); Vector::iterator last = v.end(); while (i != last) { ...} .Sp .fi .\" end_example and the reference count check step occurs only two time, when accessing via \fBbegin()\fP and \fBend()\fP. .PP Thus, in order to encourage users to do it, we declare private theses member functions. A synonym of \fBoperator[]\fP is \fBat\fP. .PP .\" skip start:AUTHOR: .\" skip start:DATE: .\" END .SH IMPLEMENTATION .\" begin_example .Sp .nf template class Vector : private smart_pointer > { 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& 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); }; .Sp .fi .\" end_example