Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

CTBcarray.icc

Go to the documentation of this file.
00001 
00006 /*----------------------------------------------------------------------------*/
00007 /* C Tool Box: Designed and implemented by:                                   */
00008 /*    Walter F.J. Mueller   Gesellschaft fuer Schwerionenforschung (GSI)      */
00009 /*                          Planckstrasse 1, D-64291 Darmstadt, Germany       */
00010 /*                  Email:  W.F.J.Mueller@gsi.de                              */
00011 /*                  WWW:    http://www-kp3.gsi.de/www/kp3/people/mueller.html */
00012 /*------------------------------------------+---------------------------------*/
00013 
00014 #include "CTBexceptionIndexRange.hxx"
00015 
00021 //------------------------------------------+-----------------------------------
00023 
00032 template <class T, CTBint DIM>
00033 inline CTBcarray<T,DIM>::CTBcarray()
00034 {}
00035 
00036 //------------------------------------------+-----------------------------------
00038 
00039 template <class T, CTBint DIM>
00040 inline CTBcarray<T,DIM>::CTBcarray(T rhs)
00041 {
00042   operator=(rhs);
00043 }
00044 
00045 //------------------------------------------+-----------------------------------
00047 
00048 template <class T, CTBint DIM>
00049 inline CTBcarray<T,DIM>::CTBcarray(const CTBcarray<T,DIM>& rhs)
00050 {
00051   operator=(rhs);
00052 }
00053 
00054 //------------------------------------------+-----------------------------------
00056 
00057 template <class T, CTBint DIM>
00058 inline T& CTBcarray<T,DIM>::operator[](CTBint i_ind)
00059 {
00060 #ifdef CTB__IndexCheck
00061   CTBindexRangeCheck(i_ind,DIM,"CTBcarray::operator[]");
00062 #endif
00063   return m_data[i_ind];
00064 }
00065 
00066 //------------------------------------------+-----------------------------------
00068 
00069 template <class T, CTBint DIM>
00070 inline const T& CTBcarray<T,DIM>::operator[](CTBint i_ind) const
00071 {
00072 #ifdef CTB__IndexCheck
00073   CTBindexRangeCheck(i_ind,DIM,"CTBcarray::operator[]");
00074 #endif
00075   return m_data[i_ind];
00076 }
00077 
00078 //------------------------------------------+-----------------------------------
00080 
00081 template <class T, CTBint DIM>
00082 inline T& CTBcarray<T,DIM>::operator()(CTBint i_ind)
00083 {
00084 #ifdef CTB__IndexCheck
00085   CTBindexRangeCheck(i_ind,DIM,"CTBcarray::operator()");
00086 #endif
00087   return m_data[i_ind];
00088 }
00089 
00090 //------------------------------------------+-----------------------------------
00092 
00093 template <class T, CTBint DIM>
00094 inline const T& CTBcarray<T,DIM>::operator()(CTBint i_ind) const
00095 {
00096 #ifdef CTB__IndexCheck
00097   CTBindexRangeCheck(i_ind,DIM,"CTBcarray::operator()");
00098 #endif
00099   return m_data[i_ind];
00100 }
00101 
00102 //------------------------------------------+-----------------------------------
00104 
00105 template <class T, CTBint DIM>
00106 inline CTBcarray<T,DIM>::operator T*()
00107 {
00108   return m_data;
00109 }
00110 
00111 //------------------------------------------+-----------------------------------
00113 
00114 template <class T, CTBint DIM>
00115 inline CTBcarray<T,DIM>::operator const T*() const
00116 {
00117   return m_data;
00118 }
00119 
00120 //------------------------------------------+-----------------------------------
00122 
00123 template <class T, CTBint DIM>
00124 inline CTBcarray<T,DIM>::operator CTBvectorDsc<T>()
00125 {
00126   return CTBvectorDsc<T>(m_data,DIM);
00127 }
00128 
00129 //------------------------------------------+-----------------------------------
00131 
00132 template <class T, CTBint DIM>
00133 inline CTBcarray<T,DIM>::operator CTBvectorCDsc<T>() const
00134 {
00135   return CTBvectorCDsc<T>(m_data,DIM);
00136 }
00137 
00138 //------------------------------------------+-----------------------------------
00140 
00141 template <class T, CTBint DIM>
00142 inline bool CTBcarray<T,DIM>::operator==(T rhs)
00143 {
00144   for (CTBint i = 0; i < DIM; i++) if (!(m_data[i] == rhs)) return false;
00145   return true;
00146 }
00147 
00148 //------------------------------------------+-----------------------------------
00150 
00151 template <class T, CTBint DIM>
00152 inline bool CTBcarray<T,DIM>::operator==(const CTBcarray<T,DIM>& rhs)
00153 {
00154   for (CTBint i = 0; i < DIM; i++) 
00155     if (!(m_data[i] == rhs.m_data[i])) return false;
00156   return true;
00157 }
00158 
00159 //------------------------------------------+-----------------------------------
00161 
00162 template <class T, CTBint DIM>
00163 inline CTBcarray<T,DIM>& CTBcarray<T,DIM>::operator=(T rhs)
00164 {
00165   for (CTBint i = 0; i < DIM; i++) m_data[i] = rhs;
00166   return *this;
00167 }
00168 
00169 //------------------------------------------+-----------------------------------
00171 
00172 template <class T, CTBint DIM>
00173 inline CTBcarray<T,DIM>& CTBcarray<T,DIM>::operator=(
00174     const CTBcarray<T,DIM>& rhs)
00175 {
00176   for (CTBint i = 0; i < DIM; i++) m_data[i] = rhs.m_data[i];
00177   return *this;
00178 }
00179 //------------------------------------------+-----------------------------------
00185 template <class T, CTBint DIM>
00186 ostream& operator<<(ostream& os, const CTBcarray<T,DIM>& obj)
00187 {
00188   int i_width = os.width();
00189 
00190   os << setw(0) << "{";
00191   for (CTBint i = 0; i < DIM; i++) {
00192     if (i > 0) os << ",";
00193     os << setw(i_width) << obj[i];
00194   }
00195   os << "}";
00196   return os;
00197 }
00198 

Generated at Fri Oct 24 18:11:27 2003 for CTBbase by doxygen1.2.9-20010812 written by Dimitri van Heesch, © 1997-2001