1/* GENERATED SOURCE. DO NOT MODIFY. */
2// © 2016 and later: Unicode, Inc. and others.
3// License & terms of use: http://www.unicode.org/copyright.html#License
4/*
5 *******************************************************************************
6 * Copyright (C) 2014, International Business Machines Corporation and
7 * others. All Rights Reserved.
8 *******************************************************************************
9 *
10 * created on: 2014feb10
11 * created by: Markus W. Scherer
12 */
13package android.icu.impl.coll;
14
15// TODO: There must be a Java class for a growable array of ints without auto-boxing to Integer?!
16// Keep the API parallel to the C++ version for ease of porting. Port methods only as needed.
17// If & when we start using something else, we might keep this as a thin wrapper for porting.
18/**
19 * @hide Only a subset of ICU is exposed in Android
20 */
21public final class UVector32 {
22    public UVector32() {}
23    public boolean isEmpty() { return length == 0; }
24    public int size() { return length; }
25    public int elementAti(int i) { return buffer[i]; }
26    public int[] getBuffer() { return buffer; }
27    public void addElement(int e) {
28        ensureAppendCapacity();
29        buffer[length++] = e;
30    }
31    public void setElementAt(int elem, int index) { buffer[index] = elem; }
32    public void insertElementAt(int elem, int index) {
33        ensureAppendCapacity();
34        System.arraycopy(buffer, index, buffer, index + 1, length - index);
35        buffer[index] = elem;
36        ++length;
37    }
38    public void removeAllElements() {
39        length = 0;
40    }
41
42    private void ensureAppendCapacity() {
43        if(length >= buffer.length) {
44            int newCapacity = buffer.length <= 0xffff ? 4 * buffer.length : 2 * buffer.length;
45            int[] newBuffer = new int[newCapacity];
46            System.arraycopy(buffer, 0, newBuffer, 0, length);
47            buffer = newBuffer;
48        }
49    }
50    private int[] buffer = new int[32];
51    private int length = 0;
52}
53