MCPcopy Create free account
hub / github.com/davidgiven/luje / insertElementAt

Method insertElementAt

lib/java/util/Vector.java:577–593  ·  view source on GitHub ↗

Inserts the specified object into this vector at the specified location. This object is inserted before any previous element at the specified location. All elements with an index equal or greater than location have their index increased by 1. If the location is equal to the size of this vect

(E object, int location)

Source from the content-addressed store, hash-verified

575 * @see #size
576 */
577 public synchronized void insertElementAt(E object, int location) {
578 if (0 <= location && location <= elementCount) {
579 if (elementCount == elementData.length) {
580 growByOne();
581 }
582 int count = elementCount - location;
583 if (count > 0) {
584 System.arraycopy(elementData, location, elementData,
585 location + 1, count);
586 }
587 elementData[location] = object;
588 elementCount++;
589 modCount++;
590 } else {
591 throw new ArrayIndexOutOfBoundsException(location);
592 }
593 }
594
595 /**
596 * Returns if this vector has no elements, a size of zero.

Callers 1

addMethod · 0.95

Calls 2

growByOneMethod · 0.95
arraycopyMethod · 0.95

Tested by

no test coverage detected