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 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::Map
29 
30 Description
31  A HashTable to objects of type <T> with a label key.
32 
33 Note
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 
38 See also
39  PtrMap
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef Map_H
44 #define Map_H
45 
46 #include "HashTable.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class Map Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 template<class T>
58 class Map
59 :
60  public HashTable<T, label, Hash<label>>
61 {
62 public:
63 
64  //- The template instance used for this Map
65  typedef Map<T> this_type;
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 with default table capacity
77  Map()
78  :
79  parent_type()
80  {}
81 
82  //- Construct with given initial table capacity
83  explicit Map(const label size)
84  :
85  parent_type(size)
86  {}
87 
88  //- Construct from Istream with default 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)
102  :
103  parent_type(std::move(map))
104  {}
105 
106  //- Construct from an initializer list
107  Map(std::initializer_list<std::pair<label, T>> map)
108  :
109  parent_type(map)
110  {}
111 
112 
113  // Member Operators
114 
115  using parent_type::operator=;
116 
117  //- Copy assignment
118  void operator=(const this_type& rhs)
119  {
121  }
122 
123  //- Move assignment
124  void operator=(this_type&& rhs)
125  {
126  parent_type::operator=(std::move(rhs));
127  }
128 };
129 
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 
133 } // End namespace Foam
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 #endif
138 
139 // ************************************************************************* //
Foam::Map< patchControl >::const_iterator
typename parent_type::const_iterator const_iterator
Definition: Map.H:70
HashTable.H
Foam::HashTable::iterator
Forward iterator with non-const access.
Definition: HashTable.H:681
Foam::HashTable::const_iterator
Forward iterator with const access.
Definition: HashTable.H:742
Foam::Map::operator=
void operator=(const this_type &rhs)
Copy assignment.
Definition: Map.H:117
Foam::Map::Map
Map(Istream &is)
Construct from Istream with default table capacity.
Definition: Map.H:88
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: lumpedPointController.H:69
Foam::Map< patchControl >::iterator
typename parent_type::iterator iterator
Definition: Map.H:69
Foam::HashTable::operator=
void operator=(const this_type &rhs)
Copy assign.
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::Map::Map
Map(std::initializer_list< std::pair< label, T >> map)
Construct from an initializer list.
Definition: Map.H:106
Foam::Map::Map
Map(const label size)
Construct with given initial table capacity.
Definition: Map.H:82
Foam::Map::this_type
Map< T > this_type
The template instance used for this Map.
Definition: Map.H:64
Foam::Map::Map
Map(this_type &&map)
Move construct.
Definition: Map.H:100
Foam::Map::Map
Map()
Default construct with default table capacity.
Definition: Map.H:76
Foam::Map::operator=
void operator=(this_type &&rhs)
Move assignment.
Definition: Map.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::HashTable
A HashTable similar to std::unordered_map.
Definition: HashTable.H:105
Foam::Map::Map
Map(const this_type &map)
Copy construct.
Definition: Map.H:94
Foam::Map::parent_type
HashTable< T, label, Hash< label > > parent_type
The template instance used for the parent HashTable.
Definition: Map.H:67