18 #ifndef IOX_HOOFS_CXX_FORWARD_LIST_HPP
19 #define IOX_HOOFS_CXX_FORWARD_LIST_HPP
21 #include "iceoryx_hoofs/cxx/helplets.hpp"
26 #include "iceoryx_hoofs/platform/platform_correction.hpp"
56 template <
typename T, u
int64_t Capacity>
66 using iterator = IteratorBase<false>;
67 using const_iterator = IteratorBase<true>;
69 using size_type = decltype(Capacity);
122 const_iterator
begin() const noexcept;
136 const_iterator
end() const noexcept;
141 const_iterator
cend() const noexcept;
155 size_type
size() const noexcept;
200 iterator
erase_after(const_iterator beforeToBeErasedIter) noexcept;
206 size_type
remove(const T& data) noexcept;
212 template <typename UnaryPredicate>
218 template <typename... ConstructorArgs>
225 template <typename... ConstructorArgs>
226 iterator
emplace_after(const_iterator afterToBeEmplacedIter, ConstructorArgs&&... args) noexcept;
243 template <
bool IsConstIterator = true>
248 using iterator_category = std::forward_iterator_tag;
249 using value_type =
typename std::conditional<IsConstIterator, const T, T>::type;
250 using difference_type = void;
251 using pointer =
typename std::conditional<IsConstIterator, const T*, T*>::type;
252 using reference =
typename std::conditional<IsConstIterator, const T&, T&>::type;
257 IteratorBase(
const IteratorBase<false>& iter) noexcept;
263 IteratorBase&
operator=(
const IteratorBase<false>& rhs) noexcept;
268 IteratorBase& operator++() noexcept;
276 template <
bool IsConstIteratorOther>
277 bool operator==(
const IteratorBase<IsConstIteratorOther>& rhs)
const noexcept;
285 template <
bool IsConstIteratorOther>
286 bool operator!=(
const IteratorBase<IsConstIteratorOther>& rhs)
const noexcept;
290 reference operator*()
const noexcept;
294 pointer operator->()
const noexcept;
298 using parentListPointer =
typename std::
306 explicit IteratorBase(parentListPointer parent, size_type idx) noexcept;
310 friend class IteratorBase<true>;
312 parentListPointer m_list;
313 size_type m_iterListNodeIdx;
322 void init() noexcept;
323 T* getDataPtrFromIdx(const size_type idx) noexcept;
324 const T* getDataPtrFromIdx(const size_type idx) const noexcept;
326 bool isValidElementIdx(const size_type idx) const noexcept;
327 bool isInvalidIterator(const const_iterator& iter) const noexcept;
328 bool isInvalidIterOrDifferentLists(const const_iterator& iter) const noexcept;
329 bool isInvalidElement(const size_type idx) const noexcept;
330 void setInvalidElement(const size_type idx, const
bool value) noexcept;
331 size_type& getNextIdx(const size_type idx) noexcept;
332 const size_type& getNextIdx(const size_type idx) const noexcept;
333 size_type& getNextIdx(const const_iterator& iter) noexcept;
334 const size_type& getNextIdx(const const_iterator& iter) const noexcept;
335 void setNextIdx(const size_type idx, const size_type nextIdx) noexcept;
336 static
void errorMessage(const
char* source, const
char* msg) noexcept;
346 static constexpr size_type BEFORE_BEGIN_INDEX{Capacity};
347 static constexpr size_type END_INDEX{size_type(Capacity) + 1U};
348 static constexpr size_type NODE_LINK_COUNT{size_type(Capacity) + 2U};
352 size_type m_freeListHeadIdx{0U};
354 NodeLink m_links[NODE_LINK_COUNT];
355 using element_t = uint8_t[
sizeof(T)];
356 alignas(T) element_t m_data[Capacity];
358 size_type m_size{0U};
364 #include "iceoryx_hoofs/internal/cxx/forward_list.inl"
C++11 compatible uni-directional forward list implementation.
Definition: forward_list.hpp:58
void clear() noexcept
remove all elements from the list, list will be empty element destructors will be invoked
forward_list() noexcept
constructor for an empty list (of T-types elements)
const_iterator cbefore_begin() const noexcept
const_iterator an interator before first element only allowed for usage in erase_after,...
size_type max_size() const noexcept
list meta information, maximum number of elements the list can contain
bool full() const noexcept
list meta information on filling
size_type size() const noexcept
list meta information on filling
iterator end() noexcept
default list operation to retrieve an interator to end of list (behind last valid element) Terminated...
bool push_front(const T &data) noexcept
add element to the beginning of the list
forward_list & operator=(const forward_list &rhs) noexcept
copy assignment, each element is copied (added) to the constructed list any existing elements in 'thi...
iterator erase_after(const_iterator beforeToBeErasedIter) noexcept
remove next element from linked iterator position element destructors will be invoked recursive calls...
iterator insert_after(const_iterator citer, const T &data) noexcept
insert element after iterator position
const_iterator cend() const noexcept
default list operation to retrieve an const_iterator to end of list (behind last valid element) Termi...
iterator emplace_after(const_iterator afterToBeEmplacedIter, ConstructorArgs &&... args) noexcept
construct element inplace after the pointed-to element
iterator begin() noexcept
default list operation to retrieve an interator to first list element
const_iterator cbegin() const noexcept
default list operation to retrieve an const_iterator to first list element
T & emplace_front(ConstructorArgs &&... args) noexcept
construct element inplace at begining of list
size_type capacity() const noexcept
list meta information, maximum number of elements the list can contain
bool empty() const noexcept
list meta information on filling
size_type remove_if(UnaryPredicate pred) noexcept
remove all elements which matches the provided comparison function requires a the template type T to ...
size_type remove(const T &data) noexcept
remove all elements which matches the given comparing element (compare by value) requires a the templ...
T & front() noexcept
Returns a reference to the first element in the container. calling front() on an empty list will term...
bool pop_front() noexcept
remove the first element from the begining of the list element destructor will be invoked
iterator before_begin() noexcept
retrieve an interator before first element only allowed for usage in erase_after, insert_after,...
building block to easily create free function for logging in a library context
Definition: lockfree_queue.hpp:29