00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software: you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 00023 00024 \*---------------------------------------------------------------------------*/ 00025 00026 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 00027 00028 template<class T> 00029 inline Foam::SubList<T>::SubList 00030 ( 00031 const UList<T>& list, 00032 const label subSize 00033 ) 00034 : 00035 UList<T>(list.v_, subSize) 00036 { 00037 # ifdef FULLDEBUG 00038 list.checkSize(subSize); 00039 # endif 00040 } 00041 00042 00043 template<class T> 00044 inline Foam::SubList<T>::SubList 00045 ( 00046 const UList<T>& list, 00047 const label subSize, 00048 const label startIndex 00049 ) 00050 : 00051 UList<T>(&(list.v_[startIndex]), subSize) 00052 { 00053 # ifdef FULLDEBUG 00054 00055 // Artificially allow the start of a zero-sized subList to be 00056 // one past the end of the original list. 00057 if (subSize) 00058 { 00059 list.checkStart(startIndex); 00060 list.checkSize(startIndex + subSize); 00061 } 00062 else 00063 { 00064 // Start index needs to fall between 0 and size. One position 00065 // behind the last element is allowed 00066 list.checkSize(startIndex); 00067 } 00068 # endif 00069 } 00070 00071 00072 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 00073 00074 template<class T> 00075 inline const Foam::SubList<T>& Foam::SubList<T>::null() 00076 { 00077 return *reinterpret_cast< SubList<T>* >(0); 00078 } 00079 00080 00081 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // 00082 00083 template<class T> 00084 inline Foam::SubList<T>::operator const Foam::List<T>&() const 00085 { 00086 return *reinterpret_cast< const List<T>* >(this); 00087 } 00088 00089 00090 template<class T> 00091 inline void Foam::SubList<T>::operator=(const T& t) 00092 { 00093 UList<T>::operator=(t); 00094 } 00095 00096 00097 // ************************ vim: set sw=4 sts=4 et: ************************ //