![]() |
|
00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2005 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 the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 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, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 \*---------------------------------------------------------------------------*/ 00026 00027 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00028 00029 namespace Foam 00030 { 00031 00032 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 00033 00034 template<class T> 00035 inline SubList<T>::SubList 00036 ( 00037 const UList<T>& list, 00038 const label subSize 00039 ) 00040 : 00041 UList<T>(list.v_, subSize) 00042 { 00043 # ifdef FULLDEBUG 00044 list.checkSize(subSize); 00045 # endif 00046 } 00047 00048 00049 template<class T> 00050 inline SubList<T>::SubList 00051 ( 00052 const UList<T>& list, 00053 const label subSize, 00054 const label startIndex 00055 ) 00056 : 00057 UList<T>(&(list.v_[startIndex]), subSize) 00058 { 00059 # ifdef FULLDEBUG 00060 00061 // Artificially allowing the start of a zero-sized subList to be 00062 // one past the end of the original list. 00063 if (subSize > 0) 00064 { 00065 list.checkStart(startIndex); 00066 list.checkSize(startIndex + subSize); 00067 } 00068 else 00069 { 00070 // Start index needs to fall between 0 and size. One position 00071 // behind the last element is allowed 00072 list.checkSize(startIndex); 00073 } 00074 # endif 00075 } 00076 00077 00078 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 00079 00080 // Return a null SubList 00081 template<class T> 00082 SubList<T>& SubList<T>::null() 00083 { 00084 SubList<T>* nullPtr = reinterpret_cast<SubList<T>*>(NULL); 00085 return *nullPtr; 00086 } 00087 00088 00089 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // 00090 00091 // Allow cast to a const List<T>& 00092 template<class T> 00093 inline SubList<T>::operator const List<T>&() const 00094 { 00095 return *reinterpret_cast<const List<T>*>(this); 00096 } 00097 00098 00099 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00100 00101 } // End namespace Foam 00102 00103 // ************************************************************************* //