SubListI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2017-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class T>
33 (
34  const UList<T>& list
35 )
36 :
37  UList<T>(list.v_, list.size())
38 {}
39 
40 
41 template<class T>
43 (
44  const UList<T>& list,
45  const label subSize
46 )
47 :
48  UList<T>(list.v_, subSize)
49 {
50  #ifdef FULLDEBUG
51  list.checkSize(subSize);
52  #endif
53 }
54 
55 
56 template<class T>
58 (
59  const UList<T>& list,
60  const label subSize,
61  const label startIndex
62 )
63 :
64  UList<T>(&(list.v_[startIndex]), subSize)
65 {
66  #ifdef FULLDEBUG
67  // Artificially allow the start of a zero-sized subList to be
68  // one past the end of the original list.
69  if (subSize)
70  {
71  list.checkStart(startIndex);
72  list.checkSize(startIndex + subSize);
73  }
74  else
75  {
76  // Start index needs to fall between 0 and size. One position
77  // behind the last element is allowed
78  list.checkSize(startIndex);
79  }
80  #endif
81 }
82 
83 
84 template<class T>
86 (
87  const UList<T>& list,
88  const labelRange& range
89 )
90 :
91  SubList<T>(list.validateRange(range), list)
92 {}
93 
94 
95 template<class T>
97 (
98  const labelRange& range,
99  const UList<T>& list
100 )
101 :
102  SubList<T>(list, range.size(), range.start())
103 {}
104 
105 
106 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
107 
108 template<class T>
110 {
111  return NullObjectRef<SubList<T>>();
112 }
113 
114 
115 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
116 
117 template<class T>
119 {
120  return *reinterpret_cast<const List<T>*>(this);
121 }
122 
123 
124 template<class T>
125 inline void Foam::SubList<T>::operator=(const SubList<T>& list)
126 {
127  UList<T>::deepCopy(list);
128 }
129 
130 
131 template<class T>
132 inline void Foam::SubList<T>::operator=(const UList<T>& list)
133 {
134  UList<T>::deepCopy(list);
135 }
136 
137 
138 template<class T>
139 inline void Foam::SubList<T>::operator=(const T& val)
140 {
141  UList<T>::operator=(val);
142 }
143 
144 
145 template<class T>
147 {
149 }
150 
151 
152 // ************************************************************************* //
Foam::UList::validateRange
labelRange validateRange(const labelRange &range) const
Definition: UList.C:39
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:53
Foam::UList::checkSize
void checkSize(const label size) const
Check size is within valid range [0,size].
Definition: UListI.H:116
Foam::UList::checkStart
void checkStart(const label start) const
Check start is within valid range [0,size)
Definition: UListI.H:103
Foam::labelRange
A range or interval of labels defined by a start and a size.
Definition: labelRange.H:55
Foam::SubList::SubList
SubList(const SubList &)=default
Copy construct.
T
const volScalarField & T
Definition: createFieldRefs.H:2
Foam::SubList::operator=
void operator=(const SubList< T > &list)
Copy assign entries from given sub-list.
Definition: SubListI.H:125
Foam::SubList::null
static const SubList< T > & null()
Return a null SubList.
Definition: SubListI.H:109
range
scalar range
Definition: LISASMDCalcMethod1.H:12
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
Foam::UList::size
void size(const label n) noexcept
Override size to be inconsistent with allocated storage.
Definition: UListI.H:360
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62