1 22 23 package org.gjt.sp.util; 24 25 28 public class IntegerArray 29 { 30 public IntegerArray() 32 { 33 this(2000); 34 } 36 public IntegerArray(int initialSize) 38 { 39 array = new int[initialSize]; 40 } 42 public void add(int num) 44 { 45 if(len >= array.length) 46 { 47 int[] arrayN = new int[len * 2]; 48 System.arraycopy(array,0,arrayN,0,len); 49 array = arrayN; 50 } 51 52 array[len++] = num; 53 } 55 public final int get(int index) 57 { 58 return array[index]; 59 } 61 public final int getSize() 63 { 64 return len; 65 } 67 public final void setSize(int len) 69 { 70 this.len = len; 71 } 73 public final void clear() 75 { 76 len = 0; 77 } 79 public int[] getArray() 81 { 82 return array; 83 } 85 private int[] array; 87 private int len; 88 } 90 | Popular Tags |