dllist.h

来自「nachos下并发程序设计。编写双向链表并演示并发错误。包含文件Makefile」· C头文件 代码 · 共 44 行

H
44
字号
#ifndef DLLIST_INCLUDED
#define DLLIST_INCLUDED

class DLLElement 
{
public:
	DLLElement(void *itermptr,int sortKey); // initiallize a list element
	DLLElement *next; //next element on list, NULL if this is the last
	DLLElement *prev;// previous element on list NULL if this is the first

	int key; //priority,for a sorted list
	void *item; //pointer to item on the list
};

class DLList
{
public:
	DLList();   //initialize the list
	~DLList(); // de-allocate the list

	void Prepend(void *item);  //add to the head of the list
	void Append(void *item);   //add to the tail of the list
	void *Remove(int *keyPtr); //remove from the list

	bool IsEmpty();           // return true if the list has no element

	void SortedInsert(void *item, int sortKey);  //put items on list in order
	void *SortedRemove(int sortKey); // remove first item with key==sortKey return NULL if no such item

private:
	DLLElement *first;    //head of the list , null if empty
	DLLElement *last;    //tail of the list ,null if empty

};

extern void ListInsert(int n,DLList *list,int t_num);  //insert n elements to the list 
extern void ListRemove(int n,DLList *list,int t_num);  //remove n elements to the list
extern int Thread_num,Node_num,Flag;  
//extern Thread* currentThread;
#endif



⌨️ 快捷键说明

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