树  0.1
数据结构_第6章
ch6_1.cc File Reference

测试:交换二叉树中所有结点的左右子树 More...

#include "binaryTree.hh"
#include <ctime>
#include <fstream>
#include <string>
Include dependency graph for ch6_1.cc:

Go to the source code of this file.

Functions

static bool GenTreeData (const char *_file_path="./test0.txt", const char *empty_flag="@")
 生成一个文件,内容是一棵二叉树的层次遍历 More...
 
template<typename T , typename Comparator >
static void print_test_result (const Tree::binaryTree< T, Comparator > &binary_tree, const typename Tree::binaryTree< T, Comparator >::value_type &flag, std::ostream &out=std::cout)
 (测试用)将二叉树类的多种方法的输出插到输出流 More...
 
int main (int argc, char const *argv[])
 
template<class T , typename Comparator >
void print_test_result (const Tree::binaryTree< T, Comparator > &binary_tree, const typename Tree::binaryTree< T, Comparator >::value_type &flag, std::ostream &out)
 (测试用)将二叉树类的多种方法的输出插到输出流 More...
 

Detailed Description

测试:交换二叉树中所有结点的左右子树

Author
Guorui Wei (31301.nosp@m.7602.nosp@m.@qq.c.nosp@m.om)
Version
0.1
Date
2020-04-27

See the file LICENSE in the top directory of this distribution for more information.

Definition in file ch6_1.cc.

Function Documentation

◆ GenTreeData()

bool GenTreeData ( const char *  _file_path = "./test0.txt",
const char *  empty_flag = "@" 
)
static

生成一个文件,内容是一棵二叉树的层次遍历

Parameters
_file_path文件路径
empty_flag空结点标记

首先询问是否删除同名文件(若有)。 \然后判断文件是否存在且可读,若是,则不做任何操作; \若否,则尝试新建文件。 \函数返回true,只保证文件file_path存在,不保证其可读。

Returns
true 文件已存在,或生成成功
false 文件生成失败

Definition at line 122 of file ch6_1.cc.

Referenced by main().

Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char const *  argv[] 
)

Definition at line 50 of file ch6_1.cc.

References Tree::binaryTree< T, Comparator >::createTree(), data_file_name(), GenTreeData(), and print_test_result().

Here is the call graph for this function:

◆ print_test_result() [1/2]

template<class T , typename Comparator >
void print_test_result ( const Tree::binaryTree< T, Comparator > &  binary_tree,
const typename Tree::binaryTree< T, Comparator >::value_type &  flag,
std::ostream &  out = std::cout 
)

(测试用)将二叉树类的多种方法的输出插到输出流

Template Parameters
T二叉树存储的数据的类型
Comparator函数对象,用于比较T类型的数据:lhs < rhs
Note
要求重载bool operator(const T &lhs, const T &rhs)
Parameters
binary_tree二叉树类的对象
flag类T的对象,表示空结点的特殊标记
out输出流对象,要求是ostream类及其派生类的对象,如std::cout,或ofstream类的对象

Definition at line 175 of file ch6_1.cc.

◆ print_test_result() [2/2]

template<typename T , typename Comparator >
static void print_test_result ( const Tree::binaryTree< T, Comparator > &  binary_tree,
const typename Tree::binaryTree< T, Comparator >::value_type &  flag,
std::ostream &  out = std::cout 
)
static

(测试用)将二叉树类的多种方法的输出插到输出流

Template Parameters
T二叉树存储的数据的类型
Comparator函数对象,用于比较T类型的数据:lhs < rhs
Note
要求重载bool operator(const T &lhs, const T &rhs)
Parameters
binary_tree二叉树类的对象
flag类T的对象,表示空结点的特殊标记
out输出流对象,要求是ostream类及其派生类的对象,如std::cout,或ofstream类的对象

Definition at line 175 of file ch6_1.cc.

Referenced by main().

Here is the caller graph for this function: