Shows how to use xtd::collections::generic::linked_list_node class.
#include <xtd/xtd>
using namespace text;
class example {
public:
static auto main() {
auto lln = linked_list_node<string> {"orange"};
console::write_line("After creating the node ....");
display_properties(lln);
auto ll = linked_list<string> {};
ll.add_last(lln);
console::write_line("After adding the node to the empty linked_list ....");
display_properties(lln);
ll.add_first("red");
ll.add_last("yellow");
lln = *ll.find("orange");
console::write_line("After adding red and yellow ....");
display_properties(lln);
}
private:
static auto display_properties(const linked_list_node<string>& lln) -> void {
if (lln.list().is_empty()) console::write_line(" Node is not linked.");
else console::write_line(" Node belongs to a linked list with {0} elements.", lln.list().get().count());
if (lln.previous() == nullopt) console::write_line(" Previous node is null.");
else console::write_line(" Value of previous node: {0}", lln.previous()->value());
console::write_line(" Value of current node: {0}", lln.value());
if (lln.next() == nullopt) console::write_line(" Next node is null.");
else console::write_line(" Value of next node: {0}", lln.next()->value());
console::write_line();
}
};
#define startup_(...)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:278