Ai
1 Star 0 Fork 0

郑玉强/dataStructure

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
simple_gen_list.h 1.44 KB
一键复制 编辑 原始数据 按行查看 历史
#pragma once
#include <iostream>
#include <cstdlib>
#include <queue>
#include <string>
using namespace std;
namespace simple_gen_list
{
struct SimpleGenListNode
{
static const int ATOM = 1;
static const int LIST = 2;
int type; // 类型
char data; // 数据项
SimpleGenListNode* head; // 表头指针(如果type是LIST_HEAD类型)
SimpleGenListNode* next; // 下一节点
SimpleGenListNode() :type(ATOM),data('\0'),next(NULL),head(NULL){}
explicit SimpleGenListNode(int type, char data = '\0') :type(type), next(NULL), head(NULL), data(data) {}
SimpleGenListNode(const SimpleGenListNode& node)
{
type = node.type;
data = node.data;
head = node.head;
next = node.next;
}
};
}
class SimpleGenList
{
private:
// 广义表结点
simple_gen_list::SimpleGenListNode* list_node_;
// 使用队列创建广义表(递归)
void createByQueueRecursive_(queue<char>& char_queue, simple_gen_list::SimpleGenListNode*& node);
// 子表构造字符队列(递归)
bool toCharQueueRecursive_(queue<char>& char_queue, simple_gen_list::SimpleGenListNode* node);
// 求子表深度(递归)
int subGenListDepthRecursive_(simple_gen_list::SimpleGenListNode* node);
// 求子表长度(递归)
int subGenListLengthRecursive_(simple_gen_list::SimpleGenListNode* node);
public:
SimpleGenList() :list_node_(NULL) {}
// 使用字符串创建广义表
void createByString(const string& gen_list_string);
// 生成字符串
string toString();
// 获取深度
int depth();
// 获取长度
int length();
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/zheng-yuqiang_lyg_cn/data-structure.git
git@gitee.com:zheng-yuqiang_lyg_cn/data-structure.git
zheng-yuqiang_lyg_cn
data-structure
dataStructure
dev01

搜索帮助