dllist-driver.cc
来自「本次实验的目的在于将nachos中的锁机制和条件变量的实现补充完整」· CC 代码 · 共 101 行
CC
101 行
#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 + =
减小字号Ctrl + -
显示快捷键?