| 34 | /// |
| 35 | /// - java.lang.StringBuffer |
| 36 | public class Vector<E> extends AbstractList<E> implements List<E>, |
| 37 | RandomAccess { |
| 38 | |
| 39 | /// The number of elements or the size of the vector. |
| 40 | protected int elementCount; |
| 41 | |
| 42 | /// The elements of the vector. |
| 43 | protected Object[] elementData; |
| 44 | |
| 45 | /// How many elements should be added to the vector when it is detected that |
| 46 | /// it needs to grow to accommodate extra entries. If this value is zero or |
| 47 | /// negative the size will be doubled if an increase is needed. |
| 48 | protected int capacityIncrement; |
| 49 | |
| 50 | private static final int DEFAULT_SIZE = 10; |
| 51 | |
| 52 | /// Constructs a new vector using the default capacity. |
| 53 | public Vector() { |
| 54 | this(DEFAULT_SIZE, 0); |
| 55 | } |
| 56 | |
| 57 | /// Constructs a new vector using the specified capacity. |
| 58 | /// |
| 59 | /// #### Parameters |
| 60 | /// |
| 61 | /// - `capacity`: the initial capacity of the new vector. |
| 62 | /// |
| 63 | /// #### Throws |
| 64 | /// |
| 65 | /// - `IllegalArgumentException`: if `capacity` is negative. |
| 66 | public Vector(int capacity) { |
| 67 | this(capacity, 0); |
| 68 | } |
| 69 | |
| 70 | /// Constructs a new vector using the specified capacity and capacity |
| 71 | /// increment. |
| 72 | /// |
| 73 | /// #### Parameters |
| 74 | /// |
| 75 | /// - `capacity`: the initial capacity of the new vector. |
| 76 | /// |
| 77 | /// - `capacityIncrement`: the amount to increase the capacity when this vector is full. |
| 78 | /// |
| 79 | /// #### Throws |
| 80 | /// |
| 81 | /// - `IllegalArgumentException`: if `capacity` is negative. |
| 82 | public Vector(int capacity, int capacityIncrement) { |
| 83 | if (capacity < 0) { |
| 84 | throw new IllegalArgumentException(); |
| 85 | } |
| 86 | elementData = newElementArray(capacity); |
| 87 | elementCount = 0; |
| 88 | this.capacityIncrement = capacityIncrement; |
| 89 | } |
| 90 | |
| 91 | /// Constructs a new instance of `Vector` containing the elements in |
| 92 | /// `collection`. The order of the elements in the new `Vector` |
| 93 | /// is dependent on the iteration order of the seed collection. |
nothing calls this directly
no outgoing calls
no test coverage detected