SLIDE  3.0.0
A simulator for lithium-ion battery pack degradation
Loading...
Searching...
No Matches
ArrayVec.hpp
Go to the documentation of this file.
1/*
2 * ArrayVec.hpp
3 *
4 * A small class to store variable size arrays
5 * Created on: 05 Apr 2022
6 * //!< not working yet.
7 * Author(s): Jorn Reniers, Volkan Kumtepeli
8 */
9
10#pragma once
11
12#include <vector>
13#include <array>
14#include <cstdlib>
15#include <algorithm>
16#include <span>
17
18namespace slide {
19template <typename Tdata>
21{
22 std::vector<std::span<Tdata>> data_span;
23
24public:
25 std::vector<Tdata> data;
26 ArrayVec() = default;
27
28 void push_back(std::span<const Tdata> spn)
29 {
30 const auto new_begin = data.end();
31 data.insert(new_begin, spn.begin(), spn.end());
32 data_span.emplace_back(new_begin, data.end());
33 }
34
35 void push_back(const Tdata &x)
36 {
37 const auto new_begin = data.end();
38 data.push_back(x);
39 data_span.emplace_back(new_begin, new_begin + 1);
40 }
41
42 [[nodiscard]] constexpr auto begin() noexcept { return data_span.begin(); }
43 [[nodiscard]] constexpr auto end() noexcept { return data_span.end(); }
44
45 [[nodiscard]] constexpr auto cbegin() noexcept { return data_span.cbegin(); }
46 [[nodiscard]] constexpr auto cend() noexcept { return data_span.cend(); }
47};
48} // namespace slide
Definition: ArrayVec.hpp:21
void push_back(std::span< const Tdata > spn)
Definition: ArrayVec.hpp:28
ArrayVec()=default
std::vector< Tdata > data
Definition: ArrayVec.hpp:25
constexpr auto begin() noexcept
Definition: ArrayVec.hpp:42
constexpr auto end() noexcept
Definition: ArrayVec.hpp:43
constexpr auto cend() noexcept
Definition: ArrayVec.hpp:46
void push_back(const Tdata &x)
Definition: ArrayVec.hpp:35
constexpr auto cbegin() noexcept
Definition: ArrayVec.hpp:45
Slide namespace contains all the types, classes, and functions for the simulation framework.
Definition: Cell.hpp:27