IndexVectorMapTool.h
Go to the documentation of this file.
1 // IndexVectorMapTool.h
2 
3 // David Adams
4 // June 2018
5 // June 2020: Change get to return by balue instead of ref.
6 //
7 // Interface for tools that map one index to a vector of indices.
8 
9 #ifndef IndexVectorMapTool_H
10 #define IndexVectorMapTool_H
11 
12 #include <vector>
13 #include <algorithm>
14 
16 
17 public:
18 
19  using Index = unsigned int;
20  using IndexVector = std::vector<Index>;
21 
22  static Index badIndex() { return -1; }
23 
24  virtual ~IndexVectorMapTool() =default;
25 
26  // Return the vector for an index.
27  virtual IndexVector get(Index idx) const =0;
28 
29  // Return if the vector for an index contains a value.
30  virtual bool contains(Index idx, Index val) {
31  IndexVector vec = get(idx);
32  return find(vec.begin(), vec.end(), val) != vec.end();
33  }
34 
35 };
36 
37 #endif
std::vector< Index > IndexVector
virtual ~IndexVectorMapTool()=default
virtual bool contains(Index idx, Index val)
static Index badIndex()