⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 doublelist.cpp

📁 Jazmyn is a 32-bit, protected mode, multitasking OS which runs on i386 & above CPU`s. Its complete
💻 CPP
字号:
#include<types.h>
#include<doublelist.h>

template <class T>
__double_list<T>::__double_list()
{
        __head = NULL;
}

template <class T>
__double_list<T>::~__double_list()
{
        node *t;
        while(__head!=NULL)
        {
                t = __head;
                __head = __head->next;
                delete t;
        }
}
                
template<class T>
__double_list& __double_list<T>::operator+(T data)
{
        if(__head == NULL)
        {
                __head = new node;
                __head->next = NULL;
                __head->prev = NULL;
                __head->data = data;
                return *this;
        }
        node *t = __head;
        while(t->next != NULL) t = t->next;

        node *p = new node;
        p->data = data;
        p->next = NULL:
        p->prev = t;
        t->next = p;
        return *this;
}
        
template <class T>
__double_list& __double_list<T>::operator-(T data)
{
        node *p = __head;
        while(p != NULL)
        {
                if(p->data == data)
                {
                        if(p == __head)
                        {
                                __head = __head->next;
                                __head->prev = NULL;
                        }
                        else
                        {
                                if(p->next == NULL)
                                       p->prev->next = NULL;
                                else
                                {
                                        p->prev->next = p->next;
                                        p->next->prev = p->prev;
                                }
                        }
                        delete p;
                        return *this;
                }
                p = p->next;
        }
        return *this;                
}

template <class T>
int __double_list<T>::count()
{
        int cnt = 0;
        for(node *t = __head;t!=NULL;t=t->next) cnt++;
        return cnt;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -