* 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>
8.7 KiB
| title |
|---|
| Intrusive Links |
{{< callout type="info">}}
Header: intrusive_links.h
{{< /callout >}}
A set of link structures designed to be used within containers such as etl::intrusive_list.
They are parameterised by an id that allows them to be multiply inherited from when creating objects that must exist in more than one intrusive container.
There are link and unlink functions supplied to manage connections between links. The functions will accept any permutation of pointer and reference parameters, though reference parameters offer the best performance.
For bidirectional links, unlinking a node will automatically adjust the links of the surrounding nodes at the same level.
Forward link
template <size_t ID_>
struct forward_link
Template parameters
const size_t ID_ A unique id for this link level.
Public constants
enum ID
Description
The unique id for this link level.
Public variables
forward_link<ID>* etl_next
Description
A pointer to the next forward link at this level.
Public functions
clear()
Description
Clears the pointers to nullptr.
Link functions
template <typename TLink>
struct is_forward_link
template <typename TLink>
inline constexpr bool is_forward_link_v;
Checks if TLink is an etl::forward_link.
From: C++17
template <typename TLink>
void link(TLink& lhs, TLink& rhs)
template <typename TLink>
void link(TLink* lhs, TLink* rhs)
template <typename TLink>
void link(TLink& lhs, TLink* rhs)
template <typename TLink>
void link(TLink* lhs, TLink& rhs)
Description
Make rhs the next element after lhs.
template <typename TLink>
void link_splice(TLink& lhs, TLink& rhs)
template <typename TLink>
void link_splice(TLink* lhs, TLink* rhs)
template <typename TLink>
void link_splice(TLink& lhs, TLink* rhs)
template <typename TLink>
void link_splice(TLink* lhs, TLink& rhs)
Description
Insert rhs as the element after lhs.
The original element after lhs will be linked after rhs.
template <typename TLink>
void link_splice(TLink& lhs, TLink& first, TLink& last)
template <typename TLink>
void link_splice(TLink* lhs, TLink& first, TLink& last)
Description
The elements in the range [first, last] will be inserted after lhs.
template <typename TLink>
TLink* unlink_after(TLink& node)
Description
Unlinks the element after node.
Return
A pointer to the removed node or nullptr.
template <typename TLink>
TLink* unlink_after(TLink& before, TLink& last)
Description
Unlinks the the range (before, last].
Return
A pointer to the first element in the removed range.
template <typename TLink>
bool is_linked(TLink& node)
template <typename TLink>
bool is_linked(TLink* node)
Return
true if node is linked to another.
template <typename TLink>
void link_clear(TLink& node)
template <typename TLink>
void link_clear(TLink* node)
Description
Clears the links for node.
template <typename TLink>
void link_clear_range(TLink& start)
template <typename TLink>
void link_clear_range(TLink* start)
Description
Clears the links for all nodes linked to start.
template <typename TLink, typename... TLinks>
TLink* create_linked_list(TLink& first, TLinks&... links)
Description
Create a linked list from a number of forward_link nodes.
template <typename TLink>
void detach_linked_list(TLink& first)
template <typename TLink>
void detach_linked_list(TLink* first)
Description
A synonym for link_clear_range.
Bidirectional link
template <const size_t ID_>
struct bidirectional_link
Template parameters
const size_t ID_
Description
The unique id for this link level.
Public constants
enum ID
Description
The unique id for this link level.
Public variables
bidirectional_link<ID>* etl_previous
Description
A pointer to the previous bidirectional link at this level.
bidirectional_link<ID>* etl_next
Description
A pointer to the next bidirectional link at this level.
Public functions
clear()
Description
Clears the link pointers to nullptr.
reverse()
Description
Reverses the order of the elements.
Link functions
void etl::link<type>(lhs, rhs)
Description
Link lhs to rhs.
void etl::link_splice<type>(lhs, rhs)
Insert rhs as the element after lhs.
The original element after lhs will be linked after rhs.
void etl::link_splice<type>(lhs, first, last)
Description
The elements in the range [first, last] will be inserted after lhs.
unlink
void etl::unlink(node)
Description
Unlink the specified node. Elements either side are linked to each other.
void etl::unlink(first, last)
Description
Unlinks the range [first, last].
The range [first, last] remain linked to each other.
template <typename T>
etl::is_bidirectional_link
Description
Tests if type T is an etl::bidirectional_link.
template <typename T>
etl::is_bidirectional_link_v
Description
Tests if type T is an etl::bidirectional_link.
From C++17
Tree link
template <const size_t ID_>
struct tree_link
Template parameters
const size_t ID_
Description
A unique id for this link level.
Public constants
enum ID
Description
The unique id for this link level.
Public variables
tree_link<ID>* etl_parent
Description
A pointer to the parent tree link at this level.
tree_link<ID>* etl_left
Description
A pointer to the left tree link at this level.
tree_link<ID>* etl_right
Description
A pointer to the right tree link at this level.
Public functions
clear()
Description
Clears the pointers to nullptr.
Link Functions
void etl::link_left<type>(parent, leaf)
Description
Links leaf to the left of parent.
void etl::link_right<type>(parent, leaf)
Description
Links leaf to the right of parent.
void etl::link_rotate_left<type>(parent, leaf)
Description
Rotates the link left making leaf the new parent.
void etl::link_rotate_right<type>(parent, leaf)
Description
Rotates the link right making leaf the new parent.
void etl::link_rotate<type>(parent, leaf)
Description
Rotates the link left or right making leaf the new parent.
Chooses left or right rotate depending on the leaf connection.
template <typename T>
etl::is_tree_link
Tests if type T is an etl::tree_link.
From: 20.37.0
template <typename T>
etl::is_tree_link_v
Tests if type T is an etl::tree_link.
From: 20.37.0
From: C++17
Example 1
A simple two level intrusive list.
// The link levels
typedef etl::bidirectional_link<0> level0_t;
typedef etl::bidirectional_link<1> level1_t;
constexpr bool is_bdl = etl::is_bidirectional_link_v<level0_t>;
// The item stored in the lists
struct item : public level0_t, public level1_t
{
item(int value)
:: value(value)
{
}
int value;
};
item data0(0);
item data1(1);
item data2(2);
item data3(3);
etl::intrusive_list<item, level0_t> level0_list;
etl::intrusive_list<item, level1_t> level1_list;
// Add items to level0 list
level0_list.push_back(data0);
level0_list.push_back(data1);
level0_list.push_back(data2);
// Add items to level1 list
level1_list.push_back(data3);
level1_list.push_back(data2);
level1_list.push_back(data1);
Example 2
Manual list manipulation.
typedef etl::bidirectional_link<0> level0_t;
typedef etl::bidirectional_link<1> level1_t;
// The item stored in the lists
struct item : public level0_t, public level1_t
{
item(int value)
:: value(value)
{
}
int value;
};
item data0(0);
item data1(1);
item data2(2);
item data3(3);
// Set the first and last nodes links to nullptr.
data0.level0_t::clear();
data3.level0_t::clear();
// Make the links.
etl::link<level0_t>(data0, data1);
etl::link<level0_t>(data1, data2);
etl::link<level0_t>(data2, data3); // Level 0 = data0, data1, data2, data3
// Set the first and last nodes links to nullptr.
data2.level1_t::clear();
data1.level1_t::clear();
// Make the links.
etl::link<level1_t>(data2, data3);
etl::link<level1_t>(data3, data0);
etl::link<level1_t>(data0, data1); // Level 1 = data2, data3, data0, data1
// Disconnect a node.
etl::unlink<level1_t>(data3); // Level 1 = data2, data0, data1
TLink*TLink*