首先定义队列的基本结构,队列和栈不同之处在于队列需要两个指针,一个指向头,一个指向尾
String[] queue;
int front = 0;
int rear = 0;
构造方法
public QueueOfStrings(int capacity) {
queue = new String[capacity];
}
进队列
public void enqueu...
分类:
编程语言 时间:
2014-11-06 02:05:20
阅读次数:
260
DescriptionRailway tickets were difficult to buy around the Lunar New Year in China, so we must get up early and join a long queue…The Lunar New Year ...
分类:
其他好文 时间:
2014-11-05 17:03:26
阅读次数:
150
n*m矩阵,起点@,从矩阵中拿k个物品的最小代价
水BFS
#include "stdio.h"
#include "string.h"
#include "queue"
using namespace std;
int b[]={1,2,4,8,16};
int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
struct node
{
i...
分类:
其他好文 时间:
2014-11-05 10:53:34
阅读次数:
165
本文有关栈的介绍部分参考自网站数据结构。 1. 队列 1.1 队列的定义 队列(Queue)是只允许在一端进行插入,而在另一端进行删除的运算受限的线性表。 (1)允许删除的一端称为队头(Front)。 (2)允许插入的一端称为队尾(Rear)。 (3)当队列中没有元素时称为空队列...
分类:
编程语言 时间:
2014-11-04 22:23:26
阅读次数:
374
BOOST_FOREACH可以方便的遍历STL容器.
只需要头文件:
#include
然后遍历容器vector/list/set/deque/stack/queue都是类似的:
vectorint32_t> _v;
BOOST_FOREACH(int32_t value,_v)
{
//这里就可以访问value
}
同时元素还支持引用,const,比如...
分类:
其他好文 时间:
2014-11-04 11:03:46
阅读次数:
154
CPU LOAD通俗点讲,即当前系统正在执行及等待执行的任务数量。 维基百科上面对LOAD的详细解释:Each process using or waiting for CPU (the ready queue or run queue) increments the load number by ...
分类:
系统相关 时间:
2014-11-03 23:54:38
阅读次数:
381
一个客户端连接网络模块工作(一个连接的过程)监听线程收到一个连接后像轮询线程的连接队列中push一个conn_queue_item,然后向soketpair中写入一个字节此时子线程就是自动调用设置的事件,然后从连接队列中pop一个socket然后创建一个机遇socket的bufferevent在cr...
分类:
其他好文 时间:
2014-11-03 22:18:45
阅读次数:
131
jQuery中的queue和dequeue是一组很有用的方法,他们对于一系列需要按次序运行的函数特别有用。特别animate动画,ajax,以及timeout等需要一定时间的函数。queue() 方法显示或操作在匹配元素上执行的函数队列。queue和dequeue的过程主要是:用queue把函数加入...
分类:
Web程序 时间:
2014-11-03 22:16:19
阅读次数:
198
For a binary tree, preorder traversal may be enough.
For example,
_30_
/ \
10 20
/ / 50 45 35
The result is
30 10 50 # # # 20 45 # # 35 # #
Using a queue ...
分类:
其他好文 时间:
2014-11-03 16:28:42
阅读次数:
242
判断CPU瓶颈1, %processor time 平均值大于952, processor queue length大于2 (大于处理器个数+1).可以确定CPU瓶颈3, CPU空闲时间为零(zero percent idle CPU)4, 过高的用户占用CPU时间(%User Time)5, 过高...
分类:
其他好文 时间:
2014-11-03 14:35:02
阅读次数:
169