hashMap.hh

Go to the documentation of this file.
1 
7 #ifndef hashMap_hh
8 #define hashMap_hh
9 
10 #include <functional>
11 #include <unordered_map>
12 
13 #include "basics/outputOperator.hh"
14 #include "basics/outputMatlab.hh"
15 
16 namespace concepts {
17 
18  template<class F>
19  class HashMap : public std::unordered_map<uint, F>, public virtual OutputOperator {
20  public:
21 
23  bool exists(uint i) const {
24  return this->find(i) != this->end();
25  }
26  protected:
27  virtual std::ostream& info(std::ostream& os) const;
28  };
29 
30  template<class F>
31  std::ostream& HashMap<F>::info(std::ostream& os) const {
32  os << concepts::typeOf(*this)<<"(" << this->size() << ": " << std::endl;
33  for (typename concepts::HashMap<F>::
34  const_iterator i = this->begin(); i != this->end(); ++i)
35  os << " " << i->first << " - "
36  << OutputMatlab<F>(i->second) << std::endl;
37  return os << ')';
38  }
39 
40 } // namespace concepts
41 
42 #endif
Class for output of objects to matlab.
Definition: outputMatlab.hh:88
bool exists(uint i) const
Returns true if the entrance exists.
Definition: hashMap.hh:23
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
Class providing an output operator.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition: hashMap.hh:31
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich