Lodestar
An integrated real-time control package in C++
|
|
5 #ifndef LODESTAR_ARRAYSTACK_HPP
6 #define LODESTAR_ARRAYSTACK_HPP
20 template<
typename TType,
size_t TSize>
27 using arrayType = std::array<TType, TSize>;
47 inline size_t size() const noexcept
57 inline constexpr
size_t max_size() const noexcept
86 throw std::out_of_range(
"ArrayStack index less than zero.");
88 throw std::out_of_range(
"ArrayStack index greater than size.");
106 throw std::out_of_range(
"ArrayStack index less than zero.");
108 throw std::out_of_range(
"ArrayStack index greater than size.");
118 inline void fill(
const TType &value)
144 inline void push(
const TType &value)
151 for (
int i = size_ - 1; i >= 0; i--)
152 array_[i + 1] = array_[i];
166 for (
int i = 0; i < size_ - 1; i++)
167 array_[i] = array_[i + 1];
194 throw std::out_of_range(
"ArrayStack has size 0.");
210 throw std::out_of_range(
"ArrayStack has size 0.");
226 throw std::out_of_range(
"ArrayStack has size 0.");
228 return array_[size_ - 1];
238 inline const TType &
back()
const
242 throw std::out_of_range(
"ArrayStack has size 0.");
244 return array_[size_ - 1];
252 inline typename arrayType::iterator
begin() noexcept
254 return array_.begin();
262 inline typename arrayType::const_iterator
begin() const noexcept
264 return array_.begin();
272 inline typename arrayType::iterator
end() noexcept
274 return array_.begin() + size_;
282 inline typename arrayType::const_iterator
end() const noexcept
284 return array_.begin() + size_;
287 const arrayType &array() const noexcept
299 #endif //LODESTAR_ARRAYSTACK_HPP
const TType & operator[](size_t idx) const
Returns a const reference to the element at idx.
Definition: ArrayStack.hpp:103
void pop_front()
Pops first element.
Definition: ArrayStack.hpp:163
void clear() noexcept
Clears the stack.
Definition: ArrayStack.hpp:68
TType & back()
Returns a reference to the rear value in the stack.
Definition: ArrayStack.hpp:222
arrayType::iterator end() noexcept
Returns an iterator the end of the stack.
Definition: ArrayStack.hpp:272
arrayType::iterator begin() noexcept
Returns an iterator the beginning of the stack.
Definition: ArrayStack.hpp:252
static type zero()
Construct a stack filled with the default values of TType.
Definition: ArrayStack.hpp:34
TType & operator[](size_t idx)
Returns a reference to the element at idx.
Definition: ArrayStack.hpp:83
const TType & back() const
Returns a const reference to the rear value in the stack.
Definition: ArrayStack.hpp:238
arrayType::const_iterator end() const noexcept
Returns a const iterator the end of the stack.
Definition: ArrayStack.hpp:282
TType & front()
Returns a reference to the front value in the stack.
Definition: ArrayStack.hpp:190
void fill(const TType &value)
Fills the stack to full capacity with value.
Definition: ArrayStack.hpp:118
Main Lodestar code.
Definition: BilinearTransformation.hpp:12
bool empty() const noexcept
Returns true if stack is empty.
Definition: ArrayStack.hpp:131
const TType & front() const
Returns a const reference to the front value in the stack.
Definition: ArrayStack.hpp:206
arrayType::const_iterator begin() const noexcept
Returns a const iterator the beginning of the stack.
Definition: ArrayStack.hpp:262
A statically sized stack with full member access.
Definition: ArrayStack.hpp:21
size_t size() const noexcept
Gives current stack size.
Definition: ArrayStack.hpp:47
void pop_back()
Pops last element.
Definition: ArrayStack.hpp:175
void push(const TType &value)
Pushes value to front of ArrayStack.
Definition: ArrayStack.hpp:144
constexpr size_t max_size() const noexcept
Gives maximum stack size.
Definition: ArrayStack.hpp:57