RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
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
17namespace RDKit {
18namespace FMCS {
19class 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()) {
52 break;
53 }
54 }
55 iterator it = Seeds.insert(where, EmptySeed);
56 Value &val = *it;
57 val.setMoleculeFragment(seed);
58
59 return val;
60 }
61};
62} // namespace FMCS
63} // namespace RDKit
iterator end()
Definition SeedSet.h:37
ValueSet::iterator iterator
Definition SeedSet.h:26
Value & add(const Value &seed)
Definition SeedSet.h:47
iterator begin()
Definition SeedSet.h:36
const_iterator begin() const
Definition SeedSet.h:39
Value & push_back(const Value &seed)
Definition SeedSet.h:43
ValueSet::const_iterator const_iterator
Definition SeedSet.h:27
Value & front()
Definition SeedSet.h:38
void erase(iterator where)
Definition SeedSet.h:31
const Value & front() const
Definition SeedSet.h:41
const_iterator end() const
Definition SeedSet.h:40
void setMoleculeFragment(const Seed &src)
Definition Seed.h:101
#define RDKIT_FMCS_EXPORT
Definition export.h:153
Std stuff.