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 #include <RDGeneral/export.h>
12 #pragma once
13 #include <map>
14 #include <algorithm>
15 #include "Seed.h"
16 
17 namespace RDKit {
18 namespace FMCS {
19 class RDKIT_FMCS_EXPORT SeedSet { // sorted by amount of bonds
20  typedef std::list<Seed> ValueSet;
21  ValueSet Seeds;
22  Seed EmptySeed;
23 
24  public:
25  typedef Seed Value;
26  typedef ValueSet::iterator iterator;
27  typedef ValueSet::const_iterator const_iterator;
28 
29  public:
30  void clear() { Seeds.clear(); }
31  void erase(iterator where) { Seeds.erase(where); }
32  size_t size() {
33  return Seeds.size(); // for statistics only
34  }
35  bool empty() { return Seeds.empty(); }
36  iterator begin() { return Seeds.begin(); }
37  iterator end() { return Seeds.end(); }
38  Value& front() { return Seeds.front(); }
39  const_iterator begin() const { return Seeds.begin(); }
40  const_iterator end() const { return Seeds.end(); }
41  const Value& front() const { return Seeds.front(); }
42 
43  Value& push_back(const Value& seed) {
44  Seeds.push_back(seed);
45  return Seeds.back();
46  }
47  Value& add(const Value& seed) {
48  iterator where;
49  for (where = Seeds.begin(); where != Seeds.end();
50  where++) // find position in sorted list
51  if (where->getNumBonds() < seed.getNumBonds()) break;
52  iterator it = Seeds.insert(where, EmptySeed);
53  Value& val = *it;
54  val.setMoleculeFragment(seed);
55 
56  return val;
57  }
58 };
59 }
60 }
void setMoleculeFragment(const Seed &src)
Definition: Seed.h:92
Value & add(const Value &seed)
Definition: SeedSet.h:47
const_iterator begin() const
Definition: SeedSet.h:39
iterator begin()
Definition: SeedSet.h:36
#define RDKIT_FMCS_EXPORT
Definition: export.h:190
void erase(iterator where)
Definition: SeedSet.h:31
Value & push_back(const Value &seed)
Definition: SeedSet.h:43
iterator end()
Definition: SeedSet.h:37
const Value & front() const
Definition: SeedSet.h:41
Value & front()
Definition: SeedSet.h:38
Std stuff.
Definition: Atom.h:30
const_iterator end() const
Definition: SeedSet.h:40
ValueSet::iterator iterator
Definition: SeedSet.h:26
ValueSet::const_iterator const_iterator
Definition: SeedSet.h:27
unsigned getNumBonds() const
Definition: Seed.h:127