Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
TinySTL
提交
d1e80a87
T
TinySTL
项目概览
OpenDocCN
/
TinySTL
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TinySTL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d1e80a87
编写于
10月 27, 2014
作者:
邹
邹晓航
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加avl-tree
上级
5740c723
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
0 deletion
+44
-0
TinySTL/AVLTree.h
TinySTL/AVLTree.h
+40
-0
TinySTL/TinySTL.vcxproj
TinySTL/TinySTL.vcxproj
+1
-0
TinySTL/TinySTL.vcxproj.filters
TinySTL/TinySTL.vcxproj.filters
+3
-0
未找到文件。
TinySTL/AVLTree.h
0 → 100644
浏览文件 @
d1e80a87
#ifndef _AVL_TREE_H_
#define _AVL_TREE_H_
#include "Allocator.h"
namespace
TinySTL
{
//class of avl tree
template
<
class
T
>
class
avl_tree
{
public:
typename
T
value_type
;
private:
struct
node
{
T
data_
;
node
*
left_
,
*
right_
;
size_t
height_
;
explicit
node
(
T
d
=
T
(),
node
*
l
=
0
,
node
*
r
=
0
,
size_t
h
=
0
)
:
data_
(
d
),
left_
(
l
),
right_
(
r
),
height_
(
h
){}
};
typedef
TinySTL
::
allocator
<
T
>
dataAllocator
;
private:
node
*
root_
;
public:
avl_tree
()
:
root_
(
0
){}
avl_tree
(
const
avl_tree
&
)
=
delete
;
avl_tree
&
operator
=
(
const
avl_tree
&
)
=
delete
;
~
avl_tree
(){
destroyAndDeallocateAllNodes
(
root_
);
}
private:
void
destroyAndDeallocateAllNodes
(
node
*
p
){
if
(
p
!=
0
){
destroyAndDeallocateAllNodes
(
p
->
left_
);
destroyAndDeallocateAllNodes
(
p
->
right_
);
dataAllocator
::
destroy
(
p
);
dataAllocator
::
deallocate
(
p
);
}
}
};
}
#endif
\ No newline at end of file
TinySTL/TinySTL.vcxproj
浏览文件 @
d1e80a87
...
...
@@ -86,6 +86,7 @@
<ClInclude
Include=
"Algorithm.h"
/>
<ClInclude
Include=
"Alloc.h"
/>
<ClInclude
Include=
"Allocator.h"
/>
<ClInclude
Include=
"AVLTree.h"
/>
<ClInclude
Include=
"BinarySearchTree.h"
/>
<ClInclude
Include=
"Bitmap.h"
/>
<ClInclude
Include=
"CircularBuffer.h"
/>
...
...
TinySTL/TinySTL.vcxproj.filters
浏览文件 @
d1e80a87
...
...
@@ -83,5 +83,8 @@
<ClInclude
Include=
"BinarySearchTree.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
<ClInclude
Include=
"AVLTree.h"
>
<Filter>
头文件
</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录