RDKit
Open-source cheminformatics and machine learning.
SeedSet.h
Go to the documentation of this file.
1 // $Id$
2 //
3 // Copyright (C) 2014 Novartis Institutes for BioMedical Research
4 //
5 // @@ All Rights Reserved @@
6 // This file is part of the RDKit.
7 // The contents are covered by the terms of the BSD license
8 // which is included in the file license.txt, found at the root
9 // of the RDKit source tree.
10 //
11 #pragma once
12 #include <map>
13 #include <algorithm>
14 #include "Seed.h"
15 
16 namespace RDKit {
17 namespace FMCS {
18 class SeedSet { // sorted by amount of bonds
19  typedef std::list<Seed> ValueSet;
20  ValueSet Seeds;
21  Seed EmptySeed;
22 
23  public:
24  typedef Seed Value;
25  typedef ValueSet::iterator iterator;
26  typedef ValueSet::const_iterator const_iterator;
27 
28  public:
29  void clear() { Seeds.clear(); }
30  void erase(iterator where) { Seeds.erase(where); }
31  size_t size() {
32  return Seeds.size(); // for statistics only
33  }
34  bool empty() { return Seeds.empty(); }
35  iterator begin() { return Seeds.begin(); }
36  iterator end() { return Seeds.end(); }
37  Value& front() { return Seeds.front(); }
38  const_iterator begin() const { return Seeds.begin(); }
39  const_iterator end() const { return Seeds.end(); }
40  const Value& front() const { return Seeds.front(); }
41 
42  Value& push_back(const Value& seed) {
43  Seeds.push_back(seed);
44  return Seeds.back();
45  }
46  Value& add(const Value& seed) {
47  iterator where;
48  for (where = Seeds.begin(); where != Seeds.end();
49  where++) // find position in sorted list
50  if (where->getNumBonds() < seed.getNumBonds()) break;
51  iterator it = Seeds.insert(where, EmptySeed);
52  Value& val = *it;
53  val.setMoleculeFragment(seed);
54 
55  return val;
56  }
57 };
58 }
59 }
void setMoleculeFragment(const Seed &src)
Definition: Seed.h:91
Value & add(const Value &seed)
Definition: SeedSet.h:46
iterator begin()
Definition: SeedSet.h:35
void erase(iterator where)
Definition: SeedSet.h:30
Value & push_back(const Value &seed)
Definition: SeedSet.h:42
const Value & front() const
Definition: SeedSet.h:40
unsigned getNumBonds() const
Definition: Seed.h:126
iterator end()
Definition: SeedSet.h:36
const_iterator begin() const
Definition: SeedSet.h:38
Value & front()
Definition: SeedSet.h:37
Std stuff.
Definition: Atom.h:29
ValueSet::iterator iterator
Definition: SeedSet.h:25
const_iterator end() const
Definition: SeedSet.h:39
ValueSet::const_iterator const_iterator
Definition: SeedSet.h:26