19:41:25 2019-08-19

继续学习

 

链表的游标实现

 

Cursor.h

 1 #ifndef _CURSOR_H
 2 #define _CURSOR_H
 3 #define Size 50     
 4 #define Null 0   //当Next为0 类似于空指针
 5 typedef int PtrToNode;
 6 typedef PtrToNode List;
 7 typedef PtrToNode Position;
 8 struct Node
 9 {
10     int Element;
11     Position Next;
12 };
13 extern struct Node CursorSpace[Size];
14 void InitializeCursorSpace();  //初始化空间
15 
16 List MakeEmpty(List L);     //建一个空的表头
17 int IsEmpty(const List L);    
18 int IsLast(const Position P, const List L);
19 Position Find(int Element, const List L);
20 void Delete(int Element, List L);
21 Position FindPrevious(int Element, const List L);
22 void Insert(int Element, List L, Position P);  //插入到P元素之前
23 void DeleteList(List L);                    //删除表
24 Position Header(List L);
25 Position First(List L);
26 int Retrive(const Position P);            //取回元素
27 Position CursorAlloc();
28 void FreeCursor(Position P);
29 #endif // !_CURSOR_H
View Code

相关文章: