CASM  1.1.0
A Clusters Approach to Statistical Mechanics
DatabaseSetIterator.hh
Go to the documentation of this file.
1 #ifndef CASM_DatabaseSetIterator
2 #define CASM_DatabaseSetIterator
3 
4 #include <memory>
5 #include <set>
6 
7 namespace CASM {
8 
9 namespace DB {
10 
24 template <typename ValueType, typename DatabaseType>
25 class DatabaseSetIterator : public DatabaseIteratorBase<ValueType> {
26  public:
28 
29  std::string name() const override { return m_it->name(); }
30 
31  std::unique_ptr<DatabaseIteratorBase<ValueType> > clone() const {
32  return std::unique_ptr<DatabaseIteratorBase<ValueType> >(this->_clone());
33  }
34 
35  private:
36  friend DatabaseType;
37 
38  typedef typename std::set<ValueType>::iterator base_iterator;
39 
41 
42  base_iterator base() const { return m_it; }
43 
44  bool equal(const DatabaseIteratorBase<ValueType> &other) const override {
45  return m_it == static_cast<const DatabaseSetIterator &>(other).m_it;
46  }
47 
48  void increment() override { ++m_it; }
49 
50  const ValueType &dereference() const override { return *m_it; }
51 
52  /*
53  long distance_to(const DatabaseIteratorBase<ValueType> &other) const override
54  { return std::distance(m_it, static_cast<const DatabaseSetIterator
55  &>(other).m_it);
56  }
57  */
58 
59  DatabaseSetIterator *_clone() const override {
60  return new DatabaseSetIterator(*this);
61  }
62 
64 };
65 
66 } // namespace DB
67 } // namespace CASM
68 
69 #endif
DatabaseIterator for implementations using std::set<ValueType>
std::set< ValueType >::iterator base_iterator
DatabaseSetIterator * _clone() const override
bool equal(const DatabaseIteratorBase< ValueType > &other) const override
const ValueType & dereference() const override
DatabaseSetIterator(base_iterator _it)
std::string name() const override
std::unique_ptr< DatabaseIteratorBase< ValueType > > clone() const
Main CASM namespace.
Definition: APICommand.hh:8