01: /*
02: * @(#)IntArray.java 1.2 04/12/06
03: *
04: * Copyright (c) 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution of
07: * this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package pnuts.compiler;
10:
11: class IntArray {
12: int array[] = new int[2];
13: int count = 0;
14:
15: public void add(int i) {
16: if (count >= array.length - 1) {
17: int[] newarray = new int[array.length * 2];
18: System.arraycopy(array, 0, newarray, 0, array.length);
19: array = newarray;
20: }
21: array[count++] = i;
22: }
23:
24: public int size() {
25: return count;
26: }
27:
28: public int[] getArray() {
29: return array;
30: }
31: }
|