Recycle Queue Sample
public class RecycleQueue<T>
{
public int len;
T[] v;
int max;
int front;
int rear;
public RecycleQueue(int MAXSIZE)
{
max = MAXSIZE;
v = new T[max];
len = 0;
front = 0;
rear = 0;
}
public T this[int i]
{
get
{
return v[(rear - i + max) % max];
}
}
public void test()
{
for (int i = 0; i < max; i++)
{
Console.Write(v[i]+"\t");
}
Console.WriteLine();
}
public bool IsVaildRef(int refLen) {
if (refLen>-1 && refLen <len)
{
return true;
}
return false;
}
//入队操作
public void Push(T value)
{
if ( len ==0)
{
v[rear] = value;
len++;
}
else if (len < max)
{
rear++;
v[rear] = value;
len++;
}
else
{
v[front] = value;
rear = front;
//rear = (rear + 1) % max;
//溢出
front = (front + 1) % max;
}
}
//求队列长度
public int GetLength()
{
return len;
}
}
Recycle Queue Sample的更多相关文章
- Codeforces Round #303 (Div. 2) D. Queue 傻逼题
C. Woodcutters Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/545/probl ...
- POJ2828 Buy Tickets[树状数组第k小值 倒序]
Buy Tickets Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 19012 Accepted: 9442 Desc ...
- POJ 2828 Buy Tickets(线段树 树状数组/单点更新)
题目链接: 传送门 Buy Tickets Time Limit: 4000MS Memory Limit: 65536K Description Railway tickets were d ...
- 【poj2828】Buy Tickets
Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must get ...
- [poj2828] Buy Tickets (线段树)
线段树 Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must ...
- POJ 2828 线段树(想法)
Buy Tickets Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 15422 Accepted: 7684 Desc ...
- POJ 2828 Buy Tickets
Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must get ...
- Buy Tickets(线段树)
Buy Tickets Time Limit:4000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit ...
- 【poj2828】Buy Tickets 线段树 插队问题
[poj2828]Buy Tickets Description Railway tickets were difficult to buy around the Lunar New Year in ...
- 【POJ】2828 Buy Tickets(线段树+特殊的技巧/splay)
http://poj.org/problem?id=2828 一开始敲了个splay,直接模拟. tle了.. 常数太大.. 好吧,说是用线段树.. 而且思想很拽.. (貌似很久以前写过貌似的,,) ...
随机推荐
- 论文翻译:2020:ECAPA-TDNN: Emphasized Channel Attention, Propagation and Aggregation in TDNN Based Speaker Verification
论文地址:ECAPA-TDNN:在基于TDNN的说话人验证中强调通道注意.传播和聚集 论文代码:https://github.com/TaoRuijie/ECAPA-TDNN 引用格式:Desplan ...
- 图书管理员(NOIP 2017 PJT2)
0.题目 1.输入 输入 n,q: 输入图书,存入vector string a[20]数组,a[i][j],其中i表示图书编号的位数 2.查询操作 2.1 每输入一个读者需求 存入 int t; s ...
- activiti03 SSM使用activity
1.添加依赖 <!--activity依赖--> <dependency> <groupId>org.activiti</groupId> <ar ...
- STM32F0库函数初始化系列:进入STOP模式,外部中断唤醒
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource0); EXTI_InitStructure.EXTI_Line=EXTI_Line ...
- 树莓派VNC复制粘贴
1.安装sudo apt install autocutsel 2.运行autocutsel -f
- Stable Diffusion魔法入门
写在前面 本文为资料整合,没有原创内容,方便自己查找和学习, 花费了一晚上把sd安装好,又花了大半天了解sd周边的知识,终于体会到为啥这些生成式AI被称为魔法了,魔法使用前要吟唱类比到AI上不就是那些 ...
- 有趣的python库-turtle
turtle-绘制图像用 画樱花树 import turtle as tt import random # 画樱花的躯干(60,t) def tree(branch, t): if branch &g ...
- nodejs 接收参数,js前端传参方法
nodejs // 接口:查询检测结果 req.query接收 router.get('/getDetectionResult', (req, res) => { console.log(req ...
- Shapefile导入Oracle
1. 概述 Shapefile是常用的空间数据文件格式,Oracle数据库是常用的关系型数据库 Oracle数据库包含空间数据库,可以在Oracle中进行空间数据的存储,更详细的信息可参考: 空间数据 ...
- pycharm取消代码长度的竖线