public class ArrayQueue implements Queue
{
// data members
int front; // one counterclockwise from first element
int rear; // position of rear element of queue
Object [] queue; // element array
{
// data members
int front; // one counterclockwise from first element
int rear; // position of rear element of queue
Object [] queue; // element array
public ArrayQueue(int initialCapacity)
{
if (initialCapacity < 1)
throw new IllegalArgumentException
("initialCapacity must be >= 1");
queue = new Object [initialCapacity + 1];
// default front = rear = 0
}
public boolean isEmpty() {
return front == rear;
}
public Object getFrontElement() {
if (isEmpty()) return null;
else return queue[(front + 1) % queue.length];
}
public Object getRearElement() {
if (isEmpty()) return null;
else return queue[rear];
}
public void put(Object theElement) {
// increase array length if necessary
if ((rear + 1) % queue.length == front) {
// double array size
// code to double array size comes here
}
if ((rear + 1) % queue.length == front) {
// double array size
// code to double array size comes here
}
// put theElement at the rear of the queue
rear = (rear + 1) % queue.length;
queue[rear] = theElement;
}
rear = (rear + 1) % queue.length;
queue[rear] = theElement;
}
public Object remove() {
if (isEmpty())
return null;
front = (front + 1) % queue.length;
Object frontElement = queue[front];
queue[front] = null; // enable garbage collection
return frontElement;
}
오라클자바커뮤니티교육센터, 개발자전문교육, 개인80%환급
www.oraclejavacommunity.com평일주간(9:30~18:10) 개강
(6/30)[기업100%환급]PL/SQL,ORACLE HINT,TUNING[개강확정]
(6/30)[기업100%환급]안드로이드개발자과정[개강확정]
(6/30)[기업100%환급]SQL기초에서 Schema Object까지[개강확정]
(7/07)[기업100%환급]C#4.0,WinForm,ADO.NET프로그래밍
(7/07)[기업100%환급]Spring ,MyBatis,Hibernate실무과정[개강확정]
(7/07)[기업100%환급]자바기초에서 JDBC, Servlet/JSP까지
(7/07)[채용예정교육]오라클자바개발잘하는신입뽑기프로젝트,교육전취업확정
평일야간(19:00~21:50) 개강
(7/01)안드로이드개발자과정[개강확정]
(7/01)닷넷(C#,Network,ADO.NET,ASP.NET)마스터과정
(7/02)Spring3.X, MyBatis, Hibernate실무과정[개강확정]
(7/02)자바웹(JSP,Spring,MyBatis,XPlatform)프로젝트과정
(7/02)JAVA,Network&WEB&Framework(자바기초에서웹스프링까지)
(7/03)웹퍼블리싱 마스터
(7/15)SQL기초에서실무까지
(7/15)MyBatis3.X, Hibernate4.X ORM실무과정
(7/22)자바기초에서JSP,Ajax,jQuery,Spring3.2,MyBatis까지
주말(10:00~17:50) 개강
(6/28)Spring3.X, MyBatis, Hibernate실무과정[개강확정]
(6/28)안드로이드개발자과정
(6/29)자바기초에서JSP,Ajax,jQuery,Spring3.2,MyBatis까지[개강확정]
(7/05)SQL초보에서 Schema Object까지
(7/12)자바웹(JSP,Spring,MyBatis,XPlatform)프로젝트과정
(7/12)MyBatis3.X, Hibernate4.X ORM실무과정
(7/12)개발자를위한PLSQL,SQL튜닝,힌트
(7/12)실무예제로 배워보는 jQuery(개발자/디자이너를위한)
(7/13)C#,ASP.NET마스터
주말저녁(18:30~22:20) 개강
(6/28)JAVA,Network&WEB&Framework
(6/28)SQL기초에서실무까지
댓글 없음:
댓글 쓰기