C++语言程序设计
文章平均质量分 64
uniquever
这个作者很懒,什么都没留下…
展开
-
C++程序设计语言课后习题10章12题
#include #include using namespace std;class Char_queue{private: char *_queue; unsigned head,tail; unsigned const capacity; static unsigned const default_capacity = 20;public:原创 2014-09-30 15:41:10 · 973 阅读 · 0 评论 -
b树的c++实现
#include #include #include using namespace std;class BTree{ static const int M = 2; struct BTNode{ int keyNum; int key[2 * M - 1]; //关键字数组 struct BTNode* child[2 * M];//孩子结点数组 bool i原创 2015-05-03 23:09:50 · 1126 阅读 · 2 评论 -
b树的实现
#include #include #include #include #include #define M 2using namespace std;struct BTNode{ int keyNum; int key[2*M-1]; //关键字数组 struct BTNode* child[2*M];//孩子结点数组 bool isLeaf;};void D原创 2015-05-03 21:31:20 · 634 阅读 · 0 评论 -
二叉平衡树的详细实现:插入与删除
AvlTree.h#include #include #include using namespace std;templateclass AvlTree;templateclass AvlNode{ friend class AvlTree ; T data; int height; AvlNode *left; AvlNode *right; Avl原创 2015-03-29 19:08:58 · 780 阅读 · 0 评论 -
STL源码剖析配置器中的union obj
最近看了《原创 2014-10-15 18:28:59 · 1280 阅读 · 0 评论 -
简单内存池实现
#include #include #include #include using namespace std;class MemPool{ struct FreeNode{ struct FreeNode* next; };private: static const int allocNum = 8; static const int step = 4; stati原创 2015-04-02 23:55:42 · 692 阅读 · 0 评论 -
kruskal算法
#include #include #include using namespace std;struct edge { int begin; int end; int cost;};bool cmp(edge a, edge b){ if (a.cost < b.cost) return true; return false;}int findSet(in原创 2014-12-07 22:58:45 · 590 阅读 · 0 评论 -
prim算法
#include using namespace std;int getMin(int *a, int n) { if (n <= 0) return 0; int min; for (int i = 0; i < n; i++) { if (a[i]) { min = i; break; } } for (int i = 0; i < n; i++) {原创 2014-12-07 19:38:20 · 579 阅读 · 0 评论 -
leveldb的内存池Arena
仿照源码练练手。原创 2014-10-14 23:09:32 · 707 阅读 · 0 评论 -
隐式转换问题
1.对“普通”T&的初始化必须是一个类型T的左值,原创 2014-10-01 13:01:03 · 693 阅读 · 0 评论 -
STL源码剖析:空间配置器
看完自己重写了一下,不知道的又看了一遍。Mempool.h#ifndef MEMPOOL_H_#define MEMPOOL_H_#include #include #include namespace flysnow {enum {STEP_ = 8};enum {MAX_BYTES_ = 128};enum {FREELIST_NUM_ = MAX原创 2014-10-16 21:12:35 · 897 阅读 · 0 评论 -
The C++ Programming Language 第15章课后习题第三题
1.Board.h2.Board.cpp3.BoardTextView.h4.BoardTextV原创 2014-10-04 23:37:10 · 867 阅读 · 0 评论 -
C++程序设计语言课后习题10章15题
#include class A{public : A(){ std::cout } ~A(){ std::cout }};A a;int main(){ std::cout}原创 2014-10-01 09:52:44 · 748 阅读 · 0 评论 -
不通过类的成员函数直接访问类的私有变量
1.指针操作#include using namespace std;class object{private: int a; int b;public: object(int _a,int _b):a(_a),b(_b){} int get_a(){return a;} int get_b(){return b;}};int main()原创 2014-09-29 22:39:17 · 817 阅读 · 0 评论 -
最简单的trie树
#include #include using namespace std;class TrieTree{ struct TrieNode{ bool isStr; TrieNode* child[26]; TrieNode():isStr(false){ for (int i = 0; i < 26; i++) child[i] = NULL; }原创 2015-05-04 22:50:42 · 518 阅读 · 0 评论