omw  0.2.0
vector.h
1 /*
2 author Oliver Blaser
3 date 25.01.2022
4 copyright MIT - Copyright (c) 2022 Oliver Blaser
5 */
6 
7 #ifndef IG_OMW_VECTOR_H
8 #define IG_OMW_VECTOR_H
9 
10 #include <cstddef>
11 #include <cstdint>
12 #include <initializer_list>
13 #include <memory>
14 #include <vector>
15 
16 namespace omw
17 {
22  template <class T, class Allocator = std::allocator<T>>
23  class vector : public std::vector<T, Allocator>
24  {
25 #ifndef OMWi_DOXYGEN_PREDEFINE
26  public:
27  using value_type = typename std::vector<T, Allocator>::value_type;
28  using size_type = typename std::vector<T, Allocator>::size_type;
29 #endif // OMWi_DOXYGEN_PREDEFINE
30 
31  public:
32  static constexpr size_type maxsz = static_cast<size_type>(-1);
33 
34  public:
35  vector() : std::vector<T, Allocator>() {}
36  explicit vector(size_type count) : std::vector<T, Allocator>(count) {}
37  vector(size_type count, const T& value) : std::vector<T, Allocator>(count, value) {}
38  vector(const T* first, const T* last) : std::vector<T, Allocator>(first, last) {}
39  vector(std::initializer_list<T> init) : std::vector<T, Allocator>(init) {}
40  vector(const std::vector<T, Allocator>& other) : std::vector<T, Allocator>(other) {}
41  ~vector() {}
42 
43  bool contains(const T& item) const
44  {
45  bool r = false;
46  for (size_type i = 0; (i < this->size()) && !r; ++i)
47  if (this->at(i) == item) r = true;
48  return r;
49  }
50 
51  void reserveAdd(size_type addCap) { this->reserve(this->size() + addCap); }
52  };
53 
55 }
56 
57 #endif // IG_OMW_VECTOR_H
omw::vector
Definition: vector.h:24
omw::vector::reserveAdd
void reserveAdd(size_type addCap)
Definition: vector.h:51
omw
Main namespace.