1 #ifndef NTA_LINKEDNODE_H_INCLUDED
2 #define NTA_LINKEDNODE_H_INCLUDED
6 #include "nta/MyEngine.h"
18 using difference_type = std::ptrdiff_t;
21 using iterator_category = std::forward_iterator_tag;
27 reference operator*()
const {
30 pointer operator->()
const {
34 m_node = m_node->
next;
42 bool operator==(
const iterator& rhs)
const {
43 return m_node == rhs.m_node;
45 bool operator!=(
const iterator& rhs)
const {
46 return !operator==(rhs);
55 return iterator(
this);
58 return iterator(
nullptr);
61 std::size_t size()
const {
63 const LinkedNode* curr =
this;
64 while (curr && ++len) curr = curr->next;
68 static void remove(LinkedNode*& head, T d) {
69 LinkedNode** curr = &head;
70 while ((*curr) && (*curr)->data != d) {
71 curr = &(*curr)->next;
73 if (*curr) *curr = (*curr)->next;
75 static void remove(LinkedNode*& node) {
76 if (node) node = node->next;
81 while (*curr && !pred((*curr)->data)) {
82 curr = &(*curr)->
next;
85 *curr = (*curr)->
next;
99 #endif // NTA_LINKEDNODE_H_INCLUDED