* Add ranges * Initial Hugo setup * Work in progress * Added selection for local or remote site * Updated to 'light' theme * Changed to using Hextra Hugo theme * Changed to using Hextra Hugo theme * Changed to Hextra Hugo theme * Change to Hextra Hugo theme * Updated Hugo setup. * Updated Hugo setup. # Conflicts: # docs/releases/_index.md * Work in progress * Added new fonts Added new documentation * Latest documentation updates * Latest documentation updates # Conflicts: # docs/containers/array.md # docs/containers/array_view.md # docs/containers/array_wrapper.md # docs/containers/bip_buffer_spsc_atomic.md # docs/containers/bitset.md # docs/containers/indirect_vector.md # docs/containers/vector.md # docs/getting-started/compilers.md * Added bloom_filter markdown doc * Added more documentation Updated CSS for light and dark modes * Fixed some menus Added mode documentation files * Updated CSS rules Added badges to home page Added uniqur_ptr + pool tutorial * Fixed formatting on the home page markdown Modified light amd dark code formatting * Updated unique_ptr-with-pool * Added container and shared message tutorials * Updates to documentation * Added const_multimap * Updated source-formatting.md * Added initial raw text files form Web site editor * Innore coverage build directory * Exported raw text documentation files from the web site editor * Hugo updates * Added Hugo intalation and markdown descriptions * More addition to the documentation * Added closure.md and updates to delegate.md * Added format.md * Added documentation for etl::delegate_observable, etl::function, Base64 codec * Added io_port documentation * Added basic_format_spec * Added documentation for string_stream and string utilities. * Added more documentation Updated the documentation CSS * Added documentation for clocks, day, duration * Added more documentation for chrono classes Updated callouts * More chrono documentation * Completed chrono documentation * Maths functions documentation * Completed maths documentation * Completed maths documentation * Completed maths documentation * Completed maths documentation * Added multiple documentation files * Added iterator.md * Added debug_count.md and versions.md * Added debug_count.md and versions.md * Added more documentation * More documentation * Added some design pattern documentation Modified some of the layout files Modified the About documentation * Converted more documentation pages Modified the site CSS * Added more documentation Moced some documentation files to new directories * Added more documentation Tweaks to CSS * Added callback_timer_deferred_locked documentation * Added callback_timer_locked documentation * More documentation updates * More documentation updates * More documentation updates * New documentation files. Harmonised file name format * New documentation files. * Multiple document updates * Multiple document updates * Final conversion of web pages * Updates before PR * Updates before PR * Updates before PR # Conflicts: # docs/blog/_index.md * Final pre PR updates * Updates to message framework documentation * Renamed directory * Fix spelling * Added author and date to blog files Moved documentation files merged from development * Fixed 'Description' typo * Fix typos # Conflicts: # docs/IO/io_port.md # docs/containers/sets/const-multiset.md # docs/containers/sets/const-set.md # docs/maths/correlation.md # docs/maths/gamma.md * Renamed two files to lower case * Minor renaming * Added author and date * Updated callout on bresenham_line.md Added support for showing the ETL version on the documentation first page, by copying the version.txt file as a hugo asset. Updated the Python 'update_release.py' to copy 'version.txt' * Replace space in filename with hyphen. Added more information to hugo-commands.md * Replace space in filename with hyphen. Added more information to hugo-commands.md # Conflicts: # docs/getting-started/view-the-docs-locally/hugo-commands.md * Added a link to pseudo_moving_average.md * Updated title pages for groups * Fixed missing 404 for non-existent pages * Fixed coordinate variable names in the 'Calculating the intersection' example --------- Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de> Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com> Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.co.uk>
12 KiB
| title | weight |
|---|---|
| forward_list | 3 |
{{< callout >}}
Header: forward_list.h
Similar to: std::forward_list
{{< /callout >}}
A fixed capacity forward list.
etl::forward_list<typename T, size_t SIZE>
etl::forward_list_ext<typename T>
Inherits from etl::iforward_list<T>.
etl::iforward_list may be used as a size independent pointer or reference type for any etl::forward_list instance.
Note: Does not support the member function swap.
Shared Pools
etl::forward_list_ext<typename T>
This template may share pools with another etl::forward_list of the same type.
The list is initialised with the pool either at construction time or a call to set_pool(etl::ipool& pool).
When pools are shared there are a few side effects that must be noted.
size() and empty() will be O(N) complexity. For a normal etl::forward_list they are O(1).
Destruction of the container will always be O(N) regardless of whether the type store is trivially destructible or not.
max_size() will return the potential maximum size of the list. The actual maximum size will dependent of how many elements the other lists sharing the pool have allocated.
Pool must be declared with the list's pool_type.
Example
// The element type
struct Point { int x; int y; };
// The list type
using List = etl::forward_list_ext<Point>;
// The shared pool
etl::pool<List::pool_type, 10> pool;
Template deduction guides
C++17 and above
template <typename T...>
etl::forward_list(T...)
Example
etl::forward_list data{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
Defines data as an forward_list of int, of length 10, containing the supplied data.
Make template
C++11 and above
template <typename T, typename... TValues>
constexpr auto make_forward_list(TValues&&... values)
Example
auto data = etl::make_forward_list<int>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
Member types
value_type T
size_type std::size_t
difference_type std::ptrdiff_t
reference value_type&
const_reference const value_type&
pointer value_type*
const_pointer const value_type*
iterator Bi-directional iterator
const_iterator Constant bi-directional iterator
Constructors
etl::forward_list<typename T, const size_t SIZE>()
etl::forward_list<typename T, const size_t SIZE>(size_t initialSize, parameter_t value = T())
template <typename TIterator>
etl::forward_list<typename T, const size_t SIZE>(TIterator begin, TIterator end)
Raises an etl::forward_list_iterator if the iterators are invalid. Raises an etl::forward_list_full if the list becomes full.
If asserts or exceptions are disabled then undefined behaviour occurs.
For shared pool lists
etl::forward_list<typename T, const size_t SIZE>(etl::pool& pool)
etl::forward_list<typename T, const size_t SIZE>(size_t initialSize, parameter_t value, etl::pool& pool)
template <typename TIterator>
etl::forward_list<typename T, const size_t SIZE>(TIterator begin, TIterator end, etl::pool& pool)
Raises an etl::forward_list_iterator if the iterators are invalid. If asserts or exceptions are disabled then undefined behaviour occurs.
Copy constructor
Implicit pool
Uses the pool from other.
etl::forward_list<typename T, const size_t SIZE>(etl::forward_list<typename T, const size_t SIZE>& other)
Explicit pool
etl::forward_list<typename T, const size_t SIZE>(etl::forward_list<typename T, const size_t SIZE>& other, etl::pool& pool)
Element access
T& front()
const T& front() const
Description
Returns a reference or const reference to the first element.
Undefined behaviour if the list is empty.
Iterators
iterator begin()
const_iterator begin() const
const_iterator cbegin() const
Description
Returns an iterator to the beginning of the forward list.
Returns end() if the list is empty.
iterator end()
const_iterator end() const
const_iterator cend() const
Description
Returns an iterator to the end of the forward list.
iterator before_begin()
const_iterator before_begin() const
const_iterator cbefore_begin() const
Description
Returns an iterator to before the beginning of the forward list.
Capacity
bool empty() const
Description
Returns true if the size of the forward list is zero, otherwise false.
bool full() const
Description
Returns true if the size of the forward list is SIZE, otherwise false.
size_t size() const
Description
Returns the size of the forward list.
size_t available() const
Description
Returns the remaining available capacity in the forward list.
size_t max_size() const
Description
Returns the maximum possible size of the forward list .
Modifiers
template <typename TIterator>
void assign(TIterator begin, TIterator end)
void assign(size_t n, parameter_t value)
Description
Fills the forward list with the values.
Raises an etl::forward_list_iterator if the iterators are invalid.
Raises an etl::forward_list_full if the list becomes full.
If asserts or exceptions are disabled then undefined behaviour occurs.
void push_front(parameter_t value)
Description
Pushes a value to the front of the forward list. If the forward list is full and ETL_CHECK_PUSH_POP is defined then raises an etl::forward_list_full error, otherwise undefined behaviour occurs.
emplace_front
Description
Constructs an item at the front of the the list 'in place'.
If the forward list is full and ETL_CHECK_PUSH_POP is defined then raises an etl::forward_list_full error, otherwise undefined behaviour occurs.
C++03
template <typename T1>
void emplace_front(const T1& value1)
template <typename T1, typename T2>
void emplace_front(const T1& value1, const T2& value2)
template <typename T1, typename T2, typename T3>
void emplace_front(const T1& value1, const T2& value2,
const T3& value3)
template <typename T1, typename T2, typename T3, typename T4>
void emplace_front(const T1& value1, const T2& value2,
const T3& value3, const T4& value4)
Before: 20.35.0
C++11 and above
template <typename ... Args>
void emplace_front(Args&& ... args)
Description
Constructs an item at the front of the the list 'in place'.
If the forward list is full and ETL_CHECK_PUSH_POP is defined then raises an etl::forward_list_full error, otherwise undefined behaviour occurs.
C++03
template <typename T1>
reference emplace_front(const T1& value1)
template <typename T1, typename T2>
reference emplace_front(const T1& value1, const T2& value2)
template <typename T1, typename T2, typename T3>
reference emplace_front(const T1& value1, const T2& value2,
const T3& value3)
template <typename T1, typename T2, typename T3, typename T4>
reference emplace_front(const T1& value1, const T2& value2,
const T3& value3, const T4& value4)
From 20.35.10
C++11 and above
template <typename ... Args>
reference emplace_front(Args&& …args)
void pop_front()
Description
Pop a value from the front of the forward list.
If the forward list is empty and ETL_CHECK_PUSH_POP is defined then raises an etl::forward_list_empty error, otherwise undefined behaviour occurs.
template <typename TIterator>
void insert_after(iterator position, TIterator begin, TIterator end)
Description
Inserts the range [begin, end) into the forward list after the specified position.
Before: 20.20.0
iterator insert_after(iterator position, parameter_t value)
void insert_after(iterator position, size_t n, parameter_t value)
Description
Inserts value in to the forward list after the specified position.
template <typename TIterator>
iterator insert_after(const_iterator position, TIterator begin, TIterator end)
Description
Inserts the range [begin, end) into the forward list after the specified position.
Since: 20.20.0
iterator insert_after(const_iterator position, parameter_t value)
Description
Inserts value in to the forward list after the specified position.
iterator insert_after(const_iterator position, size_t n, parameter_t value)
Inserts values in to the forward list after the specified position.
If the forward list is full then raises an etl::forward_list_full error.
If asserts or exceptions are disabled then undefined behaviour occurs.
iterator erase_after(iterator position)
Erases elements after the specified position.
Before: 20.20.0
iterator erase_after(iterator position, const_iterator end)
Description
Erases the range (position, end)
Before: 20.20.0
iterator erase_after(const_iterator position)
Description
Erases elements after the specified position.
Since: 20.20.0
iterator erase_after(const_iterator position, const_iterator end)
Description
Erases the range (position, end)
Since: 20.20.0
void resize(size_t n)
Description
Resizes the forward list.
If the new size is larger then the first assigns default constructed values.
If n is larger than the capacity then raises an etl::forward_list_full error, if asserts or exceptions are not enabled then undefined behaviour occurs.
void resize(size_t n, parameter_t value)
Description
Resizes the forward list.
If the new size is larger then the first assigns the supplied value.
If n is larger than the capacity then raises an etl::forward_list_full error, if asserts or exceptions are not enabled then undefined behaviour occurs.
void clear()
Description
Clears the forward list to a size of zero.
Operations
void remove(const T& value)
Description
Removes from the container all the elements that compare equal to value.
template <typename TPredicate>
void remove_if(TPredicate predicate)
Description
Removes from the container all the elements that satisfy predicate.
void unique()
Description
Removes all but the first element from every group of consecutive elements.
template <typename TPredicate>
void unique(TPredicate predicate)
Description
Removes all but the first element from every group of consecutive elements that satisfy the binary predicate.
void sort()
Description
Sorts using the < operator.
template <typename TCompare>
void sort(TCompare compare)
Description
Sorts using the supplied compare function.
void reverse()
Description
Reverses the order of the container.
Non-member functions
operator ==
Return
true if the contents of the lists are equal, otherwise false.
operator !=
Return
true if the contents of the lists are not equal, otherwise false.
operator <
Return
true if the contents of the lhs are lexicographically less than the contents of the rhs, otherwise false.
operator <=
Return
true if the contents of the lhs are lexicographically less than or equal to the contents of the rhs, otherwise false.
operator >
Return
true if the contents of the lhs are lexicographically greater than the contents of the rhs, otherwise false.
operator >=
Return
true if the contents of the lhs are lexicographically greater than or equal to the contents of the rhs, otherwise false.