自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(27)
  • 资源 (3)
  • 收藏
  • 关注

原创 简单的正则表达式引擎

1、基础理论非确定有限自动机(NFA),是计算理论中抽象出来的状态机计算模型。它拥有有限个状态,当前状态根据不同的输入可以迁移到其他的状态,它的下一个状态不是唯一确定的。正则表达式本身是有限长度的字符串,在这里可以看做NFA上输入状态组成的序列。于是,NFA可以用来作为一种识别装置识别正则表达式。Thompson构造法:将正则表达式转换为NFA。这里的NFA包括ε状态及其转换,即不需要

2014-11-18 13:27:24 2511

原创 leveldb源码分析:Cache

cache.h只提供了接口,内部实现全部在cache.cc中。cache.cc中:LRUHandle是双向链表的节点结构HandleTable是一个hash表,其冲突采用链表的方法解决。它的作用主要是管理LRUCache的节点。LRUCache是一个采用LRU算法实现的Cache。ShardedLRUCache是一个Cache的具体使用,其继承自Cache类,内部有LRUCac

2016-05-02 17:46:36 601

原创 最简单的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 522

原创 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 1131 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 635

原创 排序大汇总

1.归并排序void merge(int *result, int begin, int mid, int end, int *temp){ int k = begin; int i = begin; int j = mid + 1; while (i <= mid&&j <= end){ temp[k++] = result[i] < result[j] ? result[i+

2015-04-27 19:44:50 594

原创 简单内存池实现

#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 693

原创 1维KD-Tree查找指定范围内的元素

OneKdTree.h#include #include #include using namespace std;class AvlTree;class AvlNode{ friend class AvlTree; int data; int height; AvlNode *left; AvlNode *right; AvlNode(int _data) :da

2015-03-29 22:53:20 940

原创 二叉平衡树的详细实现:插入与删除

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 782

原创 CSS规则树和HTML的DOM树合成渲染树时渲染结点与选择器链的匹配

在浏览器内核(排版引擎)CSS规则树和HTML的DOM树合成渲染树的时候,会涉及到渲染树的位置属性的问题,因为其位置属性将通过CSS选择器链的优先级来决定,而渲染树的某个结点可能会同时满足多个选择器链,这时候就要通过选择器的优先级来完成属性的赋值。在这个地方,我仅仅处理了几个简单的选择器情况:{(.class)     (#id)       (element)      (#id,.clas

2014-12-12 21:41:52 1941 2

原创 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 598

原创 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 580

原创 简单的vector实现

学习c++中,看完书后,最近苦于不知道下一步该怎么办了,就翻翻STL源码剖析中的各种容器,想重新实现一遍。很多问题之前看的时候还不知道是怎么回事,当自己写的时候才发现许多应该注意与理解的。这个vector类写得特别简单,只实现了其中的一部分功能,因为没有使用iterator,发现一些函数不太好写,而且封装性极差,同时,只能存放内置类型。在这些问题中,希望自己以后会好好重写一下。这个程序有点小情

2014-11-01 16:40:32 1380

原创 二叉树的先序、中序、后序的递归与非递归实现

#include #include #include using namespace std;struct BinTree { int data; struct BinTree *left; struct BinTree *right;};struct BinPost { BinTree *pTree; bool isFirst;};

2014-10-30 20:20:23 614

原创 跳表的实现

最近看了一下跳表,看了文章http://www.cnblogs.com/xuqiang/archive/2011/05/22/2053516.html的实现,本想参照这个流程用c++类实现一下,结果却出现一些问题,在vc++6.0中正常运行,在codeblocks中时好时坏,调试还会出现gdb停止工作。虽然觉得应该是内存问题,可是找半天找不到,泪奔啊~~~~如果有大神找到错误,请一定告

2014-10-29 21:48:44 804 1

原创 插入排序

复习一下原来学习的排序算法。#include using namespace std;void print(int *a,int n) { for(int i=0;i<n; ++i) { cout<<a[i]<<' '; } cout<<endl;}void InsertSort(int *a,int n) { int i,

2014-10-18 14:23:52 765

原创 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 899

原创 STL源码剖析配置器中的union obj

最近看了《

2014-10-15 18:28:59 1284

原创 leveldb的内存池Arena

仿照源码练练手。

2014-10-14 23:09:32 707

原创 The C++ Programming Language 第15章课后习题第三题

1.Board.h2.Board.cpp3.BoardTextView.h4.BoardTextV

2014-10-04 23:37:10 872

原创 隐式转换问题

1.对“普通”T&的初始化必须是一个类型T的左值,

2014-10-01 13:01:03 698

原创 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 751

原创 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 976

原创 不通过类的成员函数直接访问类的私有变量

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 820

原创 STL list::sort算法

// list_sort.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include #include using namespace std;int main(){ list s; for(int k=15;k>=0;k--){ s.push_back(k

2014-09-10 13:25:10 539

原创 文本查询示例

最近看c++ primer,把15章最后的例子补充完整,贴出来。文本里的标点符号书中没有考虑,我改了改。#pragma warning(disable : 4786)#include #include #include #include #include #include #include #include using namespace std;class TextQuer

2014-08-14 23:10:07 492

原创 kd-tree c语言代码

/*This file is part of ``kdtree'', a library for working with kd-trees.Copyright (C) 2007-2009 John Tsiombikas Redistribution and use in source and binary forms, with or withoutmodification, are

2014-07-26 11:34:47 2697 6

kd-tree c语言代码

本文件里是关于ke_tree的C语言代码实现,里面附有非常全面的解释,对于刚接触kd_tree的人是非常值得看的。

2014-08-14

ICP算法源代码

关于ICP算法的源代码,结构清晰,非常适合初学者的研究。

2014-08-04

kd_tree实现代码

这里面是kd_tree的实现算法,看完对kd_tree将会有更深的了解

2014-08-04

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除