📄 dllist-driver.cc
字号:
#include "dllist.h"
#include <iostream>
#include "system.h"
//extern int testnum;
//extern Thread *currenThread;
extern int testnum;
void ListInsert(int N, DLList *List)
{
// extern int testnum;
// extern Thread *currentThread;
int sortkey;
for (int i = 0; i != N; ++i)
{
int *p = new int;
*p = i;
if (testnum == 2)
currentThread->Yield();
sortkey = random(50);
List->SortedInsert(p,sortkey);
std::cout << "the insert item and its Key are "<< *p << " and " << sortkey << std::endl;
}
}
void ListRemove(int N, DLList *List)
{
// if (!(List->IsEmpty()))
// extern Thread *currentThread;
// extern int testnum;
int i = 0;
while ((!(List->IsEmpty())) && (i != N))
{
int *key = new int;
void *item = NULL;
if (testnum == 4)
{
currentThread->Yield();
item = List->SortedRemove(0);
currentThread->Yield();
*key = 0;
}
item = List->Remove(key);
if (item == NULL) std::cout << "remove error" << std::endl;
else
std::cout << "the removed item and its key are " << *((int *)item) << " and " << *key << "\n" << std::flush;
delete key;
++i;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -