|
Teuchos Package Browser (Single Doxygen Collection) Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Teuchos: Common Tools Package 00005 // Copyright (2004) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 #ifndef TEUCHOS_TUPLE_HPP 00030 #define TEUCHOS_TUPLE_HPP 00031 00032 00033 #include "Teuchos_ArrayView.hpp" 00034 00035 00036 namespace Teuchos { 00037 00038 00053 template<typename T, int N> 00054 class Tuple : public ArrayView<T> { 00055 public: 00056 00059 inline Tuple(); 00060 00063 Tuple( const Tuple<T,N> &t ); 00064 00067 Tuple<T,N>& operator=( const Tuple<T,N> &t ); 00068 00069 private: 00070 00071 T array_[N]; 00072 00073 }; 00074 00075 00080 template<typename T> inline 00081 Tuple<T,1> tuple(const T& a); 00082 00083 00088 template<typename T> inline 00089 Tuple<T,2> tuple(const T& a, const T& b); 00090 00091 00096 template<typename T> inline 00097 Tuple<T,3> tuple(const T& a, const T& b, const T& c); 00098 00099 00104 template<typename T> inline 00105 Tuple<T,4> tuple(const T& a, const T& b, const T& c, const T& d); 00106 00107 00112 template<typename T> inline 00113 Tuple<T,5> tuple(const T& a, const T& b, const T& c, const T& d, const T& e); 00114 00115 00120 template<typename T> inline 00121 Tuple<T,6> tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00122 const T& f); 00123 00124 00129 template<typename T> inline 00130 Tuple<T,7> tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00131 const T& f, const T& g); 00132 00133 00138 template<typename T> inline 00139 Tuple<T,8> tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00140 const T& f, const T& g, const T& h); 00141 00142 00147 template<typename T> inline 00148 Tuple<T,9> tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00149 const T& f, const T& g, const T& h, const T& i); 00150 00151 00156 template<typename T> inline 00157 Tuple<T,10> tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00158 const T& f, const T& g, const T& h, const T& i, const T& j); 00159 00160 00165 template<typename T> inline 00166 Tuple<T,11> tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00167 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k); 00168 00169 00174 template<typename T> inline 00175 Tuple<T,12> tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00176 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k, 00177 const T& l); 00178 00179 00184 template<typename T> inline 00185 Tuple<T,13> tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00186 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k, 00187 const T& l, const T& m); 00188 00189 00194 template<typename T> inline 00195 Tuple<T,14> tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00196 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k, 00197 const T& l, const T& m, const T& n); 00198 00199 00204 template<typename T> inline 00205 Tuple<T,15> tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00206 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k, 00207 const T& l, const T& m, const T& n, const T& o); 00208 00209 00210 // 00211 // Implementations 00212 // 00213 00214 00215 template<typename T, int N> inline 00216 Tuple<T,N>::Tuple() 00217 :ArrayView<T>() // To get rid of warnings! 00218 { 00219 ArrayView<T>::operator=(ArrayView<T>(&array_[0],N)); 00220 } 00221 00222 00223 template<typename T, int N> 00224 Tuple<T,N>::Tuple( const Tuple<T,N> &t ) 00225 :ArrayView<T>() // To get rid of warnings! 00226 { 00227 for( int i = 0; i < N; ++i ) 00228 array_[i] = t[i]; 00229 // Above, this loop with static N should allow the compiler to unroll this 00230 // entire loop! 00231 ArrayView<T>::operator=(ArrayView<T>(&array_[0],N)); 00232 } 00233 00234 00235 template<typename T, int N> 00236 Tuple<T,N>& Tuple<T,N>::operator=( const Tuple<T,N> &t ) 00237 { 00238 for( int i = 0; i < N; ++i ) 00239 array_[i] = t[i]; 00240 // Above, this loop with static N should allow the compiler to unroll this 00241 // entire loop! 00242 return *this; 00243 } 00244 00245 00246 } // end namespace Teuchos 00247 00248 00249 // 00250 // Nonmember function implementations 00251 // 00252 00253 00254 template<typename T> inline 00255 Teuchos::Tuple<T,1> 00256 Teuchos::tuple(const T& a) 00257 { 00258 Tuple<T,1> rtn; 00259 rtn[0] = a; 00260 return rtn; 00261 } 00262 00263 00264 template<typename T> inline 00265 Teuchos::Tuple<T,2> 00266 Teuchos::tuple(const T& a, const T& b) 00267 { 00268 Tuple<T,2> rtn; 00269 rtn[0] = a; 00270 rtn[1] = b; 00271 return rtn; 00272 } 00273 00274 00275 template<typename T> inline 00276 Teuchos::Tuple<T,3> 00277 Teuchos::tuple(const T& a, const T& b, const T& c) 00278 { 00279 Tuple<T,3> rtn; 00280 rtn[0] = a; 00281 rtn[1] = b; 00282 rtn[2] = c; 00283 return rtn; 00284 } 00285 00286 00287 template<typename T> inline 00288 Teuchos::Tuple<T,4> 00289 Teuchos::tuple(const T& a, const T& b, const T& c, const T& d) 00290 { 00291 Tuple<T,4> rtn;; 00292 rtn[0] = a; 00293 rtn[1] = b; 00294 rtn[2] = c; 00295 rtn[3] = d; 00296 return rtn; 00297 } 00298 00299 00300 template<typename T> inline 00301 Teuchos::Tuple<T,5> 00302 Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e) 00303 { 00304 Tuple<T,5> rtn; 00305 rtn[0] = a; 00306 rtn[1] = b; 00307 rtn[2] = c; 00308 rtn[3] = d; 00309 rtn[4] = e; 00310 return rtn; 00311 } 00312 00313 00314 template<typename T> inline 00315 Teuchos::Tuple<T,6> 00316 Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00317 const T& f) 00318 { 00319 Tuple<T,6> rtn; 00320 rtn[0] = a; 00321 rtn[1] = b; 00322 rtn[2] = c; 00323 rtn[3] = d; 00324 rtn[4] = e; 00325 rtn[5] = f; 00326 return rtn; 00327 } 00328 00329 00330 template<typename T> inline 00331 Teuchos::Tuple<T,7> 00332 Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00333 const T& f, const T& g) 00334 { 00335 Tuple<T,7> rtn; 00336 rtn[0] = a; 00337 rtn[1] = b; 00338 rtn[2] = c; 00339 rtn[3] = d; 00340 rtn[4] = e; 00341 rtn[5] = f; 00342 rtn[6] = g; 00343 return rtn; 00344 } 00345 00346 00347 template<typename T> inline 00348 Teuchos::Tuple<T,8> 00349 Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00350 const T& f, const T& g, const T& h) 00351 { 00352 Tuple<T,8> rtn; 00353 rtn[0] = a; 00354 rtn[1] = b; 00355 rtn[2] = c; 00356 rtn[3] = d; 00357 rtn[4] = e; 00358 rtn[5] = f; 00359 rtn[6] = g; 00360 rtn[7] = h; 00361 return rtn; 00362 } 00363 00364 00365 template<typename T> inline 00366 Teuchos::Tuple<T,9> 00367 Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00368 const T& f, const T& g, const T& h, const T& i) 00369 { 00370 Tuple<T,9> rtn; 00371 rtn[0] = a; 00372 rtn[1] = b; 00373 rtn[2] = c; 00374 rtn[3] = d; 00375 rtn[4] = e; 00376 rtn[5] = f; 00377 rtn[6] = g; 00378 rtn[7] = h; 00379 rtn[8] = i; 00380 return rtn; 00381 } 00382 00383 00384 template<typename T> inline 00385 Teuchos::Tuple<T,10> 00386 Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00387 const T& f, const T& g, const T& h, const T& i, const T& j) 00388 { 00389 Tuple<T,10> rtn; 00390 rtn[0] = a; 00391 rtn[1] = b; 00392 rtn[2] = c; 00393 rtn[3] = d; 00394 rtn[4] = e; 00395 rtn[5] = f; 00396 rtn[6] = g; 00397 rtn[7] = h; 00398 rtn[8] = i; 00399 rtn[9] = j; 00400 return rtn; 00401 } 00402 00403 00404 template<typename T> inline 00405 Teuchos::Tuple<T,11> 00406 Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00407 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k) 00408 { 00409 Tuple<T,11> rtn; 00410 rtn[0] = a; 00411 rtn[1] = b; 00412 rtn[2] = c; 00413 rtn[3] = d; 00414 rtn[4] = e; 00415 rtn[5] = f; 00416 rtn[6] = g; 00417 rtn[7] = h; 00418 rtn[8] = i; 00419 rtn[9] = j; 00420 rtn[10] = k; 00421 return rtn; 00422 } 00423 00424 template<typename T> inline 00425 Teuchos::Tuple<T,12> 00426 Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00427 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k, 00428 const T& l) 00429 { 00430 Tuple<T,12> rtn; 00431 rtn[0] = a; 00432 rtn[1] = b; 00433 rtn[2] = c; 00434 rtn[3] = d; 00435 rtn[4] = e; 00436 rtn[5] = f; 00437 rtn[6] = g; 00438 rtn[7] = h; 00439 rtn[8] = i; 00440 rtn[9] = j; 00441 rtn[10] = k; 00442 rtn[11] = l; 00443 return rtn; 00444 } 00445 00446 template<typename T> inline 00447 Teuchos::Tuple<T,13> 00448 Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00449 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k, 00450 const T& l, const T& m) 00451 { 00452 Tuple<T,13> rtn; 00453 rtn[0] = a; 00454 rtn[1] = b; 00455 rtn[2] = c; 00456 rtn[3] = d; 00457 rtn[4] = e; 00458 rtn[5] = f; 00459 rtn[6] = g; 00460 rtn[7] = h; 00461 rtn[8] = i; 00462 rtn[9] = j; 00463 rtn[10] = k; 00464 rtn[11] = l; 00465 rtn[12] = m; 00466 return rtn; 00467 } 00468 00469 00470 template<typename T> inline 00471 Teuchos::Tuple<T,14> 00472 Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00473 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k, 00474 const T& l, const T& m, const T& n) 00475 { 00476 Tuple<T,14> rtn; 00477 rtn[0] = a; 00478 rtn[1] = b; 00479 rtn[2] = c; 00480 rtn[3] = d; 00481 rtn[4] = e; 00482 rtn[5] = f; 00483 rtn[6] = g; 00484 rtn[7] = h; 00485 rtn[8] = i; 00486 rtn[9] = j; 00487 rtn[10] = k; 00488 rtn[11] = l; 00489 rtn[12] = m; 00490 rtn[13] = n; 00491 return rtn; 00492 } 00493 00494 00495 template<typename T> inline 00496 Teuchos::Tuple<T,15> 00497 Teuchos::tuple(const T& a, const T& b, const T& c, const T& d, const T& e, 00498 const T& f, const T& g, const T& h, const T& i, const T& j, const T& k, 00499 const T& l, const T& m, const T& n, const T& o) 00500 { 00501 Tuple<T,15> rtn; 00502 rtn[0] = a; 00503 rtn[1] = b; 00504 rtn[2] = c; 00505 rtn[3] = d; 00506 rtn[4] = e; 00507 rtn[5] = f; 00508 rtn[6] = g; 00509 rtn[7] = h; 00510 rtn[8] = i; 00511 rtn[9] = j; 00512 rtn[10] = k; 00513 rtn[11] = l; 00514 rtn[12] = m; 00515 rtn[13] = n; 00516 rtn[14] = o; 00517 return rtn; 00518 } 00519 00520 00521 #endif // TEUCHOS_TUPLE_HPP
1.7.4