Child *_tail;
};
+ // NOTE Client SHOULD implement this static method
+ static Head *head(Parent *);
+
class Node
{
public:
Child *prev(void) const { return _prev; }
Child *next(void) const { return _next; }
- protected:
- virtual Head *head(void) const = 0;
-
public:
void insertBefore(Node *next)
{
assert(next != nullptr);
- assert(next->head() != nullptr);
+ assert(next->parent() != nullptr);
+ assert(head(next->parent()) != nullptr);
assert(_prev == nullptr);
assert(_next == nullptr);
// Update parent-child relation
assert(parent() == nullptr);
- next->head()->enlist(curr());
+ head(next->parent())->enlist(curr());
assert(parent() == next->parent());
}
void insertAfter(Node *prev)
{
assert(prev != nullptr);
- assert(prev->head() != nullptr);
+ assert(prev->parent() != nullptr);
+ assert(head(prev->parent()) != nullptr);
assert(_prev == nullptr);
assert(_next == nullptr);
// Update parent-child relation
assert(parent() == nullptr);
- prev->head()->enlist(curr());
+ head(prev->parent())->enlist(curr());
assert(parent() == prev->parent());
};
{
// Update parent-child relation
assert(parent() != nullptr);
- assert(head() != nullptr);
- head()->delist(curr());
+ assert(head(parent()) != nullptr);
+ head(parent())->delist(curr());
assert(parent() == nullptr);
// Update the link of sibling nodes