SubList.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 Class
28  Foam::SubList
29 
30 Description
31  A List obtained as a section of another List.
32 
33  Since the SubList is itself unallocated, no storage is allocated or
34  de-allocated during its use. To achieve this behaviour, SubList is
35  derived from UList rather than List.
36 
37 SourceFiles
38  SubListI.H
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef SubList_H
43 #define SubList_H
44 
45 #include "List.H"
46 #include "labelRange.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward Declarations
54 template<class T> class SubList;
55 
56 // Common list types
60 
61 
62 /*---------------------------------------------------------------------------*\
63  Class SubList Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 template<class T>
67 class SubList
68 :
69  public UList<T>
70 {
71 public:
72 
73  // Static Functions
74 
75  //- Return a null SubList
76  inline static const SubList<T>& null();
77 
78 
79  // Generated Methods
80 
81  //- Copy construct
82  SubList(const SubList&) = default;
83 
84 
85  // Constructors
86 
87  //- Construct from UList, the entire size
88  inline explicit SubList(const UList<T>& list);
89 
90  //- Construct from UList and sub-list size, start at 0
91  inline SubList
92  (
93  const UList<T>& list,
94  const label subSize
95  );
96 
97  //- Construct from UList, sub-list size and start index
98  inline SubList
99  (
100  const UList<T>& list,
101  const label subSize,
102  const label startIndex
103  );
104 
105  //- Construct from UList and a (start,size) range.
106  // The range is subsetted with the list size itself to ensure that the
107  // result always addresses a valid section of the list.
108  inline SubList
109  (
110  const UList<T>& list,
111  const labelRange& range
112  );
113 
114  //- Construct from UList and a (start,size) range, but bypassing
115  //- run-time range checking.
116  inline SubList
117  (
118  const labelRange& range,
119  const UList<T>& list
120  );
121 
122 
123  // Member Operators
124 
125  //- Allow cast to a const List<T>&
126  inline operator const Foam::List<T>&() const;
127 
128  //- Copy assign entries from given sub-list
129  inline void operator=(const SubList<T>& list);
130 
131  //- Copy assign entries from given list
132  inline void operator=(const UList<T>& list);
133 
134  //- Assign all entries to the given value
135  inline void operator=(const T& val);
136 
137  //- Assign all entries to zero
138  inline void operator=(const Foam::zero);
139 };
140 
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 } // End namespace Foam
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 #include "SubListI.H"
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 #endif
153 
154 // ************************************************************************* //
List.H
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:53
SubListI.H
Foam::labelSubList
SubList< label > labelSubList
A SubList of labels.
Definition: SubList.H:58
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
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.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::SubList::operator=
void operator=(const SubList< T > &list)
Copy assign entries from given sub-list.
Definition: SubListI.H:125
Foam::boolSubList
SubList< bool > boolSubList
A SubList of bools.
Definition: SubList.H:53
range
scalar range
Definition: LISASMDCalcMethod1.H:12
labelRange.H
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::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62
Foam::charSubList
SubList< char > charSubList
A SubList of chars.
Definition: SubList.H:57