Source

pyGAP / game / src / common / list.cpp

Full commit
#include "common/list.h"

namespace common {


ListNode::ListNode() {
    prev_ = this;
    next_ = this;
}


ListNode::~ListNode()
{
    unlink();
}


void ListNode::unlink() {
    if (!is_linked())
        return;

    prev_->next_ = next_;
    next_->prev_ = prev_;
    prev_ = next_ = this;
}


void ListNode::insert_after(ListNode* node) {
    unlink();

    prev_ = node;
    next_ = node->next_;

    prev_->next_ = this;
    next_->prev_ = this;
}


void ListNode::insert_before(ListNode* node) {
    unlink();

    next_ = node;
    prev_ = node->prev_;

    next_->prev_ = this;
    prev_->next_ = this;
}


} /* namespace common */