linkedLoop
public class linkQueue <E>{ private class Node<E>{
E e;
Node<E> next; public Node(){}
public Node(E e,Node next){
this.e=e;
this.next=next;
} } private Node front;
private Node rear;
private int size; public linkQueue(){ front=rear=null; } //
public boolean empty(){ return size==0;
} //插入
public boolean add(E e){ if(empty()){ front=new Node(e,null);
rear=front; }
else{ Node<E> newnode=new Node<E>(e,null);
rear.next=newnode;
rear=newnode; }
size++;
return true; } //出队
public Node poll(){ if(empty()){
throw new RuntimeException("空队列异常");
}
else{
Node frontnode=front;
front=front.next;
frontnode.next=null;
size--;
return frontnode; }
} }
linkedLoop的更多相关文章
- Efounds笔试
Efounds的笔试~ 1.比较两个浮点数大小 一般不会直接用"=="或者"!="对两个浮点数进行比较. 判断两个浮点数float a 与 float b 是否 ...
随机推荐
- 预防SQL注入攻击
/** * 预防SQL注入攻击 * @param string $value * @return string */ function check_input($value) { // 去除斜杠 if ...
- 【LeetCode】【定制版排序】Sort Colors
之前转载过一篇STL的sort方法底层详解的博客:https://www.cnblogs.com/ygh1229/articles/9806398.html 但是我们在开发中会根据自己特定的应用,有新 ...
- P4755 Beautiful Pair
题目 洛谷 做法 \(i≤x≤j,a[i]<\frac{a[x]}{a[j]}\) 考虑\(a[x]\)的贡献,单调栈预处理\(L,R\)能作为最大值的区间 枚举一端点,仅需另一端点满足条件即可 ...
- cocos2dx打飞机项目笔记三:HeroLayer类和坐标系
HeroLayer类主要是处理hero的一些相关东西,以及调用bulletLayer的一些方法,因为子弹是附属于hero的~~ HeroLayer 类的成员如下: class HeroLayer : ...
- NSCoder
person.h头文件内容 #import <Foundation/Foundation.h> @interface Person : NSObject { NSString *name; ...
- tree 命令【转】
本文转载自:http://www.jb51.net/LINUXjishu/283874.html linux下怎么用tree命令以树形结构显示文件目录结构?tree命令可以以树形结构显示文件目录结构, ...
- JMeter学习(八)JDBC Request
[step_1]:“测试计划”--(右键)à添加à线程组: [step_2]:选择step_1中添加的线程组—(右键)à添加à配置元件àJDBC Connection Configuration,添加 ...
- 调整JVM堆内存解决OutOfMemoryError
今天在用 processing(http://zh.wikipedia.org/wiki/Processing) 编写处理 midi 文件的程序的时候,遇到了一个问题.程序主要是读取分析 midi , ...
- Linux嵌入式 -- 内核 - 进程控制 和 调度
1. 进程四要素 1. 有一段程序供其执行.这段程序不一定是某个进程所专有,可以与其他进程共用. 2. 有进程专用的内核空间堆栈. 3. 在内核中有一个task_struct数据结构,即通常所说的&q ...
- Java编程思想 Random(47)
Random类包含两个构造方法,下面依次进行介绍:1. public Random()该构造方法使用一个和当前系统时间对应的相对时间有关的数字作为种子数,然后使用这个种子数构造Random对象.2. ...