@@ -37,7 +37,7 @@ struct pair_hash {
3737 }
3838};
3939
40- struct pair_equal : public std ::binary_function<tPairKey, tPairKey, bool > {
40+ struct pair_equal {
4141 inline bool areEqual (double a, double b) const {
4242 return (std::fabs (a - b) < std::numeric_limits<double >::epsilon ());
4343 }
@@ -46,7 +46,7 @@ struct pair_equal : public std::binary_function<tPairKey, tPairKey, bool> {
4646 }
4747};
4848
49- struct array_hash : public std ::unary_function<tArrayKey, std:: size_t > {
49+ struct array_hash {
5050 std::size_t operator ()(const tArrayKey &k) const {
5151 auto h1 = std::hash<double >{}(std::get<0 >(k));
5252 auto h2 = std::hash<double >{}(std::get<1 >(k));
@@ -58,18 +58,15 @@ struct array_hash : public std::unary_function<tArrayKey, std::size_t> {
5858 }
5959};
6060
61- struct array_equal : public std ::binary_function<tArrayKey, tArrayKey, bool > {
62- bool areEqual (double a, double b) const {
63- return (std::fabs (a - b) < std::numeric_limits<double >::epsilon ());
64- }
61+ struct array_equal {
62+ bool areEqual (double a, double b) const { return (std::fabs (a - b) < std::numeric_limits<double >::epsilon ()); }
6563 bool operator ()(const tArrayKey &v0, const tArrayKey &v1) const {
66- return (areEqual (std::get<0 >(v0), std::get<0 >(v1)) &&
67- areEqual (std::get<1 >(v0), std::get<1 >(v1)) &&
64+ return (areEqual (std::get<0 >(v0), std::get<0 >(v1)) && areEqual (std::get<1 >(v0), std::get<1 >(v1)) &&
6865 areEqual (std::get<2 >(v0), std::get<2 >(v1)));
6966 }
7067};
7168
72- struct array2_hash : public std ::unary_function<tArray2Key, std:: size_t > {
69+ struct array2_hash {
7370 std::size_t operator ()(const tArray2Key &k) const {
7471 auto h1 = std::hash<int >{}(std::get<0 >(k));
7572 auto h2 = std::hash<int >{}(std::get<1 >(k));
@@ -79,15 +76,13 @@ struct array2_hash : public std::unary_function<tArray2Key, std::size_t> {
7976 }
8077};
8178
82- struct array2_equal
83- : public std::binary_function<tArray2Key, tArray2Key, bool > {
79+ struct array2_equal {
8480 bool operator ()(const tArray2Key &v0, const tArray2Key &v1) const {
85- return (std::get<0 >(v0) == std::get<0 >(v1) &&
86- std::get<1 >(v0) == std::get<1 >(v1));
81+ return (std::get<0 >(v0) == std::get<0 >(v1) && std::get<1 >(v0) == std::get<1 >(v1));
8782 }
8883};
8984
90- struct tuple_hash : public std ::unary_function<tTupleKey, std:: size_t > {
85+ struct tuple_hash {
9186 std::size_t operator ()(const tTupleKey &k) const {
9287 auto h1 = std::hash<double >{}(std::get<0 >(k));
9388 auto h2 = std::hash<double >{}(std::get<1 >(k));
@@ -99,13 +94,10 @@ struct tuple_hash : public std::unary_function<tTupleKey, std::size_t> {
9994 }
10095};
10196
102- struct tuple_equal : public std ::binary_function<tTupleKey, tTupleKey, bool > {
103- bool areEqual (double a, double b) const {
104- return (std::fabs (a - b) < std::numeric_limits<double >::epsilon ());
105- }
97+ struct tuple_equal {
98+ bool areEqual (double a, double b) const { return (std::fabs (a - b) < std::numeric_limits<double >::epsilon ()); }
10699 bool operator ()(const tTupleKey &v0, const tTupleKey &v1) const {
107- return (areEqual (std::get<0 >(v0), std::get<0 >(v1)) &&
108- areEqual (std::get<1 >(v0), std::get<1 >(v1)) &&
100+ return (areEqual (std::get<0 >(v0), std::get<0 >(v1)) && areEqual (std::get<1 >(v0), std::get<1 >(v1)) &&
109101 areEqual (std::get<2 >(v0), std::get<2 >(v1)));
110102 }
111103};
@@ -121,26 +113,22 @@ class CacheStorageWith2Args {
121113 mutable MutexType mtx;
122114
123115 public:
124- CacheStorageWith2Args (){};
116+ CacheStorageWith2Args () {};
125117 ~CacheStorageWith2Args () { cachedValues.clear (); };
126118 CacheStorageWith2Args (CacheStorageWith2Args &&other) { // Move declaration
127119 std::unique_lock<MutexType>(other.mtx );
128120 }
129- CacheStorageWith2Args &operator =(CacheStorageWith2Args &&other) =
130- delete ; // Move assignment
131- CacheStorageWith2Args (const CacheStorageWith2Args &other) =
132- delete ; // Copy declaration
133- CacheStorageWith2Args &operator =(const CacheStorageWith2Args &other) =
134- delete ; // Copy Assignment
121+ CacheStorageWith2Args &operator =(CacheStorageWith2Args &&other) = delete ; // Move assignment
122+ CacheStorageWith2Args (const CacheStorageWith2Args &other) = delete ; // Copy declaration
123+ CacheStorageWith2Args &operator =(const CacheStorageWith2Args &other) = delete ; // Copy Assignment
135124
136125 void setFunction (std::function<V(Q1, Q2)> f_) { f = f_; }
137126
138127 void cacheValue (const tPairKey &key, V value) { cachedValues[key] = value; }
139128
140129 V getValue (Q1 q1, Q2 q2) {
141130 V result (0 );
142- auto key =
143- std::make_pair (static_cast <double >(q1), static_cast <double >(q2));
131+ auto key = std::make_pair (static_cast <double >(q1), static_cast <double >(q2));
144132 auto it = cachedValues.find (key);
145133 if (it == cachedValues.end ()) {
146134 result = f (q1, q2);
@@ -150,9 +138,7 @@ class CacheStorageWith2Args {
150138 return cachedValues[key];
151139 }
152140
153- V operator [](const std::pair<double , double > &key) const {
154- return cachedValues[key];
155- }
141+ V operator [](const std::pair<double , double > &key) const { return cachedValues[key]; }
156142};
157143
158144template <typename Q1, typename Q2, typename Q3, typename V>
@@ -169,32 +155,26 @@ class CacheStorageWith3Args {
169155 mutable MutexType mtx;
170156
171157 public:
172- CacheStorageWith3Args (){};
158+ CacheStorageWith3Args () {};
173159 ~CacheStorageWith3Args () { cachedValues.clear (); };
174160 CacheStorageWith3Args (CacheStorageWith3Args &&other) { // Move declaration
175161 std::unique_lock<MutexType>(other.mtx );
176162 }
177- CacheStorageWith3Args &operator =(CacheStorageWith3Args &&other) =
178- delete ; // Move assignment
179- CacheStorageWith3Args (const CacheStorageWith3Args &other) =
180- delete ; // Copy declaration
181- CacheStorageWith3Args &operator =(const CacheStorageWith3Args &other) =
182- delete ; // Copy Assignment
163+ CacheStorageWith3Args &operator =(CacheStorageWith3Args &&other) = delete ; // Move assignment
164+ CacheStorageWith3Args (const CacheStorageWith3Args &other) = delete ; // Copy declaration
165+ CacheStorageWith3Args &operator =(const CacheStorageWith3Args &other) = delete ; // Copy Assignment
183166
184167 void setFunction (std::function<V(Q1, Q2, Q3)> f_) { f = f_; }
185168
186- void cacheValue (const tTupleKey &key, V value) {
187- cachedValues[key] = value;
188- }
169+ void cacheValue (const tTupleKey &key, V value) { cachedValues[key] = value; }
189170
190171 V getValue (Q1 q1, Q2 q2, Q3 q3) {
191172 V result (0 );
192173 /* auto key = std::make_tuple(
193174 static_cast<double>(q1),
194175 static_cast<double>(q2),
195176 static_cast<double>(q3));*/
196- tTupleKey key = {{static_cast <double >(q1), static_cast <double >(q2),
197- static_cast <double >(q3)}};
177+ tTupleKey key = {{static_cast <double >(q1), static_cast <double >(q2), static_cast <double >(q3)}};
198178 auto it = cachedValues.find (key);
199179 if (it == cachedValues.end ()) {
200180 result = f (q1, q2, q3);
@@ -207,18 +187,13 @@ class CacheStorageWith3Args {
207187class CacheStorageIC2 {
208188 private:
209189 typedef std::array<int , 2 > tArray2Key;
210- std::unordered_map<tArray2Key, QGREmissivity, array2_hash, array2_equal>
211- cachedValues;
190+ std::unordered_map<tArray2Key, QGREmissivity, array2_hash, array2_equal> cachedValues;
212191 std::function<QGREmissivity(int , int , QEnergy)> f;
213192
214193 public:
215- void setFunction (std::function<QGREmissivity(int , int , QEnergy)> f_) {
216- f = f_;
217- }
194+ void setFunction (std::function<QGREmissivity(int , int , QEnergy)> f_) { f = f_; }
218195
219- void cacheValue (const tArray2Key &key, QGREmissivity value) {
220- cachedValues[key] = value;
221- }
196+ void cacheValue (const tArray2Key &key, QGREmissivity value) { cachedValues[key] = value; }
222197
223198 QGREmissivity getValue (int q1, int q2, QEnergy q3) {
224199 QGREmissivity result (0 );
@@ -233,10 +208,8 @@ class CacheStorageIC2 {
233208};
234209
235210typedef CacheStorageWith3Args<int , int , QEnergy, QGREmissivity> CacheStorageIC;
236- typedef CacheStorageWith2Args<QEnergy, QEnergy, QDiffCrossSection>
237- CacheStorageCrossSection;
238- typedef CacheStorageWith3Args<QEnergy, QEnergy, QEnergy, QDiffCrossSection>
239- CacheStorageCrossSection3Args;
211+ typedef CacheStorageWith2Args<QEnergy, QEnergy, QDiffCrossSection> CacheStorageCrossSection;
212+ typedef CacheStorageWith3Args<QEnergy, QEnergy, QEnergy, QDiffCrossSection> CacheStorageCrossSection3Args;
240213
241214} // namespace hermes
242215
0 commit comments