鍊錶的宣告及操作

2022-05-16 20:00:34 字數 887 閱讀 4523

view code

以上使用陣列做的

以下使用鍊錶

#include#include

typedef

struct node *ptrtonode

typedef ptrtonode list

typedef ptrtonode position

struct

node;

/*測試鍊錶是否為空

*/int

isempty(list l)

/*測試是否是鍊錶結尾的函式

*/int

islast(position p,list l)

/*find例程

*//*

find position of x,null if not found

*/position

find(elementtype x,list l)

/*findprevious assume header node

*/position

findprevious(list l,x)

/*鍊錶的刪除例程

*//*

delete first occurence of x

*//*

assume header node use

*/void

delete(list l,elementtype element)}/*

鍊錶的插入例程

*//*

insert x after p

*/void

insert(list l,elementtype x,position p)

view code

無論find還是findprevious都是返回的指向結點的指標

linux 鍊錶及相關鍊錶操作

1.鍊錶結構體 struct list head2.list entry define container of ptr,type,member container of ptr,type,member ptr為list head指標,type為包含list head結構體物件型別,member為鍊...

資料結構鍊錶 鍊錶的定義及基本操作

1,鍊錶的基本結構 typedef struct linklist linklist 2,鍊錶的初始化 linklist init list 3,新建鍊錶 void createlinklist linklist headnode,int data,int datanum headnode next...

靜態鍊錶的理解及基本操作

某些高階語言裡面並沒有指標,只有陣列,靜態鍊錶就是利用陣列來實現類似鍊錶的操作 1.要分配足夠大的記憶體,用來存放變數,記憶體大小記為maxsize 2.記憶體不僅要存放資料,而且要存放 指標 把它稱為游標,滿足這一條件的變數型別是結構體,其定義如下 typedef structcomponent,...