Skip to content

Commit

Permalink
[Core] Add convenience access to front/back element of List
Browse files Browse the repository at this point in the history
  • Loading branch information
AThousandShips committed Oct 2, 2024
1 parent 1917bc3 commit 3783440
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions core/templates/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,26 @@ class List {
return _data ? _data->last : nullptr;
}

_FORCE_INLINE_ const T &get_front() const {
DEV_ASSERT(_data);
return _data->first->get();
}

_FORCE_INLINE_ T &get_front() {
DEV_ASSERT(_data);
return _data->first->get();
}

_FORCE_INLINE_ const T &get_back() const {
DEV_ASSERT(_data);
return _data->last->get();
}

_FORCE_INLINE_ T &get_back() {
DEV_ASSERT(_data);
return _data->last->get();
}

/**
* store a new element at the end of the list
*/
Expand Down

0 comments on commit 3783440

Please sign in to comment.