Main Page   Compound List   File List   Compound Members  

vector.h

00001 #ifndef VECTOR_H
00002 #define VECTOR_H
00003 
00004 #include <stdexcept>
00005 #include <new>
00006 
00007 using namespace std;
00008 
00009 /*=========================================================================*/
00010 
00020 template <typename T>
00021 class Vector {
00022 
00023   public:
00024     Vector();
00025     Vector( const unsigned, const T & = T() ) throw ( bad_alloc );
00026     Vector( const Vector<T> & ) throw ( bad_alloc );
00027     ~Vector();
00028     bool empty() const;
00029     unsigned size() const;
00030     unsigned capacity() const;
00031     void clear();
00032     void resize( const unsigned, const T & = T() ) throw ( bad_alloc );
00033     T &at( const unsigned ) const throw ( VectorEmpty, OutOfBounds );
00034     void assign( const unsigned, const T & ) throw ( VectorEmpty, OutOfBounds );
00035     void push_back( const T & ) throw ( bad_alloc );
00036     void insert( const unsigned, const T & ) throw ( bad_alloc, OutOfBounds );
00037     void remove( const unsigned ) throw ( VectorEmpty, OutOfBounds );
00038     T &operator[]( const unsigned ) const throw ( VectorEmpty, OutOfBounds );
00039     const T &operator=( const Vector<T> & ) throw ( bad_alloc );
00040 
00041   private:
00042     T *contents;
00043     unsigned sz, cap;
00044 
00045     void increaseCapacity() throw ( bad_alloc );
00046 
00047 }; // Vector class
00048 
00049 /*------------------------------------------------------------------------*/
00050 
00055 template <typename T>
00056 Vector<T>::Vector()
00057 {
00058 } // Vector<T>::Vector
00059 
00060 /*------------------------------------------------------------------------*/
00061 
00069 template <typename T>
00070 Vector<T>::Vector( const unsigned sz, const T &v ) throw ( bad_alloc )
00071 {
00072 } // Vector<T>::Vector
00073 
00074 /*------------------------------------------------------------------------*/
00075 
00082 template <typename T>
00083 Vector<T>::Vector( const Vector<T> &v ) throw ( bad_alloc )
00084 {
00085 } // Vector<T>::Vector
00086 
00087 /*------------------------------------------------------------------------*/
00088 
00093 template <typename T>
00094 Vector<T>::~Vector()
00095 {
00096 } // Vector<T>::~Vector
00097 
00098 /*------------------------------------------------------------------------*/
00099 
00106 template <typename T>
00107 bool Vector<T>::empty() const
00108 {
00109 } // Vector<T>::empty
00110 
00111 /*------------------------------------------------------------------------*/
00112 
00119 template <typename T>
00120 unsigned Vector<T>::size() const
00121 {
00122 } // Vector<T>::size
00123 
00124 /*------------------------------------------------------------------------*/
00125 
00133 template <typename T>
00134 unsigned Vector<T>::capacity() const
00135 {
00136 } // Vector<T>::capacity
00137 
00138 /*------------------------------------------------------------------------*/
00139 
00144 template <typename T>
00145 void Vector<T>::clear()
00146 {
00147 } // Vector<T>::clear
00148 
00149 /*------------------------------------------------------------------------*/
00150 
00161 template <typename T>
00162 void Vector<T>::resize( const unsigned newSize, const T &v ) throw ( bad_alloc )
00163 {
00164 } // Vector<T>::resize
00165 
00166 /*------------------------------------------------------------------------*/
00167 
00174 template <typename T>
00175 void Vector<T>::increaseCapacity() throw ( bad_alloc )
00176 {
00177 } // Vector<T>::increaseCapacity
00178 
00179 /*------------------------------------------------------------------------*/
00180 
00191 template <typename T>
00192 T &Vector<T>::at( const unsigned i ) const throw ( VectorEmpty, OutOfBounds )
00193 {
00194 } // Vector<T>::at
00195 
00196 /*------------------------------------------------------------------------*/
00197 
00207 template <typename T>
00208 void Vector<T>::assign( const unsigned i, const T &object )
00209   throw (VectorEmpty, OutOfBounds)
00210 {
00211 } // Vector<T>::assign
00212 
00213 /*------------------------------------------------------------------------*/
00214 
00223 template <typename T>
00224 void Vector<T>::push_back( const T &object ) throw ( bad_alloc )
00225 {
00226 } // Vector<T>::push_back
00227 
00228 /*------------------------------------------------------------------------*/
00229 
00240 template <typename T>
00241 void Vector<T>::insert( const unsigned i, const T &object )
00242   throw ( bad_alloc, OutOfBounds )
00243 {
00244 } // Vector<T>::insert
00245 
00246 /*------------------------------------------------------------------------*/
00247 
00256 template <typename T>
00257 void Vector<T>::remove( const unsigned i )
00258   throw (VectorEmpty, OutOfBounds)
00259 {
00260 } // Vector<T>::remove
00261 
00262 /*------------------------------------------------------------------------*/
00263 
00274 template <typename T>
00275 T &Vector<T>::operator[]( const unsigned i ) const
00276   throw (VectorEmpty, OutOfBounds)
00277 {
00278 } // Vector<T>::operator[]
00279 
00280 /*------------------------------------------------------------------------*/
00281 
00290 const Vector<T> &Vector<T>::operator=( const Vector<T> &v ) throw ( bad_alloc )
00291 {
00292 } // Vector<T>::operator=
00293 
00294 #endif // VECTOR_H

Generated on Thu Mar 31 18:12:54 2005 by doxygen1.3