Vector.hpp

A scaled-up version of std::vector with additional functionality.

This file is part of Empirical, https://github.com/devosoft/Empirical Copyright (C) 2025 Michigan State University MIT Software license; see doc/LICENSE.md

Note

Status: ALPHA

Defines

INCLUDE_EMP_DATASTRUCTS_VECTOR_HPP_GUARD
template<typename VALUE_T, size_t MAX_SIZE = 0>
class Vector
#include <Vector.hpp>

A class that can be either a static or dynamic vector, with extra functionality.

Template Parameters:
  • VALUE_T – Value type that the vector will be using.

  • MAX_SIZE – Maximum number of entries in vector (use 0 for unlimited)

Public Types

using value_type = VALUE_T
using size_type = std::size_t
using reference = value_type&
using const_reference = const value_type&

Public Functions

Vector() = default
Vector(const Vector&) = default
Vector(Vector&&) = default
inline Vector(size_t count, const VALUE_T &value = VALUE_T())
inline Vector(std::initializer_list<VALUE_T> init)
~Vector() = default
auto operator<=>(const this_t&) const = default
inline VALUE_T &operator[](size_t pos)
inline const VALUE_T &operator[](size_t pos) const
inline size_t size() const
inline auto begin() noexcept
inline auto begin() const noexcept
inline auto end() noexcept
inline auto end() const noexcept
inline this_t &Resize(size_t new_size)
inline this_t &Resize(size_t new_size, const VALUE_T &default_value)
inline void reserve(size_t size_cap)
inline VALUE_T &back()
inline const VALUE_T &back() const
inline VALUE_T &front()
inline const VALUE_T &front() const
template<typename T>
inline this_t &Fill(T &&value, size_t start, size_t count)
template<typename T>
inline this_t &Fill(T &&value, size_t start = 0)
template<typename T>
inline this_t &Push(T &&value, size_t count = 1)
inline VALUE_T Pop()
template<typename T>
inline void Insert(size_t pos, T &&value, size_t count = 1)
template<typename T>
inline void Erase(size_t pos, size_t count = 1)
inline this_t Copy(size_t start_pos, size_t count)
inline this_t Extract(size_t start_pos, size_t count)

Public Static Attributes

static constexpr bool IS_STATIC = static_cast<bool>(MAX_SIZE)

Private Types

using this_t = Vector<VALUE_T, MAX_SIZE>
using static_t = StaticVector<VALUE_T, MAX_SIZE>
using dynamic_t = vector<VALUE_T>
using vec_t = std::conditional_t<IS_STATIC, static_t, dynamic_t>

Private Members

vec_t values