CASM  1.1.0
A Clusters Approach to Statistical Mechanics
ScelDatabase.cc
Go to the documentation of this file.
2 
3 namespace CASM {
4 namespace DB {
5 
7  return _iterator(m_scel_list.begin());
8 }
9 
11  return _iterator(m_scel_list.end());
12 }
13 
15  return m_scel_list.size();
16 }
17 
18 std::pair<Database<Supercell>::iterator, bool> Database<Supercell>::insert(
19  const Supercell &obj) {
20  return _on_insert_or_emplace(m_scel_list.insert(obj));
21 }
22 
23 std::pair<Database<Supercell>::iterator, bool> Database<Supercell>::insert(
24  const Supercell &&obj) {
25  return _on_insert_or_emplace(m_scel_list.insert(std::move(obj)));
26 }
27 
30  base_iterator base_it = static_cast<it_type *>(pos.get())->base();
31  m_name_to_scel.erase(base_it->name());
32  master_selection().data().erase(base_it->name());
33  return _iterator(m_scel_list.erase(base_it));
34 }
35 
37  const std::string &name_or_alias) const {
38  std::string name = this->name(name_or_alias);
39  auto it = m_name_to_scel.find(name);
40  if (it == m_name_to_scel.end()) {
41  return _iterator(m_scel_list.end());
42  } else {
43  return _iterator(it->second);
44  }
45 }
46 
47 std::pair<Database<Supercell>::iterator, bool>
49  const std::pair<base_iterator, bool> &result) {
50  if (result.second) {
51  const value_type &obj = *result.first;
52 
53  // update
54  m_name_to_scel.insert(std::make_pair(obj.name(), result.first));
55  master_selection().data().emplace(obj.name(), false);
56  }
57 
58  return std::make_pair(_iterator(result.first), result.second);
59 }
60 
62  m_name_to_scel.clear();
63  m_scel_list.clear();
64 }
65 
67  base_iterator base_it) const {
68  return iterator(
70 }
71 
72 } // namespace DB
73 } // namespace CASM
std::set< Supercell >::iterator base_iterator
Definition: ScelDatabase.hh:61
DatabaseIterator for implementations using std::set<ValueType>
std::string name() const
Definition: Named_impl.hh:14
Represents a supercell of the primitive parent crystal structure.
Definition: Supercell.hh:51
std::pair< DB::DatabaseIterator< Supercell >, bool > insert() const
Insert the canonical form of this into the database.
Definition: Supercell.cc:283
Main CASM namespace.
Definition: APICommand.hh:8
GenericDatumFormatter< std::string, DataObject > name()
Iterator find(Iterator begin, Iterator end, const T &value, BinaryCompare q)
Equivalent to std::find(begin, end, value), but with custom comparison.
Definition: algorithm.hh:16