MathTL
utils/array1d.h
00001 // -*- c++ -*-
00002 
00003 // +--------------------------------------------------------------------+
00004 // | This file is part of MathTL - the Mathematical Template Library    |
00005 // |                                                                    |
00006 // | Copyright (c) 2002-2009                                            |
00007 // | Thorsten Raasch, Manuel Werner                                     |
00008 // +--------------------------------------------------------------------+
00009 
00010 #ifndef _MATHTL_ARRAY1D_H
00011 #define _MATHTL_ARRAY1D_H
00012 
00013 #include <iostream>
00014 
00015 namespace MathTL
00016 {
00024   template <class C>
00025     class Array1D
00026   {
00027   public:
00031     typedef C value_type;
00032 
00036     typedef value_type* pointer;
00037 
00041     typedef const value_type* const_pointer;
00042 
00046     typedef value_type* iterator;
00047 
00051     typedef const value_type* const_iterator;
00052 
00056     typedef value_type& reference;
00057     
00061     typedef const value_type& const_reference;
00062 
00066     typedef size_t size_type;
00067 
00071     Array1D();
00072 
00076     Array1D(const Array1D<C>& a);
00077     
00083     explicit Array1D(const size_type s);
00084 
00088     ~Array1D();
00089 
00093     const size_type size() const;
00094 
00101     void resize(const size_type s);
00102 
00106     Array1D<C>& operator = (const Array1D<C>& a);
00107 
00111     const C& operator [] (const size_type i) const;
00112 
00116     C& operator [] (const size_type i);
00117 
00121     const_iterator begin() const;
00122 
00126     iterator begin();
00127 
00132     const_iterator end() const;
00133 
00138     iterator end();
00139 
00143     void swap (Array1D<C>& a);
00144 
00148     void swap (const size_type i, const size_type j);
00149 
00150   protected:
00154     C* data_;
00155 
00159     size_type size_;
00160   };
00161 
00165   template <class C>
00166   std::ostream& operator << (std::ostream& os, const Array1D<C>& A);
00167 }
00168 
00169 // include implementation of inline functions
00170 #include "utils/array1d.cpp"
00171 
00172 #endif
 All Classes Functions Variables Typedefs Enumerations