xingkongyun
星空隕的程序小站
C++博客
首頁
新隨筆
聯系
聚合
管理
隨筆 - 8 文章 - 26 trackbacks - 0
<
2025年7月
>
日
一
二
三
四
五
六
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
常用鏈接
我的隨筆
我的評論
我參與的隨筆
留言簿
(5)
給我留言
查看公開留言
查看私人留言
隨筆檔案
2009年12月 (1)
2009年9月 (1)
2009年4月 (1)
2008年12月 (1)
2008年11月 (1)
2008年10月 (2)
2008年9月 (1)
文章分類
C++語言(6)
Directx(1)
STL(2)
VC++
Windows編程(4)
操作系統(4)
數據結構(10)
文章檔案
2008年11月 (1)
2008年10月 (3)
2008年9月 (10)
2008年7月 (1)
2008年6月 (13)
相冊
圖示
C++語言
C++的羅浮宮
搜索
最新評論
1.?re: 卸載遠程線程中的DLL
水平很高,學習了。
--王小亮
2.?re: 卸載遠程線程中的DLL
評論內容較長,點擊標題查看
--疑問
3.?re: NASM 與 VC 混合編程的小結
收下了
--5545645
4.?re: VC++內聯匯編(MSDN相關內容完整翻譯)
謝謝
--5545645
5.?re: 安全密碼框的設計
評論內容較長,點擊標題查看
--徐胖子
閱讀排行榜
1.?VC++內聯匯編(MSDN相關內容完整翻譯)(9293)
2.?保護模式與實模式的切換(8050)
3.?安全密碼框的設計(4995)
4.?NASM 與 VC 混合編程的小結(3942)
5.?SYSENTER指令相關(大段的轉載-_-)(3652)
評論排行榜
1.?通過虛函數表訪問私有虛函數(10)
2.?安全密碼框的設計(8)
3.?保護模式與實模式的切換(4)
4.?VC++內聯匯編(MSDN相關內容完整翻譯)(1)
5.?NASM 與 VC 混合編程的小結(1)
鏈表類---轉載
#ifndef LIST_H
#define LIST_H
template
<
typename elemtype
>
class
list_item
{
public
:
list_item( elemtype, list_item
<
elemtype
>*
);
list_item(
const
list_item
<
elemtype
>&
);
const
elemtype date ()
const
;
const
list_item
<
elemtype
>*
next()
const
;
void
get_date (
const
elemtype );
void
get_next (
const
list_item
<
elemtype
>*
);
void
operator
=
(
const
list_item
<
elemtype
>&
);
private
:
elemtype _date;
list_item
<
elemtype
>
*
_next;
}
;
//
單鏈表數據項類
//
數據項類代碼實現
template
<
typename elemtype
>
list_item
<
elemtype
>
::list_item( elemtype ia
=
0
,
list_item
<
elemtype
>
*
p
=
0
)
{
get_date( ia );
if
( p
==
NULL )
get_next( NULL );
else
{
get_next( p
->
next() );
p
->
get_next(
this
);
}
}
template
<
typename elemtype
>
const
elemtype
list_item
<
elemtype
>
::date()
const
{
return
_date;
}
template
<
typename elemtype
>
const
list_item
<
elemtype
>*
list_item
<
elemtype
>
::
next()
const
{
return
_next;
}
template
<
typename elemtype
>
void
list_item
<
elemtype
>
::get_date(
const
elemtype de )
{
_date
=
de;
}
template
<
typename elemtype
>
void
list_item
<
elemtype
>
::
get_next(
const
list_item
<
elemtype
>
*
pev )
{
_next
=
( list_item
<
elemtype
>*
)pev;
}
template
<
typename elemtype
>
class
list
{
public
:
list();
list(
const
list
<
elemtype
>&
);
~
list();
const
int
size()
const
;
const
bool empty()
const
;
void
insert(
const
elemtype,
const
elemtype );
void
insert_front(
const
elemtype );
void
insert_end(
const
elemtype );
void
remove(
const
elemtype );
void
remove_all();
void
remove_front();
void
print()
const
;
const
list_item
<
elemtype
>*
find(
const
elemtype );
void
operator
=
(
const
list
<
elemtype
>&
);
private
:
//
void
down_size();
void
add_size();
//
list_item
<
elemtype
>
*
at_front;
list_item
<
elemtype
>
*
at_end;
list_item
<
elemtype
>
*
at_move;
int
_size;
}
;
//
鏈表類定義
//
函數實現代碼
//
私有函數集合
template
<
typename elemtype
>
void
list
<
elemtype
>
::add_size()
{
++
_size;
}
template
<
typename elemtype
>
void
list
<
elemtype
>
::down_size()
{
--
_size;
}
//
公有函數集合
template
<
typename elemtype
>
list
<
elemtype
>
::list()
{
at_front
=
NULL;
at_end
=
NULL;
_size
=
0
;
}
template
<
typename elemtype
>
list
<
elemtype
>
::
~
list()
{
remove_all();
}
template
<
typename elemtype
>
const
bool list
<
elemtype
>
::empty()
const
{
return
size()
==
0
?
false
:
true
;
}
template
<
typename elemtype
>
const
int
list
<
elemtype
>
::size()
const
{
return
_size;
}
template
<
typename elemtype
>
void
list
<
elemtype
>
::insert_front(
const
elemtype iva )
{
list_item
<
elemtype
>
*
pv
=
new
list_item
<
elemtype
>
( iva,
0
);
if
(
!
at_front )
{
at_front
=
at_end
=
pv;
}
else
{
pv
->
get_next( at_front );
at_front
=
pv;
}
add_size();
}
template
<
typename elemtype
>
void
list
<
elemtype
>
::insert_end(
const
elemtype iva )
{
if
( at_end
==
NULL)
{
at_end
=
at_front
=
new
list_item
<
elemtype
>
( iva,
0
);
}
else
at_end
=
new
list_item
<
elemtype
>
( iva, at_end );
add_size();
}
template
<
typename elemtype
>
void
list
<
elemtype
>
::
insert(
const
elemtype ixa,
const
elemtype iva )
{
list_item
<
elemtype
>
*
pev
=
( list_item
<
elemtype
>*
)find( iva );
if
( pev
==
NULL )
{
cerr
<<
"
err!
"
<<
endl;
return
;
}
if
( pev
==
at_front )
insert_front( ixa );
else
{
new
list_item
<
elemtype
>
( ixa, pev );
add_size();
}
}
template
<
typename elemtype
>
const
list_item
<
elemtype
>*
list
<
elemtype
>
::
find(
const
elemtype iva )
{
list_item
<
elemtype
>
*
at_move
=
at_front;
while
( at_move
!=
NULL )
{
if
( at_move
->
date()
==
iva )
return
at_move;
at_move
=
( list_item
<
elemtype
>*
)at_move
->
next();
}
return
NULL;
}
template
<
typename elemtype
>
void
list
<
elemtype
>
::remove_front()
{
if
( at_front )
{
list_item
<
elemtype
>
*
pev
=
at_front;
at_front
=
( list_item
<
elemtype
>*
)at_front
->
next();
delete pev;
down_size();
}
}
template
<
typename elemtype
>
void
list
<
elemtype
>
::remove( elemtype iva )
{
list_item
<
elemtype
>
*
pev
=
at_front;
while
( pev
&&
pev
->
date()
==
iva )
{
pev
=
( list_item
<
elemtype
>*
)pev
->
next();
remove_front();
}
if
(
!
pev )
return
;
list_item
<
elemtype
>
*
prv
=
pev;
pev
=
( list_item
<
elemtype
>*
)pev
->
next();
while
( pev )
{
if
( pev
->
date()
==
iva )
{
prv
->
get_next( pev
->
next() );
down_size();
delete pev;
pev
=
( list_item
<
elemtype
>*
)prv
->
next();
if
( pev
!=
NULL )
{
at_end
=
prv;
return
;
}
}
else
{
prv
=
pev;
pev
=
( list_item
<
elemtype
>*
)pev
->
next();
}
}
}
template
<
typename elemtype
>
void
list
<
elemtype
>
::remove_all()
{
while
( at_front )
remove_front();
_size
=
0
;
at_front
=
at_end
=
NULL;
}
template
<
typename elemtype
>
void
list
<
elemtype
>
::print()
const
{
list_item
<
elemtype
>
*
pev
=
at_front;
cout
<<
'
[
'
<<
size()
<<
'
]
'
;
cout
<<
'
{
'
;
for
(
int
ix
=
0
; pev
&&
ix
<
size();
++
ix )
{
cout
<<
pev
->
date()
<<
'
'
;
pev
=
( list_item
<
elemtype
>*
)pev
->
next();
}
cout
<<
'
}
'
<<
endl;
}
#endif
轉載自:
http://www.shnenglu.com/mzty/archive/2005/10/28/870.html
posted on 2008-06-18 22:05
楊彬彬
閱讀(359)
評論(0)
編輯
收藏
引用
所屬分類:
數據結構
只有注冊用戶
登錄
后才能發表評論。
【推薦】100%開源!大型工業跨平臺軟件C++源碼提供,建模,組態!
相關文章:
循環隊列實現
數據結構棧簡單實現(基于鏈表)
棧結構簡單實現(基于數組)
單向帶頭結點循環鏈表實現
關于紅黑樹(r-b樹)的相關資料
二叉搜索樹實現
二叉樹實現
最大高度優先左高樹(HBLT)實現
最大堆實現
鏈表類---轉載
網站導航:
博客園
IT新聞
BlogJava
博問
Chat2DB
管理
Copyright ©2025 楊彬彬 Powered by:
博客園
模板提供:
滬江博客
久久久久久久久久久精品尤物
|
91久久香蕉国产熟女线看
|
丰满少妇人妻久久久久久4
|
伊人丁香狠狠色综合久久
|
日本道色综合久久影院
|
热久久视久久精品18
|
婷婷伊人久久大香线蕉AV
|
97久久精品人妻人人搡人人玩
|
国产福利电影一区二区三区久久老子无码午夜伦不
|
2020最新久久久视精品爱
|
久久精品视频91
|
久久99国产乱子伦精品免费
|
久久久受www免费人成
|
日本精品久久久久中文字幕8
|
亚洲国产精品成人久久蜜臀
|
久久九九久精品国产
|
久久亚洲中文字幕精品有坂深雪
|
国内精品久久久久久99蜜桃
|
国产成人久久777777
|
久久久免费精品re6
|
97精品国产97久久久久久免费
|
93精91精品国产综合久久香蕉
|
久久人人爽人人爽人人片AV不
|
国产呻吟久久久久久久92
|
人妻无码久久一区二区三区免费
|
久久强奷乱码老熟女网站
|
国产精品岛国久久久久
|
久久偷看各类wc女厕嘘嘘
|
伊人久久大香线蕉综合Av
|
久久国产欧美日韩精品免费
|
久久91精品国产91久久小草
|
国产99久久精品一区二区
|
久久强奷乱码老熟女网站
|
亚洲国产成人久久综合一区77
|
91久久精品国产91性色也
|
热99re久久国超精品首页
|
国产一区二区三精品久久久无广告
|
久久99久久成人免费播放
|
老司机国内精品久久久久
|
久久亚洲国产精品一区二区
|
久久精品人人做人人爽电影蜜月
|