Remove an element from the specified index @webref intlist:method @brief Remove an element from the specified index
(int index)
| 219 | * @brief Remove an element from the specified index |
| 220 | */ |
| 221 | public int remove(int index) { |
| 222 | if (index < 0 || index >= count) { |
| 223 | throw new ArrayIndexOutOfBoundsException(index); |
| 224 | } |
| 225 | int entry = data[index]; |
| 226 | // int[] outgoing = new int[count - 1]; |
| 227 | // System.arraycopy(data, 0, outgoing, 0, index); |
| 228 | // count--; |
| 229 | // System.arraycopy(data, index + 1, outgoing, 0, count - index); |
| 230 | // data = outgoing; |
| 231 | // For most cases, this actually appears to be faster |
| 232 | // than arraycopy() on an array copying into itself. |
| 233 | for (int i = index; i < count-1; i++) { |
| 234 | data[i] = data[i+1]; |
| 235 | } |
| 236 | count--; |
| 237 | return entry; |
| 238 | } |
| 239 | |
| 240 | |
| 241 | // Remove the first instance of a particular value, |
no outgoing calls
no test coverage detected