list_erase.hpp

Back to Doubly-linked list

pastel/sys/list/

#ifndef PASTELSYS_LIST_ERASE_HPP
#define PASTELSYS_LIST_ERASE_HPP

#include "pastel/sys/list.h"

namespace Pastel
{

    template <
        typename Settings,
        template <typename> class Customization>
    auto List<Settings, Customization>::erase(
        const ConstIterator& that)
        -> Iterator
    {
        ASSERT(that.isNormal());

        Node* node = (Node*)that.base();

        Node* next = node->next();
        ASSERT(next);

        Node* previous = node->prev();
        ASSERT(previous);

        linkNodes(previous, next);

        nodeDeallocate((Data_Node*)node);
        --size_;

        return Iterator(next);
    }

}

#endif