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