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

📄 dllist-driver.cc

📁 本次实验的目的在于将nachos中的锁机制和条件变量的实现补充完整
💻 CC
字号:
#include "dllist.h"
#include <iostream.h>

int A[]={0,13,2,30};
int B[]={0,9,3,15};
void Insertlist(int n,DLList *list,int which)
{
    int value;
    DLLElement *item;
    for(int i=1;i<=n;i++)
    {       
        if(which == 0)
        {
            value = A[i];
        }
        else if(which == 1)
        {
            value = B[i];
        }
                
        item=new DLLElement(value);
        cout<<"线程"<<which<<"插入结点:"<<item->key<<endl;
        list->SortedInsert(item,value); 
        cout<<"线程"<<which<<"插入结点:"<<item->key<<"后输出链表:";
        list->showlist();
        cout<<endl;
    }        
}

void Insertlist_new(int n,DLList *list,int which)
{
    int value;
    DLLElement *item;
    for(int i=1;i<=n;i++)
    {       
        if(which == 0)
        {
            value = A[i];
        }
        else if(which == 1)
        {
            value = B[i];
        }
                
        item=new DLLElement(value);
        cout<<"线程"<<which<<"插入结点:"<<item->key<<endl;
        list->SortedInsert_new(item,value);
        cout<<"线程"<<which<<"插入结点:"<<item->key<<"后输出链表:";
        list->showlist();
        cout<<endl;
    }        
}

void Removelist(int n,DLList *list,int which)
{
    int del;
    DLLElement *item;
    for(int i=1;i<=n;i++)
    {
        if(which == 0)
        {
            del = A[i];
        }
        else if(which == 1)
        {
            del = B[i];
        }
        cout<<"线程"<<which<<"删除结点:"<<del;
        cout<<"   "<<"删除之前的链表";
        list->showlist(); 
        item = list->SortedRemove(del);
        cout<<"线程"<<which<<"删除结点:"<<del<<"后输出链表:";
        list->showlist();
        cout<<endl;
    }
}

void Removelist_new(int n,DLList *list,int which)
{
    int del;
    DLLElement *item;
    for(int i=1;i<=n;i++)
    {
        if(which == 0)
        {
            del = A[i];
        }
        else if(which == 1)
        {
            del = B[i];
        }
        cout<<"线程"<<which<<"删除结点:"<<del;
        cout<<"   "<<"删除之前的链表";
        list->showlist(); 
        item = list->SortedRemove_new(del);
        cout<<"线程"<<which<<"删除结点:"<<del<<"后输出链表:";
        list->showlist();
        cout<<endl;
    }
}

⌨️ 快捷键说明

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