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的更多相关文章

  1. Codeforces Round #303 (Div. 2) D. Queue 傻逼题

    C. Woodcutters Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/545/probl ...

  2. POJ2828 Buy Tickets[树状数组第k小值 倒序]

    Buy Tickets Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 19012   Accepted: 9442 Desc ...

  3. POJ 2828 Buy Tickets(线段树 树状数组/单点更新)

    题目链接: 传送门 Buy Tickets Time Limit: 4000MS     Memory Limit: 65536K Description Railway tickets were d ...

  4. 【poj2828】Buy Tickets

    Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must get ...

  5. [poj2828] Buy Tickets (线段树)

    线段树 Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must ...

  6. POJ 2828 线段树(想法)

    Buy Tickets Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 15422   Accepted: 7684 Desc ...

  7. POJ 2828 Buy Tickets

    Description Railway tickets were difficult to buy around the Lunar New Year in China, so we must get ...

  8. Buy Tickets(线段树)

     Buy Tickets Time Limit:4000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit ...

  9. 【poj2828】Buy Tickets 线段树 插队问题

    [poj2828]Buy Tickets Description Railway tickets were difficult to buy around the Lunar New Year in ...

  10. 【POJ】2828 Buy Tickets(线段树+特殊的技巧/splay)

    http://poj.org/problem?id=2828 一开始敲了个splay,直接模拟. tle了.. 常数太大.. 好吧,说是用线段树.. 而且思想很拽.. (貌似很久以前写过貌似的,,) ...

随机推荐

  1. 3分钟教你安装 Dropzone4 文件拖拽增强工具 中文破解版 亲测有效

    Dropzone下载 下载直通车:立即下载 安装教程 打开我给你提供的Dropzone4 安装包 鼠标选中第一个程序拖到第二个程序里 在启动台打开 会出现下面情况 不要慌 点击好  去访达找到对应的软 ...

  2. XML02

    组成部分: 1. 文档声明 1. 格式: 2. 属性列表: * version:版本号,必须的属性 * encoding:编码方式.告知解析引擎当前文档使用的字符集,默认值:ISO-8859-1 * ...

  3. 有趣的python库-pyttsx3

    pyttsx3-语音播报功能 基本使用: import pyttsx3 px = pyttsx3.init() px.say("hello world") px.runAndWai ...

  4. GoAccess实现请求监

    GoAccess实现请求监控 简介 GoAccess是一款开源的实时web日志分析器和交互式查看器,用于可视化查看HTTP统计信息,可以系统的终端上运行,也可以通过浏览器运行: 本文通过使用GoAcc ...

  5. P5787 二分图 /【模板】线段树分治

    \(\text{Solution}\) 线段树分治的模板 对时间分治,线段树下标表示时间 在线段树上处理每条覆盖当前区间的边,对当前的时间区间求答案 小区间的信息可以由大区间一路下来得到,那么答案就是 ...

  6. 基于电商直播SDK快速实现一个淘宝直播APP【内附源码】

    现在各大互联网APP都标配电商直播带货了,没有直播带货开发经验都感觉自己跟不上技术的进步.今天快速基于Java实现一个安卓端电商直播APP,深入理解整个电商直播开发流程.我们最终实现效果如下: 按照惯 ...

  7. Java/.Net双平台核心,Jvm和CLR运行异同点

    前言: 本篇以.Net 7.0.2 CLR 和 OpenJDk19参照,解析下它们各自调用函数的异同. 以下为个人理解. 概述 JDK大约5.9G,CLR大约7.6G,两者相差1.7G左右. root ...

  8. LeetCode-380 O(1)时间插入、删除和获取随机元素

    来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/insert-delete-getrandom-o1 题目描述 实现RandomizedSet 类 ...

  9. python ( 进阶 第一部 )

    目录 列表的相关操作与函数 字符串的相关操作与函数 集合相关操作与函数 字典相关操作与函数 深浅拷贝 文件操作 列表的相关操作 列表的拼接 lst1 = [1,2,3] lst2 = [4,5,6,6 ...

  10. ROS librviz库

    1.可视化管理类:rviz::VisualizationManager The VisualizationManager class is the central manager class of r ...