• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
13 package ohos.global.icu.impl.coll;
14 
15 // TODO: There must be a Java class for a growable array of longs without auto-boxing to Long?!
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 exposed on OHOS
20  */
21 public final class UVector64 {
UVector64()22     public UVector64() {}
isEmpty()23     public boolean isEmpty() { return length == 0; }
size()24     public int size() { return length; }
elementAti(int i)25     public long elementAti(int i) { return buffer[i]; }
getBuffer()26     public long[] getBuffer() { return buffer; }
addElement(long e)27     public void addElement(long e) {
28         ensureAppendCapacity();
29         buffer[length++] = e;
30     }
setElementAt(long elem, int index)31     public void setElementAt(long elem, int index) { buffer[index] = elem; }
insertElementAt(long elem, int index)32     public void insertElementAt(long elem, int index) {
33         ensureAppendCapacity();
34         System.arraycopy(buffer, index, buffer, index + 1, length - index);
35         buffer[index] = elem;
36         ++length;
37     }
removeAllElements()38     public void removeAllElements() {
39         length = 0;
40     }
41 
ensureAppendCapacity()42     private void ensureAppendCapacity() {
43         if(length >= buffer.length) {
44             int newCapacity = buffer.length <= 0xffff ? 4 * buffer.length : 2 * buffer.length;
45             long[] newBuffer = new long[newCapacity];
46             System.arraycopy(buffer, 0, newBuffer, 0, length);
47             buffer = newBuffer;
48         }
49     }
50     private long[] buffer = new long[32];
51     private int length = 0;
52 }
53