Provides Node class and related utilities.
More...
#include <iostream>
#include <memory>
#include <vector>
Go to the source code of this file.
|
template<typename Node , typename Action > |
void | traverse (const Node *const inNode, const Action &action) |
|
template<typename Node > |
void | display_all (const Node *const inNode) |
|
template<typename Node > |
std::vector< typename Node::value_type > | push_all_to_vector (const Node *const inNode, const std::size_t expected_size=0) |
|
Provides Node class and related utilities.
Definition in file node.hpp.
◆ display_all()
void display_all |
( |
const Node *const | inNode | ) |
|
Definition at line 31 of file node.hpp.
31 {
32 traverse(inNode,
33 [](
const Node& curNode) { std::cout << curNode.data <<
" "; });
34}
◆ push_all_to_vector()
std::vector< typename Node::value_type > push_all_to_vector |
( |
const Node *const | inNode, |
|
|
const std::size_t | expected_size = 0 ) |
Definition at line 37 of file node.hpp.
38 {
39 std::vector<typename Node::value_type> res;
40 res.reserve(expected_size);
41 traverse(inNode,
42 [&res](
const Node& curNode) { res.push_back(curNode.data); });
43 return res;
44}
◆ traverse()
template<typename
Node , typename Action >
void traverse |
( |
const Node *const | inNode, |
|
|
const Action & | action ) |
Definition at line 23 of file node.hpp.
23 {
24 if (inNode) {
25 action(*inNode);
26 traverse(inNode->next.get(), action);
27 }
28}