随笔分类 - C++代码实现
摘要:BFS 典型搜索树示意图 // 计算从起点 start 到终点 target 的最近距离 int BFS(Node start, Node target) { std::queue<Node> q; // 核心数据结构 std::set<Node> visited; // 避免走回头路 q.push
阅读全文
摘要:树结构 1.二叉搜索树 typedef int DataType; struct TreeNode { DataType data; std::shared_ptr<TreeNode> left_node; std::shared_ptr<TreeNode> right_node; TreeNode
阅读全文
摘要:单例模式 #pragma once template<typename T> class Singleton { public: Singleton() = default; ~Singleton() = default; Singleton(const Singleton&) = delete;
阅读全文