RDKit
Open-source cheminformatics and machine learning.
MatchTable.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2014 Novartis Institutes for BioMedical Research
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 #pragma once
11 #include <vector>
12 #include <stdexcept>
13 
14 namespace RDKit {
15 namespace FMCS {
16 template <typename T>
17 class TArray2D { // for scalar value types ! including bool with special STL
18  // implementation (no reference to item - bitset used)
19  size_t XSize;
20  size_t YSize;
21  std::vector<T> Data;
22 
23  public:
24  inline TArray2D(size_t cy = 0, size_t cx = 0)
25  : XSize(cx), YSize(cy), Data(cx * cy) {}
26  inline size_t getXSize() const { return XSize; }
27  inline size_t getYSize() const { return YSize; }
28  inline bool empty() const { return Data.empty(); }
29  inline void clear() {
30  Data.clear();
31  XSize = 0;
32  YSize = 0;
33  }
34  inline void resize(size_t cy, size_t cx) {
35  Data.resize(cx * cy);
36  XSize = cx;
37  YSize = cy;
38  }
39  inline void set(size_t row, size_t col, T val) {
40  Data[row * XSize + col] = val;
41  }
42  inline T at(size_t row, size_t col) { return Data[row * XSize + col]; }
43  inline T at(size_t row, size_t col) const { return Data[row * XSize + col]; }
44 };
45 
46 typedef TArray2D<bool> MatchTable; // row is index in QueryMolecule
47 }
48 }
TArray2D< bool > MatchTable
Definition: MatchTable.h:46
T at(size_t row, size_t col) const
Definition: MatchTable.h:43
bool empty() const
Definition: MatchTable.h:28
TArray2D(size_t cy=0, size_t cx=0)
Definition: MatchTable.h:24
Std stuff.
Definition: Atom.h:29
size_t getYSize() const
Definition: MatchTable.h:27
size_t getXSize() const
Definition: MatchTable.h:26
void resize(size_t cy, size_t cx)
Definition: MatchTable.h:34
T at(size_t row, size_t col)
Definition: MatchTable.h:42