Loading...
Searching...
No Matches
Map.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-2025 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::Map
29
30Description
31 A HashTable to objects of type <T> with a label key.
32
33Note
34 The Map contents are unordered.
35 When the key order is important, use the sortedToc() method to obtain
36 a list of sorted keys and use that for further access.
37
38See also
39 PtrMap
40
41\*---------------------------------------------------------------------------*/
42
43#ifndef Foam_Map_H
44#define Foam_Map_H
45
46#include "HashTable.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
52
53/*---------------------------------------------------------------------------*\
54 Class Map Declaration
55\*---------------------------------------------------------------------------*/
56
57template<class T>
58class Map
59:
60 public HashTable<T, label, Hash<label>>
61{
62public:
63
64 //- The template instance used for this Map
66
67 //- The template instance used for the parent HashTable
69
70 using iterator = typename parent_type::iterator;
72
73
74 // Constructors
75
76 //- Default construct: empty without allocation (capacity=0)
77 constexpr Map() noexcept = default;
78
79 //- Construct empty without allocation (capacity=0)
80 explicit constexpr Map(Foam::zero) noexcept : this_type() {}
82 //- Construct empty with given initial table capacity
83 explicit Map(const label initialCapacity)
84 :
85 parent_type(initialCapacity)
86 {}
87
88 //- Construct from Istream (with default initial table capacity)
89 Map(Istream& is)
90 :
91 parent_type(is)
92 {}
93
94 //- Copy construct
95 Map(const this_type& map)
96 :
97 parent_type(map)
98 {}
99
100 //- Move construct
101 Map(this_type&& map) noexcept
103 parent_type(std::move(map))
104 {}
105
106 //- Construct from key/value pairs in initializer list
107 // By default, uses insert not overwrite semantics for duplicates.
108 Map
109 (
110 std::initializer_list<std::pair<label, T>> map,
111 const bool overwrite = false
112 )
113 :
114 parent_type(map, overwrite)
115 {}
116
117 //- Construct from key/value pairs
118 // By default, uses insert not overwrite semantics for duplicates.
119 Map
121 const UList<label>& keys,
122 const UList<T>& values,
123 const bool overwrite = false
124 )
125 :
126 parent_type(keys, values, overwrite)
127 {}
128
129
130 // Member Operators
131
133
134 //- Copy assignment
135 void operator=(const this_type& rhs)
136 {
138 }
139
140 //- Move assignment
141 void operator=(this_type&& rhs)
142 {
143 parent_type::operator=(std::move(rhs));
144 }
145};
146
147
148// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149
150} // End namespace Foam
151
152// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153
154#endif
155
156// ************************************************************************* //
Forward iterator with const access.
Definition HashTable.H:1135
Forward iterator with non-const access.
Definition HashTable.H:1043
const_iterator_pair< const_key_iterator, this_type > keys() const
A const iterator begin/end pair for iterating over keys.
Definition HashTable.H:1295
friend Ostream & operator(Ostream &, const HashTable< T, label, Hash > &tbl)
void operator=(const this_type &rhs)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
Map(this_type &&map) noexcept
Move construct.
Definition Map.H:110
typename parent_type::iterator iterator
Definition Map.H:67
HashTable< interfaceEntry, label, Hash< label > > parent_type
Definition Map.H:65
Map< interfaceEntry > this_type
Definition Map.H:60
Map(const label initialCapacity)
Construct empty with given initial table capacity.
Definition Map.H:86
void operator=(this_type &&rhs)
Move assignment.
Definition Map.H:160
Map(std::initializer_list< std::pair< label, T > > map, const bool overwrite=false)
Construct from key/value pairs in initializer list.
Definition Map.H:121
constexpr Map() noexcept=default
Default construct: empty without allocation (capacity=0).
Map(const UList< label > &keys, const UList< T > &values, const bool overwrite=false)
Construct from key/value pairs.
Definition Map.H:135
Map(Istream &is)
Construct from Istream (with default initial table capacity).
Definition Map.H:94
Map(const this_type &map)
Copy construct.
Definition Map.H:102
typename parent_type::const_iterator const_iterator
Definition Map.H:68
void operator=(const this_type &rhs)
Copy assignment.
Definition Map.H:152
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:89
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
Namespace for OpenFOAM.
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
const direction noexcept
Definition scalarImpl.H:265