class Queue { private final int MAX_SIZE = 100000; private int head; private int tail; private Object[] array; public Queue() { this.head = 0; this.tail = -1; array = new Object[MAX_SIZE]; } public void add(Object o) { array[++tail] = o; } public Object peek() { return array[head]; } public Object poll() { return array[head++]; } public boolean empty() { return head > tail; } }
'Java > Java 기초' 카테고리의 다른 글
SHA256 encoding (0) | 2018.05.31 |
---|---|
Base62 encoding decoding (0) | 2018.05.29 |
Java Stack 구현 (0) | 2018.05.24 |
XSS(Cross-site scripting) 특수문자 치환 (0) | 2018.05.10 |
Arrays.binarySearch() 사용 (0) | 2017.12.29 |