STL--stack/queue的使用方法2010-01-05 17:36stack(栈)和queue(队列)也是在程序设计中经常会用到的数据容器,STL为我们提供了方便的stack(栈)的queue(队列)的实现。准确地说,STL中的stack和queue不同于vector、list等容器,而是对...
分类:
编程语言 时间:
2015-06-12 18:57:10
阅读次数:
227
前面分析了`ngx_array_t`数组,现在看一下`ngx_queue`队列的实现。 ## ngx_queue队列 `ngx_queue_t`是一个双向链表,实现了一个队列的操作逻辑。但是它的结构只进行指针的操作,因而在定义自己的节点时,需要自己...
分类:
其他好文 时间:
2015-05-31 12:34:06
阅读次数:
125
由于通过顺序表代码的复用实现队列的过程中,进队列要从队列的最后一个元素进入,所以造成时间复杂度加大,现通过引进front、rear优化队列实现方法
front:代表头元素的下标
rear:代表队尾下一个元素的下标
一、SeqQueue.h
#ifndef _SEQQUEUE_H_
#define _SEQQUEUE_H_
typedef void S...
分类:
其他好文 时间:
2015-05-29 18:13:01
阅读次数:
145
方法一、通过对顺序表代码的复用实现队列
一、SeqList.h
#ifndef _SEQLIST_H_
#define _SEQLIST_H_
typedef void SeqList;
typedef void SeqListNode;
SeqList* SeqList_Create(int capacity);
void SeqList_D...
分类:
其他好文 时间:
2015-05-29 15:51:40
阅读次数:
89
头文件:
#pragma once
#include
#include
using namespace std;
template
class CQueue
{
public:
CQueue(size_t sz = INIT_SZ);
~CQueue();
public:
bool full()const;
bool empty()const;
void show()c...
分类:
编程语言 时间:
2015-05-29 10:10:46
阅读次数:
208
头文件:
#pragma once
#include
#include
using namespace std;
template
class SeqQueue
{
public:
SeqQueue(size_t sz = INIT_SZ);
~SeqQueue();
public:
bool empty()const;
bool full()const;
void s...
分类:
编程语言 时间:
2015-05-28 21:30:30
阅读次数:
221
http://www.imooc.com/wenda/detail/252185一、队列使用场景:为什么需要队列在web开发中,我们经常会遇到需要处理批量任务的时候,这些批量任务可能是用户提交的,也可能是当系统被某个事件触发时需要进行批量处理的,面对这样的 ...
分类:
Web程序 时间:
2015-05-14 20:24:48
阅读次数:
152
顺序队列的实现,写出给大家分享一下,我不习惯写什么心得,直接贴代码出来供大家分享,共同进步。
1:头文件:Queue.h
#pragma once
#include
#include
#define ElemType int
#define SizeFull 20
typedef struct Queue
{
ElemType *data;
int sizefull;
int fro...
分类:
其他好文 时间:
2015-05-12 09:26:32
阅读次数:
92
循环队列的实现,本人语文表达能力有限,但写的代码简单易懂,这就不做更多的解释,直接看代码。
1:头文件:#include"DQueue.h"#pragma once
#include
#include
#define ElemType int
#define SizeFull 20
typedef struct Queue
{
ElemType *data;
int sizefull;
...
分类:
其他好文 时间:
2015-05-12 01:44:04
阅读次数:
158
贪心算法之赫夫曼编码
编码基本介绍
等长编码
变长编码
前缀码
赫夫曼编码的构造
贪心选择是安全的
最优子结构
编码实现
编码树节点TreeNode
优先队列的实现
赫夫曼编码的构建
maincc和Makefile
编译运行贪心算法之赫夫曼编码赫夫曼编码(Huffman coding)是一种编码方式,赫夫曼编码是变长编码的一种。可以有效的压缩数据,一般可以节约20%~90%的空间,这一般是由文件的数...
分类:
编程语言 时间:
2015-05-11 16:10:14
阅读次数:
779