BiIndirectList.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) 2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::BiIndirectList
29
30Description
31 Indexes into negList (negative index) or posList (zero or positive index).
32
33SourceFiles
34 BiIndirectListI.H
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef BiIndirectList_H
39#define BiIndirectList_H
40
41#include "List.H"
42
43// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44
45namespace Foam
46{
47
48/*---------------------------------------------------------------------------*\
49 Class BiIndirectList Declaration
50\*---------------------------------------------------------------------------*/
51
52template<class T>
54{
55 // Private Data
56
57 UList<T>& posList_;
58 UList<T>& negList_;
59
60 labelList addressing_;
61
62
63public:
64
65 // Constructors
66
67 //- Construct given the complete lists and the addressing array
68 inline BiIndirectList
69 (
70 const UList<T>& posList,
71 const UList<T>& negList,
72 const labelUList& addr
73 );
74
75 //- Construct given the complete list and by transferring addressing
76 inline BiIndirectList
77 (
78 const UList<T>& posList,
79 const UList<T>& negList,
80 labelList&& addr
81 );
82
83
84 // Member Functions
85
86 // Access
87
88 //- The number of elements in the list
89 inline label size() const noexcept;
90
91 //- True if the list is empty (ie, size() is zero).
92 inline bool empty() const noexcept;
93
94 inline const UList<T>& posList() const noexcept;
95 inline const UList<T>& negList() const noexcept;
96
97 //- Return the list addressing
98 inline const labelList& addressing() const noexcept;
99
100 //- Calculate index given whether index is into posList or negList
101 inline static label posIndex(const label i);
102 inline static label negIndex(const label i);
103
104
105 // Edit
106
107 //- Copy reset addressing
108 inline void resetAddressing(const labelUList& addr);
109
110 //- Move reset addressing
111 inline void resetAddressing(labelList&& addr);
112
113
114 // Member Operators
115
116 //- Return the addressed elements as a List
117 inline List<T> operator()() const;
118
119 //- Return non-const access to an element
120 inline T& operator[](const label i);
121
122 //- Return const access to an element
123 inline const T& operator[](const label i) const;
124
125 //- Assignment to UList of addressed elements
126 inline void operator=(const UList<T>& ae);
127
128 //- Assignment of all entries to the given value
129 inline void operator=(const T& val);
130};
131
132
133// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134
135} // End namespace Foam
136
137// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138
139#include "BiIndirectListI.H"
140
141// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142
143#endif
144
145// ************************************************************************* //
Indexes into negList (negative index) or posList (zero or positive index).
const UList< T > & negList() const noexcept
const labelList & addressing() const noexcept
Return the list addressing.
static label posIndex(const label i)
Calculate index given whether index is into posList or negList.
static label negIndex(const label i)
bool empty() const noexcept
True if the list is empty (ie, size() is zero).
const UList< T > & posList() const noexcept
label size() const noexcept
The number of elements in the list.
void operator=(const UList< T > &ae)
Assignment to UList of addressed elements.
void resetAddressing(const labelUList &addr)
Copy reset addressing.
List< T > operator()() const
Return the addressed elements as a List.
T & operator[](const label i)
Return non-const access to an element.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
const volScalarField & T
Namespace for OpenFOAM.