private void ensureSize(int newSize) {
            if (items.length < newSize) {
                int[] newItems = new int[items.length * 2];
                System.arraycopy(items, 0, newItems, 0, items.length);
                items = newItems;
            }
        }