31#ifndef ETL_CYCLIC_VALUE_INCLUDED
32#define ETL_CYCLIC_VALUE_INCLUDED
39#include "static_assert.h"
41#include "static_assert.h"
52 template <
typename T, T FIRST = 0, T LAST = 0,
bool EtlRuntimeSpecialisation = ((FIRST == 0) && (LAST == 0))>
63 template <
typename T, T FIRST, T LAST>
115 else if (value_ < FIRST)
147 for (
int i = 0; i < n; ++i)
154 for (
int i = 0; i < -n; ++i)
174 operator const T()
const
184 if (value >= LAST) ETL_UNLIKELY
213 if (value <= FIRST) ETL_UNLIKELY
249 template <const T FIRST2, const T LAST2>
287 swap(value, other.value);
303 return lhs.value == rhs.value;
311 return !(lhs == rhs);
327 template <
typename T, T FIRST, T LAST>
365 : first_value(first_)
375 : value(other.value),
376 first_value(other.first_value),
377 last_value(other.last_value)
387 void set(T first_, T last_)
389 first_value = first_;
400 if (value_ > last_value)
404 else if (value_ < first_value)
406 value_ = first_value;
436 for (
int i = 0; i < n; ++i)
443 for (
int i = 0; i < -n; ++i)
463 operator const T()
const
473 if (value >= last_value)
502 if (value <= first_value)
541 first_value = other.first_value;
542 last_value = other.last_value;
577 swap(first_value, other.first_value);
578 swap(last_value, other.last_value);
579 swap(value, other.value);
595 return (lhs.value == rhs.value) &&
596 (lhs.first_value == rhs.first_value) &&
597 (lhs.last_value == rhs.last_value);
605 return !(lhs == rhs);
Provides a value that cycles between two limits.
Definition: cyclic_value.h:53
A templated set implementation that uses a fixed size buffer.
Definition: set.h:2502
T first() const
Gets the first value.
Definition: cyclic_value.h:557
void advance(int n)
Definition: cyclic_value.h:143
const T last() const
Gets the last value.
Definition: cyclic_value.h:275
cyclic_value(T first_, T last_)
Definition: cyclic_value.h:350
cyclic_value(T first_, T last_, T initial)
Definition: cyclic_value.h:364
T get() const
Gets the value.
Definition: cyclic_value.h:259
T last() const
Gets the last value.
Definition: cyclic_value.h:565
cyclic_value(T initial)
Definition: cyclic_value.h:82
void set(T value_)
Definition: cyclic_value.h:109
void to_first()
Resets the value to the first in the range.
Definition: cyclic_value.h:415
cyclic_value()
Definition: cyclic_value.h:72
T get() const
Gets the value.
Definition: cyclic_value.h:549
void to_last()
Resets the value to the last in the range.
Definition: cyclic_value.h:423
void swap(cyclic_value< T, FIRST, LAST > &other)
Swaps the values.
Definition: cyclic_value.h:573
cyclic_value(const cyclic_value &other)
Copy constructor.
Definition: cyclic_value.h:374
cyclic_value()
Definition: cyclic_value.h:337
void advance(int n)
Definition: cyclic_value.h:432
const T first() const
Gets the first value.
Definition: cyclic_value.h:267
friend void swap(cyclic_value< T, FIRST, LAST > &lhs, cyclic_value< T, FIRST, LAST > &rhs)
Swaps the values.
Definition: cyclic_value.h:293
cyclic_value(const cyclic_value< T, FIRST, LAST > &other)
Copy constructor.
Definition: cyclic_value.h:90
void set(T value_)
Definition: cyclic_value.h:398
void set(T first_, T last_)
Definition: cyclic_value.h:387
void swap(cyclic_value< T, FIRST, LAST > &other)
Swaps the values.
Definition: cyclic_value.h:283
void to_first()
Resets the value to the first in the range.
Definition: cyclic_value.h:126
void to_last()
Resets the value to the last in the range.
Definition: cyclic_value.h:134
bitset_ext
Definition: absolute.h:38
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:645
void swap(etl::array< T, SIZE > &lhs, etl::array< T, SIZE > &rhs)
Template deduction guides.
Definition: array.h:621
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:633