58 _list =
new item_t[num_items];
59 _list_len = num_items;
70 void put(
const T &new_value)
75 for (
int i = 0; i < _list_len; ++i) {
76 if (_list[i].timestamp_us == 0) {
77 _list[i].timestamp_us = now;
78 _list[i].value = new_value;
86 for (
int i = 1; i < _list_len; ++i) {
87 if (_list[i].timestamp_us < _list[oldest_i].timestamp_us) {
93 _list[oldest_i].timestamp_us = now;
94 _list[oldest_i].value = new_value;
116 for (
int i = _current_i; i < _list_len; ++i) {
117 if (_list[i].timestamp_us != 0) {
119 return &_list[i].value;
131 if (_current_i < _list_len) {
132 _list[_current_i].timestamp_us = 0;
141 if (_current_i < _list_len) {
156 item_t *_list =
nullptr;
High-resolution timer with callouts and timekeeping.
Definition: timestamped_list.h:53
void reset_to_start()
Before iterating using get_next(), reset to start.
Definition: timestamped_list.h:100
void drop_current()
Disable the last item that we have gotten.
Definition: timestamped_list.h:129
T * get_next()
Iterate through all active values (not sorted).
Definition: timestamped_list.h:111
void update_current()
Update the timestamp of the item we have gotten.
Definition: timestamped_list.h:139
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
Definition: drv_hrt.h:58
hrt_abstime hrt_absolute_time()
Get absolute time in [us] (does not wrap).
Definition: drv_hrt.cpp:155
void put(const T &new_value)
Insert a value into the list, overwrite the oldest entry if full.
Definition: timestamped_list.h:70