-
Notifications
You must be signed in to change notification settings - Fork 0
/
uint_vector.h
51 lines (29 loc) · 1.13 KB
/
uint_vector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef BIGINT_UINT_VECTOR_H
#define BIGINT_UINT_VECTOR_H
#include <variant>
#include <vector>
#include <array>
#include <memory>
class uint_vector {
std::variant<std::array<uint32_t, 4>, std::shared_ptr<std::vector<uint32_t>>> data_;
typedef std::iterator<std::random_access_iterator_tag, uint32_t> iter;
typedef std::iterator<std::random_access_iterator_tag, uint32_t const> citer;
public:
uint_vector();
uint_vector(uint_vector const &rhs);
uint_vector(size_t count, uint32_t value);
uint_vector &operator=(uint_vector const &rhs) = default;
void push_back(uint32_t value);
void pop_back();
uint32_t *data();
uint32_t const * const data() const;
size_t size() const noexcept;
uint32_t const &operator[](uint32_t i) const;
uint32_t &operator[](uint32_t i);
void begin_erase(size_t count);
void begin_insert(size_t count, uint32_t val);
void assign(size_t count, uint32_t value);
friend bool operator==(uint_vector const &lhs, uint_vector const &rhs);
friend bool operator!=(uint_vector const &lhs, uint_vector const &rhs);
};
#endif //BIGINT_UINT_VECTOR_H