librcsb-core-wrapper  1.000
mapped_vector.h
Go to the documentation of this file.
1 //$$FILE$$
2 //$$VERSION$$
3 //$$DATE$$
4 //$$LICENSE$$
5 
6 
7 #ifndef MAPPED_VECTOR_H
8 #define MAPPED_VECTOR_H
9 
10 
11 #include <vector>
12 #include <map>
13 
14 
20 template <typename T, typename StringCompareT = std::less<T> >
22 {
23  private:
24  typedef std::map<T, unsigned int, StringCompareT> tIndex;
25 
26  tIndex _index;
27 
28  std::vector<T> _vector;
29 
30  mutable std::pair<T, unsigned int> _current;
31 
32  unsigned int get_index(const T& inT) const;
33 
34  bool is_equal(const T& firstT, const T& secondT) const;
35 
36  public:
37  mapped_vector();
38  mapped_vector(const StringCompareT& cmp);
39  mapped_vector(const mapped_vector& inMappedVector);
41 
42  void push_back(const T& inT);
43  unsigned int size() const;
44  bool empty() const;
45 
46  void operator=(const mapped_vector& inMappedVector);
47  void operator=(const std::vector<T>& inVector);
48  bool operator==(const mapped_vector& inMappedVector);
49  bool operator!=(const mapped_vector& inMappedVector);
50 
51  const T& operator[](unsigned int index) const;
52  const std::vector<T>& get_vector() const;
53  std::vector<T>& get_vector();
54 
55  void erase(const T& inT);
56  void insert(const unsigned int index, const T& inT);
57  void index_it();
58 
59  void clear();
60 
62  unsigned int find(const T& inT) const;
63 };
64 
65 
66 #endif