1/* 2 * Javassist, a Java-bytecode translator toolkit. 3 * Copyright (C) 1999-2007 Shigeru Chiba, and others. All Rights Reserved. 4 * 5 * The contents of this file are subject to the Mozilla Public License Version 6 * 1.1 (the "License"); you may not use this file except in compliance with 7 * the License. Alternatively, the contents of this file may be used under 8 * the terms of the GNU Lesser General Public License Version 2.1 or later. 9 * 10 * Software distributed under the License is distributed on an "AS IS" basis, 11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 12 * for the specific language governing rights and limitations under the 13 * License. 14 */ 15package javassist.bytecode.analysis; 16 17import java.util.NoSuchElementException; 18 19class IntQueue { 20 private static class Entry { 21 private IntQueue.Entry next; 22 private int value; 23 private Entry(int value) { 24 this.value = value; 25 } 26 } 27 private IntQueue.Entry head; 28 29 private IntQueue.Entry tail; 30 31 void add(int value) { 32 IntQueue.Entry entry = new Entry(value); 33 if (tail != null) 34 tail.next = entry; 35 tail = entry; 36 37 if (head == null) 38 head = entry; 39 } 40 41 boolean isEmpty() { 42 return head == null; 43 } 44 45 int take() { 46 if (head == null) 47 throw new NoSuchElementException(); 48 49 int value = head.value; 50 head = head.next; 51 if (head == null) 52 tail = null; 53 54 return value; 55 } 56}