24class Vector : 
public std::vector<T> {
 
   27    using std::vector<T>::vector;
 
   38        return std::distance(std::cbegin(*
this),
 
   39            std::min_element(std::cbegin(*
this), std::cend(*
this)));
 
   51        return std::distance(std::cbegin(*
this),
 
   52            std::max_element(std::cbegin(*
this), std::cend(*
this)));
 
   62        std::sort(std::begin(*
this), std::end(*
this));
 
   73    [[nodiscard]] T 
min()
 const 
   75        return *std::min_element(std::cbegin(*
this), std::cend(*
this));
 
   86    [[nodiscard]] T 
max()
 const 
   88        return *std::max_element(std::cbegin(*
this), std::cend(*
this));
 
   99    [[nodiscard]] T 
sum()
 const 
  101        return std::accumulate(std::cbegin(*
this), std::cend(*
this), T{});
 
  112    [[nodiscard]] 
int index(
const T& element)
 const 
  114        auto it = std::find(std::cbegin(*
this), std::cend(*
this), element);
 
  115        return it != std::cend(*
this) ? std::distance(std::cbegin(*
this), it) : -1;
 
  128    [[nodiscard]] 
bool exist(
const T& element)
 const 
  130        return std::find(std::cbegin(*
this), std::cend(*
this), element) != std::cend(*
this);
 
  139        for (
const auto& elem : other) {
 
  140            if (std::find(this->begin(), this->end(), elem) != this->end()) {
 
  154        for (
const auto& elem : *
this) {
 
  155            if (std::find(other.begin(), other.end(), elem) == other.end()) {
 
  171        if (other_vector.empty()) {
 
  174        this->reserve(this->size() + other_vector.size());
 
  175        this->insert(this->end(), other_vector.begin(), other_vector.end());
 
  189        auto iter = std::find(this->begin(), this->end(), value);
 
  190        if (iter != this->end()) {
 
  206        std::stringstream ss = std::stringstream(
"");
 
  209        for (
const auto& elem : *
this) {
 
  221        std::stringstream ss = std::stringstream(
"");
 
  223        for (
const auto& elem : *
this) {
 
A vector.
Definition vector.h:24
 
bool removeValue(const T &value)
Removes the value described by value.
Definition vector.h:188
 
bool isSubsetOf(const Vector< T > &other) const
check if the other vector is a subset of the current vector
Definition vector.h:153
 
std::string toNotFormattedString() const
Definition vector.h:220
 
std::string toString() const
Convert this object into a string representation.
Definition vector.h:205
 
auto argmax() const
Argmax function returns the index of the largest element in the vector.
Definition vector.h:50
 
T sum() const
Sum function returns the sum of all elements in the vector.
Definition vector.h:99
 
T min() const
min function returns the smalled element in the vector
Definition vector.h:73
 
bool hasCommonElement(const Vector< T > &other) const
check if the other vector contains any value in the current vector
Definition vector.h:138
 
bool exist(const T &element) const
check if the element exists in the vector
Definition vector.h:128
 
T max() const
max function returns the largest element in the vector
Definition vector.h:86
 
void insertToEnd(const std::vector< T > &other_vector)
insert another vector to the end of this vector
Definition vector.h:170
 
auto argmin() const
Argmin function returns the index of the smallest element in the vector.
Definition vector.h:37
 
int index(const T &element) const
get the index of an element in the vector
Definition vector.h:112
 
void sort()
Sort function sorts the elements in the vector in ascending order.
Definition vector.h:61