estar/util.hpp

Go to the documentation of this file.
00001 /* 
00002  * Copyright (C) 2005 Roland Philippsen <roland dot philippsen at gmx net>
00003  * 
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00017  * USA
00018  */
00019 
00020 
00021 #ifndef ESTAR_UTIL_HPP
00022 #define ESTAR_UTIL_HPP
00023 
00024 
00025 #include <boost/scoped_array.hpp>
00026 
00027 
00028 namespace estar {
00029   
00030   
00041   void set_cleanup(void (*function)());
00042 
00043 
00051   template<typename value_t, typename index_t = size_t>
00052   class array
00053   {
00054   public:
00055     typedef boost::scoped_array<value_t> inner_t;
00056     typedef boost::scoped_array<inner_t> outer_t;
00057   
00058     array(index_t xsize, index_t ysize)
00059       : data(new inner_t[xsize])
00060     {
00061       for (index_t ix(0); ix < xsize; ++ix)
00062         data[ix].reset(new value_t[ysize]);
00063     }
00064     
00065     array(index_t xsize, index_t ysize, const value_t & init)
00066       : data(new inner_t[xsize])
00067     {
00068       for (index_t ix(0); ix < xsize; ++ix) {
00069         data[ix].reset(new value_t[ysize]);
00070         for(index_t iy(0); iy < ysize; ++iy)
00071           data[ix][iy] = init;
00072       }
00073     }
00074     
00075     inner_t & operator [] (index_t ix) { return data[ix]; }
00076     const inner_t & operator [] (index_t ix) const { return data[ix]; }
00077     
00078     outer_t data;
00079   };
00080   
00081 }
00082 
00083 #endif // ESTAR_UTIL_HPP

doxygen SourceForge.net Logo
E* Interpolated Graph Replanner Wed Dec 12 18:55:40 2007