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 
60  labelList addressing_;
61 
62 
63 public:
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 // ************************************************************************* //
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::negList
const UList< T > & negList() const noexcept
Definition: BiIndirectListI.H:99
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::addressing
const labelList & addressing() const noexcept
Return the list addressing.
Definition: BiIndirectListI.H:107
Foam::BiIndirectList
Indexes into negList (negative index) or posList (zero or positive index).
Definition: BiIndirectList.H:52
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::posList
const UList< T > & posList() const noexcept
Definition: BiIndirectListI.H:92