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-2019 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 Member Functions
74 
75  //- Return a null SubList
76  inline static const SubList<T>& null();
77 
78 
79  // Constructors
80 
81  //- Construct from UList, the entire size
82  inline explicit SubList(const UList<T>& list);
83 
84  //- Construct from UList and sub-list size, start at 0
85  inline SubList
86  (
87  const UList<T>& list,
88  const label subSize
89  );
90 
91  //- Construct from UList, sub-list size and start index
92  inline SubList
93  (
94  const UList<T>& list,
95  const label subSize,
96  const label startIndex
97  );
98 
99  //- Construct from UList and a (start,size) range.
100  // The range is subsetted with the list size itself to ensure that the
101  // result always addresses a valid section of the list.
102  inline SubList
103  (
104  const UList<T>& list,
105  const labelRange& range
106  );
107 
108  //- Construct from UList and a (start,size) range, but bypassing
109  //- run-time range checking.
110  inline SubList
111  (
112  const labelRange& range,
113  const UList<T>& list
114  );
115 
116 
117  // Member Operators
118 
119  //- Allow cast to a const List<T>&
120  inline operator const Foam::List<T>&() const;
121 
122  //- Copy assign entries from given sub-list
123  inline void operator=(const SubList<T>& list);
124 
125  //- Copy assign entries to the given list
126  inline void operator=(const UList<T>& list);
127 
128  //- Assign all entries to the given value
129  inline void operator=(const T& val);
130 
131  //- Assign all entries to zero
132  inline void operator=(const zero);
133 };
134 
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 } // End namespace Foam
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 #include "SubListI.H"
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 #endif
147 
148 // ************************************************************************* //
Foam::val
label ListType::const_reference val
Definition: ListOps.H:407
List.H
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:53
SubListI.H
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
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:58
Foam::SubList::SubList
SubList(const UList< T > &list)
Construct from UList, the entire size.
Definition: SubListI.H:33
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: HashTable.H:102
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), which can be used to avoid manipulating objects that ar...
Definition: zero.H:61
Foam::charSubList
SubList< char > charSubList
A SubList of chars.
Definition: SubList.H:57