SLIDE  3.0.0
A simulator for lithium-ion battery pack degradation
Loading...
Searching...
No Matches
Interval.hpp
Go to the documentation of this file.
1/*
2 * Interval.hpp
3 *
4 * A small class for returning non-owning view of some storages.
5 * It stores a pointer and an interval.
6 *
7 * Created on: 05 Apr 2022
8 * Author(s): Jorn Reniers, Volkan Kumtepeli
9 */
10
11#pragma once
12
13#include <vector>
14
15namespace slide {
16
17template <typename Tcontainer>
19{
20 Tcontainer *root{ nullptr };
21 int beg{ 0 }, en{ 0 };
22
23public:
24 Interval() = default;
25
26 Interval(Tcontainer &data) : root(&data), en(data.size() - 1) {}
27
28 Interval(Tcontainer &data, int begin_, int end_) : root(&data), beg(begin_), en(end_) {}
29
30 [[nodiscard]] constexpr auto begin() noexcept { return std::begin(*root) + beg; }
31 [[nodiscard]] constexpr auto end() noexcept { return std::begin(*root) + en; }
32
33 [[nodiscard]] constexpr auto cbegin() const noexcept { return std::advance(std::cbegin(*root), beg); }
34 [[nodiscard]] constexpr auto cend() const noexcept { return std::advance(std::cbegin(*root), en); }
35};
36} // namespace slide
Definition: Interval.hpp:19
constexpr auto cend() const noexcept
Definition: Interval.hpp:34
constexpr auto begin() noexcept
Definition: Interval.hpp:30
Interval()=default
Interval(Tcontainer &data, int begin_, int end_)
Definition: Interval.hpp:28
Interval(Tcontainer &data)
Definition: Interval.hpp:26
constexpr auto end() noexcept
Definition: Interval.hpp:31
constexpr auto cbegin() const noexcept
Definition: Interval.hpp:33
Slide namespace contains all the types, classes, and functions for the simulation framework.
Definition: Cell.hpp:27