Atoms Crowd  7.0.0
Set.h
1 #pragma once
2 #include <ToolchefsSTL/Allocators/Allocator.h>
3 
4 namespace ToolchefsSTL
5 {
6  template<typename T>
7  class Set
8  {
9  public:
10 
11  template <class Iter>
13  {
14  ReverseIterator(Iter* ptr) : m_ptr(ptr) {}
15  ~ReverseIterator() = default;
16  Iter* operator +(size_t value) const { return m_ptr - value; }
17  Iter* operator -(size_t value) const { return m_ptr + value; }
18  Iter* operator ++() { return --m_ptr; }
19  Iter* operator --() { return ++m_ptr; }
20  bool operator ==(const ReverseIterator& rhs) const { return m_ptr == rhs.m_ptr; }
21  bool operator !=(const ReverseIterator& rhs) const { return m_ptr != rhs.m_ptr; }
22  Iter operator *() const { return *m_ptr; }
23  Iter* operator->() const { return m_ptr; }
24  Iter* m_ptr;
25  };
26 
27  typedef T value_type;
28  typedef T& reference_type;
29  typedef T* ptr_type;
30 
31  typedef T* iterator;
32  typedef const T* const_iterator;
35 
36  explicit Set(Allocator* allocator = defaultAllocator()) noexcept;
37 
38  ~Set() noexcept;
39 
40  Set(const Set& rhs) noexcept;
41 
42  Set& operator=(const Set& rhs) noexcept;
43 
44  Set(Set&& rhs) noexcept;
45 
46  Set& operator=(Set&& rhs) noexcept;
47 
48  bool operator==(const Set& rhs) const noexcept;
49 
50  void insert(const T& element) noexcept;
51 
52  void erase(const T& element) noexcept;
53  void erase(iterator it) noexcept;
54 
56  iterator begin() noexcept;
57  iterator end() noexcept;
58  const_iterator cbegin() const noexcept;
59  const_iterator cend() const noexcept;
60 
61  reverse_iterator rbegin() noexcept;
62  reverse_iterator rend() noexcept;
63  const_reverse_iterator crbegin() const noexcept;
64  const_reverse_iterator crend() const noexcept;
65 
66  const T* data() const noexcept;
67 
68  void reserve(size_t new_capacity) noexcept;
69 
70  void clear() noexcept;
71 
72  size_t size() const noexcept;
73 
74  size_t length() const noexcept;
75 
76  size_t capacity() const noexcept;
77 
78  void shrink_to_fit() noexcept;
79 
80  iterator find(const T& element) noexcept;
81 
82  const_iterator find(const T& element) const noexcept;
83 
84  bool empty() const noexcept;
85 
86  private:
87 
88  void resize(size_t new_length) noexcept;
89 
90  T& back() noexcept;
91  const T& back() const noexcept;
92 
93  T& front() noexcept;
94  const T& front() const noexcept;
95 
96  void grow() noexcept;
97 
98  private:
99 
100  T* m_data;
101  Allocator* m_allocator;
102  size_t m_length;
103  size_t m_capacity;
104  };
105 }
106 
107 #include "Set.impl.h"
Definition: Allocator.h:10
Definition: Set.h:8
iterator begin() noexcept
Iterators.
Definition: Set.impl.h:122