MathTL
utils/fixed_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_FIXED_ARRAY1D_H
00011 #define _MATHTL_FIXED_ARRAY1D_H
00012 
00013 #include <iostream>
00014 
00015 namespace MathTL
00016 {
00022   template <class C, unsigned int SIZE>
00023   class FixedArray1D
00024   {
00025   public:
00029     typedef C value_type;
00030     
00034     typedef value_type* pointer;
00035     
00039     typedef const value_type* const_pointer;
00040     
00044     typedef value_type* iterator;
00045     
00049     typedef const value_type* const_iterator;
00050     
00054     typedef value_type& reference;
00055     
00059     typedef const value_type& const_reference;
00060     
00064     typedef unsigned int size_type;
00065     
00069     FixedArray1D();
00070     
00074     FixedArray1D(const FixedArray1D<C, SIZE>& a);
00075     
00079     ~FixedArray1D();
00080     
00084     const size_type size() const;
00085     
00089     FixedArray1D<C, SIZE>& operator = (const FixedArray1D<C, SIZE>& a);
00090     
00094     const C& operator [] (const size_type i) const;
00095     
00099     C& operator [] (const size_type i);
00100     
00104     const_iterator begin() const;
00105     
00109     iterator begin();
00110     
00115     const_iterator end() const;
00116     
00121     iterator end();
00122     
00123   protected:
00127     C* data_;
00128   };
00129 
00131   template <unsigned int SIZE>
00132   class FixedArray1D<double,SIZE>
00133   {
00134   public:
00136     typedef double value_type;
00137     
00139     typedef value_type* pointer;
00140     
00142     typedef const value_type* const_pointer;
00143     
00145     typedef value_type* iterator;
00146     
00148     typedef const value_type* const_iterator;
00149     
00151     typedef value_type& reference;
00152     
00154     typedef const value_type& const_reference;
00155     
00157     typedef unsigned int size_type;
00158     
00160     FixedArray1D();
00161     
00163     FixedArray1D(const FixedArray1D<double, SIZE>& a);
00164     
00166     ~FixedArray1D();
00167     
00169     const size_type size() const;
00170     
00172     FixedArray1D<double, SIZE>& operator = (const FixedArray1D<double, SIZE>& a);
00173     
00175     const double& operator [] (const size_type i) const;
00176     
00178     double& operator [] (const size_type i);
00179     
00181     const_iterator begin() const;
00182     
00184     iterator begin();
00185     
00190     const_iterator end() const;
00191     
00196     iterator end();
00197     
00198   protected:
00203     double data_[SIZE+1];
00204   };
00205 
00206   
00210   template <class C, unsigned int SIZE>
00211   std::ostream& operator << (std::ostream& os, const FixedArray1D<C, SIZE>& A);
00212 }
00213 
00214 // include implementation of inline functions
00215 #include "utils/fixed_array1d.cpp"
00216 
00217 #endif
 All Classes Functions Variables Typedefs Enumerations