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-2021 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 #include "FixedList.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class T>
35 (
36  const UList<T>& list
37 )
38 :
39  UList<T>(const_cast<T*>(list.cdata()), list.size())
40 {}
41 
42 
43 template<class T>
44 template<unsigned N>
46 (
47  const FixedList<T, N>& list
48 )
49 :
50  UList<T>(const_cast<T*>(list.cdata()), static_cast<label>(N))
51 {}
52 
53 
54 template<class T>
56 (
57  const UList<T>& list,
58  const label subSize
59 )
60 :
61  UList<T>(const_cast<T*>(list.cdata()), subSize)
62 {
63  #ifdef FULLDEBUG
64  list.checkSize(subSize);
65  #endif
66 }
67 
68 
69 template<class T>
71 (
72  const UList<T>& list,
73  const label subSize,
74  const label startIndex
75 )
76 :
77  UList<T>(const_cast<T*>(list.cdata() + startIndex), subSize)
78 {
79  #ifdef FULLDEBUG
80  list.checkRange(startIndex, subSize);
81  #endif
82 }
83 
84 
85 template<class T>
87 (
88  const UList<T>& list,
89  const labelRange& range
90 )
91 :
92  SubList<T>(range.subset0(list.size()), list)
93 {
94  #ifdef FULLDEBUG
95  // The subset0() above always produces valid ranges but want to check
96  // that the input itself was valid
97  list.checkRange(range.start(), range.size());
98  #endif
99 }
100 
101 
102 template<class T>
104 (
105  const labelRange& range,
106  const UList<T>& list
107 )
108 :
109  SubList<T>(list, range.size(), range.start())
110 {}
111 
112 
113 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114 
115 template<class T>
117 {
118  return NullObjectRef<SubList<T>>();
119 }
120 
121 
122 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
123 
124 template<class T>
126 {
127  return *reinterpret_cast<const List<T>*>(this);
128 }
129 
130 
131 template<class T>
132 inline void Foam::SubList<T>::operator=(const SubList<T>& list)
133 {
134  UList<T>::deepCopy(list);
135 }
136 
137 
138 template<class T>
139 inline void Foam::SubList<T>::operator=(const UList<T>& list)
140 {
141  UList<T>::deepCopy(list);
142 }
143 
144 
145 template<class T>
146 template<class Addr>
148 {
149  UList<T>::deepCopy(list);
150 }
151 
152 
153 template<class T>
154 inline void Foam::SubList<T>::operator=(const T& val)
155 {
156  UList<T>::operator=(val);
157 }
158 
159 
160 template<class T>
161 inline void Foam::SubList<T>::operator=(const Foam::zero)
162 {
164 }
165 
166 
167 // ************************************************************************* //
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: HashTable.H:101
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
A range or interval of labels defined by a start and a size.
Definition: labelRange.H:51
SubList() noexcept=default
Default construct, zero-sized and nullptr.
Base for lists with indirect addressing, templated on the list contents type and the addressing type...
scalar range
void operator=(const SubList< T > &list)
Copy assign entries from given sub-list. Sizes must match!
Definition: SubListI.H:125
A List obtained as a section of another List.
Definition: SubList.H:50
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:99
const volScalarField & T
const Vector< label > N(dict.get< Vector< label >>("N"))
void checkRange(const label start, const label len) const
Check that start and length define a valid range.
Definition: UListI.H:123
static const SubList< T > & null()
Return a null SubList.
Definition: SubListI.H:109
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:58
void checkSize(const label size) const
Check size is within valid range [0,size].
Definition: UListI.H:109
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:157