#ifndef VEC_TEMPLATE_H_ #define VEC_TEMPLATE_H_ #include "integer/int_vector.hpp" #include "float/float_vector.hpp" #include "string/string_vector.hpp" #include #include #include template class Vector { std::vector container; public: constexpr Vector(); ~Vector(); constexpr T first(); constexpr T last(); constexpr T bracket(const int index); constexpr T bracket_equal(const int index, const T var); constexpr void emplace_back(const T var); constexpr int size(); constexpr void clear(); T sum(); constexpr Vector& push_back_object(const T var); constexpr Vector intersection(const Vector vec); constexpr Vector sort(); constexpr Vector& destructive_sort(); constexpr Vector reverse(); constexpr Vector& destructive_reverse(); }; template constexpr Vector::Vector() {} template Vector::~Vector() {} template constexpr T Vector::first() { return this->container.front(); } template constexpr T Vector::last() { return this->container.back(); } template constexpr T Vector::bracket(const int index) { return this->container[index]; } template constexpr T Vector::bracket_equal(const int index, const T var) { return this->container[index] = var; } template constexpr void Vector::emplace_back(const T var) { this->container.emplace_back(std::move(var)); } template constexpr int Vector::size() { return this->container.size(); } template constexpr void Vector::clear() { this->container.clear(); } template T Vector::sum() { T sum; for (auto&& c : this->container) sum += c; return sum; } template constexpr Vector& Vector::push_back_object(const T var) { this->container.emplace_back(std::move(var)); return *this; } template constexpr Vector Vector::intersection(const Vector vec) { std::vector result; std::set_intersection( this->container.begin(), this->container.end(), vec.container.begin(), vec.container.end(), std::inserter(result, result.end()) ); Vector object; object.container = std::move(result); return object; } template constexpr Vector Vector::sort() { Vector object; object.container = this->container; std::sort(object.container.begin(), object.container.end()); return object; } template constexpr Vector& Vector::destructive_sort() { std::sort(this->container.begin(), this->container.end()); return *this; } template constexpr Vector Vector::reverse() { Vector object; object.container = this->container; std::reverse(object.container.begin(), object.container.end()); return object; } template constexpr Vector& Vector::destructive_reverse() { std::reverse(this->container.begin(), this->container.end()); return *this; } #endif