#pragma once
#include
using
namespace std;
template
<
class
t>
class
singlecircularlinklist
;template
<
class
t>
class
node
friend ostream&
operator
<<
(ostream& os,node
* node)
friend
class
singlecircularlinklist
;private
: node
*next;
t data;};
template
<
class
t>
class
singlecircularlinklist
bool
isempty()
//清空鍊錶
void
clear()
delete p;
}//顯示鍊錶
void
show_list()
cout << p << endl;
}//根據位置查詢值
t find
(int index)
return p-
>data;
}//根據值查詢位置
intfind_data
(t data)
return index;
}//根據位置查詢節點
node
*find_node
(int index)
return p;
}//插入到指定位置
void
insert_index
(t data,
int index)
}else
if(index == size)
//末位置
else
//中間位置
++size;
}//彈出任意位置資料
t pop_index
(int index)
else
if(index == size-1)
//末位置
else
--size;
data = node-
>data;
delete node;
return data;
}void
push_back
(t data)
void
push_front
(t data)
t pop_back()
t pop_front()
private
: node
*first;
node
*last;
int size;
};
單向迴圈鍊錶
單向迴圈鍊錶.cpp 定義控制台應用程式的入口點。include stdafx.h include include clinklist.h using namespace std int tmain int argc,tchar argv int n 5 測試空鍊錶 clinklistclist a...
迴圈單向鍊錶
typedef struct list list 初始化乙個迴圈單向鍊錶 void list init list head 判斷鍊錶是否為空 int is list empty list head 往迴圈單向鍊錶中插入乙個元素 prev 在prev元素後面插入 void list insert li...
單向鍊錶迴圈
include include include include includetypedef struct looplink looplink,plooplink 設定結點物件,包含兩個成員,nvalue和指向下乙個物件的指標pnext plooplink create phead nvalue 9...