CBMC
expanding_vector.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 
10 #ifndef CPROVER_UTIL_EXPANDING_VECTOR_H
11 #define CPROVER_UTIL_EXPANDING_VECTOR_H
12 
13 #include <vector>
14 
15 template<typename T>
17 {
18  typedef std::vector<T> data_typet;
20 
21 public:
22  // NOLINTNEXTLINE(readability/identifiers)
23  typedef typename data_typet::size_type size_type;
24  // NOLINTNEXTLINE(readability/identifiers)
25  typedef typename data_typet::iterator iterator;
26  // NOLINTNEXTLINE(readability/identifiers)
27  typedef typename data_typet::const_iterator const_iterator;
28 
30  {
31  if(n>=data.size())
32  data.resize(n+1);
33  return data[n];
34  }
35 
36  void clear() { data.clear(); }
37 
38  iterator begin() { return data.begin(); }
39  const_iterator begin() const { return data.begin(); }
40  const_iterator cbegin() const { return data.cbegin(); }
41 
42  iterator end() { return data.end(); }
43  const_iterator end() const { return data.end(); }
44  const_iterator cend() const { return data.cend(); }
45 
46  size_type size() const { return data.size(); }
47 
48  void push_back(const T &t) { data.push_back(t); }
49  void push_back(T &&t) { data.push_back(std::move(t)); }
50 };
51 
52 #endif // CPROVER_UTIL_EXPANDING_VECTOR_H
std::vector< T > data_typet
size_type size() const
data_typet::iterator iterator
const_iterator cend() const
data_typet::const_iterator const_iterator
const_iterator begin() const
void push_back(T &&t)
const_iterator cbegin() const
void push_back(const T &t)
T & operator[](typename std::vector< T >::size_type n)
const_iterator end() const
data_typet::size_type size_type
#define size_type
Definition: unistd.c:347