public static void adjustArray ( int type , Object array , int usedElements , int index , int count ) { if ( index >= usedElements ) { return ; } int newCount = usedElements + count ; int source ; int target ; int size ; if ( count >= 0 ) { source = index ; target = index + count ; size = usedElements - index ; } else { source = index - count ; target = index ; size = usedElements - index + count ; } if ( size > 0 ) { System . arraycopy ( array , source , array , target , size ) ; } if ( count < 0 ) { clearArray ( type , array , newCount , usedElements ) ; } }
Moves the contents of an array to allow both addition and removal of elements . Used arguments must be in range .