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