add the specfied value at the specified index @param index the index where the new value is to be added @param value the new value @exception IndexOutOfBoundsException if the index is out of range (index < 0 || index > size()).
(final int index, final int value)
| 111 | */ |
| 112 | |
| 113 | public void add(final int index, final int value) |
| 114 | { |
| 115 | if (index > _limit) |
| 116 | { |
| 117 | throw new IndexOutOfBoundsException(); |
| 118 | } |
| 119 | else if (index == _limit) |
| 120 | { |
| 121 | add(value); |
| 122 | } |
| 123 | else |
| 124 | { |
| 125 | |
| 126 | // index < limit -- insert into the middle |
| 127 | if (_limit == _array.length) |
| 128 | { |
| 129 | growArray(_limit * 2); |
| 130 | } |
| 131 | System.arraycopy(_array, index, _array, index + 1, |
| 132 | _limit - index); |
| 133 | _array[ index ] = value; |
| 134 | _limit++; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Appends the specified element to the end of this list |