1 24 25 package org.aspectj.util; 26 27 28 import java.util.*; 29 30 public class IntList { 31 private final int BASE_SIZE = 256; 32 33 private int[] data; 34 private int size; 35 36 public IntList() { 37 size = 0; 38 data = new int[BASE_SIZE]; 39 } 40 41 private void ensureSize(int needsSize) { 42 if (needsSize <= data.length) return; 43 44 int[] newData = new int[data.length*2]; 45 System.arraycopy(data, 0, newData, 0, data.length); 46 data = newData; 47 } 48 49 public void add(int value) { 50 ensureSize(size+1); 51 data[size++] = value; 52 } 53 54 public int[] toIntArray() { 55 int[] ret = new int[size]; 56 System.arraycopy(data, 0, ret, 0, size); 57 return ret; 58 } 59 } 60 | Popular Tags |