class node{ int x; int y; } public class Test { public static void main(String[] args) { MyQueue<String> q=new MyQueue<String>(); q.push("xxx"); q.push("xxx"); q.push("xxx"); q.push("你"); q.push("真"); q.push("666!"); q.print(); System.out.println(q.GetMaxSize()); } } class MyQueue<T>{ public int HIndex=0; public int size=0; public int MaxSize=0; public T space[]; @SuppressWarnings("unchecked") public boolean push(T t) { if(MaxSize<=size){ MaxSize=MaxSize+((MaxSize>>1)>1?(MaxSize>>1):1); T temp[]=(T[])new Object[MaxSize]; for(int i=0;i<size;++i) { temp[i]=space[i]; } space=temp; } space[size++]=t; return true; } public boolean pop() { if(!isEmpty()) { HIndex++; size--; } return true; } public boolean isEmpty() { if(size==0) { return true; } return false; } public boolean print() { for(int i=HIndex;i<size;++i) { System.out.println(space[i]); } return true; } public int GetMaxSize() { return MaxSize; } }