Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

packcontainer_int.h

Go to the documentation of this file.
00001 
00002 #ifndef _PACKCONTAINER_INT_H_
00003 #define _PACKCONTAINER_INT_H_
00004 
00005 #include "packnode.h"
00006 
00038 
00039 
00052 class packcontainer_int {
00053 private:
00055   size_t N;
00057   int* lhs;
00059   int* rhs;
00060 
00061 private:
00063   packcontainer_int( const packcontainer_int &rhs ) {};
00065   packcontainer_int() {};
00066 
00067 public:
00068 
00089   packcontainer_int( packnode<int>* node )
00090   {
00091     assert( node != 0 );
00092     N = node->length();
00093     assert( N > 1 );
00094 
00095     size_t half = N >> 1;
00096     block_pool mem_pool;
00097     size_t num_bytes = half * sizeof(int);
00098 
00099     lhs = (int *)mem_pool.pool_alloc( num_bytes );
00100     rhs = (int *)mem_pool.pool_alloc( num_bytes );
00101 
00102     for (size_t i = 0; i < N; i++) {
00103       (*this)[i] = (*node)[i];
00104     }
00105   } // packcontainer_int
00106 
00107 
00118   packcontainer_int( size_t n )
00119   {
00120     N = n;
00121     lhs = 0;
00122     rhs = 0;
00123   }
00124 
00131   void *operator new( unsigned int num_bytes )
00132   {
00133     block_pool mem_pool;
00134 
00135     void *mem_addr = mem_pool.pool_alloc( num_bytes );
00136     return mem_addr;
00137   } // new
00138 
00139 
00141   int &operator[]( const size_t i )
00142   {
00143     assert( i < N );
00144     size_t half = N >> 1;
00145 
00146     if (i < half)
00147       return lhs[i];
00148     else {
00149       return rhs[i-half];
00150     }
00151   }
00152 
00154   int operator[]( const size_t i ) const
00155   {
00156     assert( i < N );
00157     size_t half = N >> 1;
00158 
00159     if (i < half)
00160       return lhs[i];
00161     else {
00162       return rhs[i-half];
00163     }
00164   }
00165 
00167   int* lhsData() { return lhs; }
00169   int* rhsData() { return rhs; }
00170 
00172   void lhsData(int* l) { lhs = l; }
00174   void rhsData(int* r) { rhs = r; }
00175 
00181   size_t length() { return N; }
00182 
00183 }; // packcontainer_int
00184 
00185 #endif

Generated at Tue May 27 21:56:16 2003 for Wavelet compression, determinism and time series forecasting by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001