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  public:
23  typedef Seed Value;
24  typedef ValueSet::iterator iterator;
25  typedef ValueSet::const_iterator const_iterator;
26 
27  public:
28  void clear() {
29  Seeds.clear();
30  }
31  void erase(iterator where) {
32  Seeds.erase(where);
33  }
34  size_t size () {
35  return Seeds.size (); // for statistics only
36  }
37  bool empty() {
38  return Seeds.empty();
39  }
40  iterator begin() {
41  return Seeds.begin();
42  }
43  iterator end () {
44  return Seeds.end ();
45  }
46  Value& front() {
47  return Seeds.front();
48  }
49  const_iterator begin()const {
50  return Seeds.begin();
51  }
52  const_iterator end ()const {
53  return Seeds.end ();
54  }
55  const Value& front()const {
56  return Seeds.front();
57  }
58 
59  Value& push_back(const Value& seed) {
60  Seeds.push_back(seed);
61  return Seeds.back();
62  }
63  Value& add(const Value& seed) {
64  iterator where;
65  for(where = Seeds.begin(); where != Seeds.end(); where++) // find position in sorted list
66  if(where->getNumBonds() < seed.getNumBonds())
67  break;
68  iterator it = Seeds.insert(where, EmptySeed);
69  Value& val = *it;
70  val.setMoleculeFragment(seed);
71 
72  return val;
73  }
74  };
75 
76  }
77 }
78 
void setMoleculeFragment(const Seed &src)
Definition: Seed.h:68
Value & add(const Value &seed)
Definition: SeedSet.h:63
iterator begin()
Definition: SeedSet.h:40
void erase(iterator where)
Definition: SeedSet.h:31
Value & push_back(const Value &seed)
Definition: SeedSet.h:59
const Value & front() const
Definition: SeedSet.h:55
unsigned getNumBonds() const
Definition: Seed.h:105
iterator end()
Definition: SeedSet.h:43
const_iterator begin() const
Definition: SeedSet.h:49
Value & front()
Definition: SeedSet.h:46
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:28
ValueSet::iterator iterator
Definition: SeedSet.h:24
const_iterator end() const
Definition: SeedSet.h:52
ValueSet::const_iterator const_iterator
Definition: SeedSet.h:25