LibreOffice Module xmerge (master) 1
IntArrayList.java
Go to the documentation of this file.
1/*
2 * This file is part of the LibreOffice project.
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 *
8 * This file incorporates work covered by the following license notice:
9 *
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
17 */
18
19package org.openoffice.xmerge.util;
20
21import java.util.ArrayList;
22
26public class IntArrayList {
27
29 private final ArrayList<Integer> list;
30
36 public IntArrayList() {
37 list = new ArrayList<Integer>();
38 }
39
45 public IntArrayList(int initialCapacity) {
46 list = new ArrayList<Integer>(initialCapacity);
47 }
48
55 public void ensureCapacity(int minCapacity) {
56 list.ensureCapacity(minCapacity);
57 }
58
72 public void ensureCapacityAndFill(int minCapacity, int fillValue) {
73
74 list.ensureCapacity(minCapacity);
75
76 int needToAdd = minCapacity - list.size();
77 if (needToAdd > 0) {
78 for (int i = 0; i < needToAdd; i++) {
79 list.add(Integer.valueOf(fillValue));
80 }
81 }
82 }
83
91 public void set(int index, int value) {
92 list.set(index, Integer.valueOf(value));
93 }
94
101 public void add(int value) {
102 list.add(Integer.valueOf(value));
103 }
104
113 public int get(int index) {
114 return list.get(index).intValue();
115 }
116
122 public int size() {
123 return list.size();
124 }
125}
This is a convenience class used to create an ArrayList of integers.
void ensureCapacity(int minCapacity)
This method ensures that the list is large enough for minCapacity elements.
int size()
This method gets the size of the list.
final ArrayList< Integer > list
The list to hold our integers.
IntArrayList(int initialCapacity)
Constructor.
void ensureCapacityAndFill(int minCapacity, int fillValue)
This method ensures that the list is large enough for minCapacity elements.
void add(int value)
This method appends an element to the list.
Any value
int i
index