|
ztsdb
|
19 #ifndef VALUE_VECTOR_HPP
20 #define VALUE_VECTOR_HPP
24 #include "valuevar.hpp"
34 typedef val::Value value_type;
40 template <typename U, typename UO>
41 friend void setv(Vector<U,UO>& v, size_t i, const U& t);
42 template <typename U, typename UO>
43 friend void setv_checkbefore(Vector<U,UO>& v, size_t i, const U& t);
48 Vector(Vector<val::Value>&& v) : c(std::move(v.c)) { }
52 std::unique_ptr<baseallocator>&& alloc_p =
nullptr) : c(v.c) { }
56 const val::Value& value=getInitValue<val::Value>(),
57 std::unique_ptr<baseallocator>&& alloc_p =
nullptr) : c(n, value) { }
60 Vector(
rsv_t,
size_t n, std::unique_ptr<baseallocator>&& alloc_p =
nullptr) {
67 std::unique_ptr<baseallocator>&& alloc_p =
nullptr) : c(b, e) { }
70 template <
class InputIterator>
72 const InputIterator& e,
73 std::unique_ptr<baseallocator>&& alloc_p =
nullptr) : c(b, e) { }
75 Vector(std::initializer_list<val::Value> l,
76 std::unique_ptr<baseallocator>&& alloc_p =
nullptr) : c(l) { }
79 Vector(std::unique_ptr<baseallocator>&& alloc_p) {
92 bool isOrdered() {
return false; }
94 void at(arr::idx_type i,
const val::Value& v) {
96 throw std::out_of_range(
"subscript out of bounds");
100 val::Value& operator[](
size_t i) {
101 if (i > size() - 1) {
102 throw std::out_of_range(
"subscript out of bounds");
106 const val::Value& operator[](
size_t i)
const {
107 if (i > size() - 1) {
108 throw std::out_of_range(
"subscript out of bounds");
113 void push_back(
const val::Value& value) {
117 template <
class InputIterator>
120 InputIterator last) {
121 auto diff = last - first;
125 auto oldbegin = begin();
127 resize(size() +
static_cast<size_t>(diff));
129 if (oldbegin != oldend && oldend - 1 - position > 0) {
130 for (
auto iter = end(); iter != position; --iter) {
131 *(iter) = *(iter - diff);
135 for (
auto iter = first; iter != last; ++iter) {
143 c.erase(c.begin() +
size_t(position));
149 c.erase(c.begin() +
size_t(first), c.begin() +
size_t(last));
153 explicit operator std::vector<val::Value>()
const {
157 const val::Value& front()
const {
159 throw std::range_error(
"front on empty Vector");
164 const val::Value& back()
const {
166 throw std::range_error(
"back on empty Vector");
168 return c[c.size()-1];
171 size_t size()
const {
return c.size(); }
172 void forceUnOrdered() { ; }
175 c.assign(count, value);
181 throw std::out_of_range(
"valuevector can't resize with 'from' > 0");
196 template <
typename AO=O>
197 Vector& sort() {
return *
this; }
199 template<
typename U,
typename AO=O>
202 void deallocate() { }
218 val::Value& at(
size_t i) {
return c[i]; }
219 vector<val::Value> c;
226 if (i >= v.size())
throw std::range_error(
"subscript out of bounds");
231 if (i >= v.size())
throw std::range_error(
"subscript out of bounds");
Vector(Vector< T, O > &&v)
move constructor.
Definition: vector_base.hpp:124
Vector(const vector_const_iterator< val::Value, O > &b, const vector_const_iterator< val::Value, O > &e, std::unique_ptr< baseallocator > &&alloc_p=nullptr)
vector_iterator constructor.
Definition: valuevector.hpp:65
Definition: vector_base.hpp:103
Definition: valuevector.hpp:32
Contains the types that constitute the output of an evaluation by the interpreter.
Definition: display.hpp:31
Definition: vector_base.hpp:56
Definition: vector_base.hpp:55
Vector(const InputIterator &b, const InputIterator &e, std::unique_ptr< baseallocator > &&alloc_p=nullptr)
std::vector iterator constructor.
Definition: valuevector.hpp:71
Vector(std::unique_ptr< baseallocator > &&alloc_p)
constructor from a mmapallocator.
Definition: valuevector.hpp:79
Definition: vector_base.hpp:59
Contains the classes and functions that implement a multidimentional array type.
Definition: allocator.hpp:29
Vector(size_t n=0, const val::Value &value=getInitValue< val::Value >(), std::unique_ptr< baseallocator > &&alloc_p=nullptr)
basic constructor with conditional initial value.
Definition: valuevector.hpp:55
Vector(rsv_t, size_t n, std::unique_ptr< baseallocator > &&alloc_p=nullptr)
basic constructor leaving the vector allocated but unininitialized.
Definition: valuevector.hpp:60