@Override public void append( Object[] vs ) { append( vs, 0, vs.length ); }
@Override public void set( int i, Object[] vs, int from, int to ) { int c = to - from; ensureCapacity( i + c ); System.arraycopy( vs, from, a, i, c ); n = i + c; }
@Override public void insert( int i, Object[] vs ) { insert( i, vs, 0, vs.length ); }
@Override public void ensureCapacity( int minCapacity ) { int capacity = a.length; if ( minCapacity > capacity ) { Object[] aNew = newArray( capacity, minCapacity ); System.arraycopy( a, 0, aNew, 0, n ); this.a = aNew; } }
@Override public void insert( int i, Object v ) { prepForInsert( i, 1 ); a[i] = v; }
@Override public void prepend( Object v ) { prepForPrepend( 1 ); a[0] = v; }
@Override public void append( Object v ) { prepForAppend( 1 ); a[n - 1] = v; }
@Override public void prepend( Object[] vs ) { prepend( vs, 0, vs.length ); }
@Override public void set( int i, Object[] vs ) { set( i, vs, 0, vs.length ); }
@Override public void removeIndex( int index ) { removeRange( index, index + 1 ); }
/** * Makes room in this array for new values to be appended. * * When this call returns, the values in <code>this.a</code> on <code>[this.n-c,this.n)</code> * are undefined. Writing meaningful values to these indices is up to the * caller. * * @param c The count of new values that will be appended */ public void prepForAppend( int c ) { Object[] a = this.a; int capacity = a.length; int n = this.n; int nNew = n + c; if ( nNew > capacity ) { Object[] aNew = newArray( capacity, nNew ); System.arraycopy( a, 0, aNew, 0, n ); this.a = aNew; } this.n = nNew; }
@Override public void insert( int i, Object[] vs, int from, int to ) { int c = to - from; prepForInsert( i, c ); System.arraycopy( vs, from, a, i, c ); }
@Override public void prepend( Object[] vs, int from, int to ) { int c = to - from; prepForPrepend( c ); System.arraycopy( vs, from, a, 0, c ); }
@Override public void append( Object[] vs, int from, int to ) { int c = to - from; prepForAppend( c ); System.arraycopy( vs, from, a, n - c, c ); }
@Override public void prepend( Objects vs ) { prepend( vs, 0, vs.n( ) ); }
/** * Makes room in this array for new values to be prepended. * * When this call returns, the values in <code>this.a</code> on <code>[0,c)</code> * are undefined. Writing meaningful values to these indices is up to the * caller. * * @param c The count of new values that will be inserted */ public void prepForPrepend( int c ) { Object[] a = this.a; int capacity = a.length; int n = this.n; int nNew = n + c; if ( nNew > capacity ) { Object[] aNew = newArray( capacity, nNew ); System.arraycopy( a, 0, aNew, c, n ); this.a = aNew; } else { System.arraycopy( a, 0, a, c, n ); } this.n = nNew; }
@Override public void insert( int i, Objects vs, int from, int to ) { int c = to - from; prepForInsert( i, c ); vs.copyTo( from, a, i, c ); }
@Override public void prepend( Objects vs, int from, int to ) { int c = to - from; prepForPrepend( c ); vs.copyTo( from, a, 0, c ); }
@Override public void append( Objects vs, int from, int to ) { int c = to - from; prepForAppend( c ); vs.copyTo( from, a, n - c, c ); }
@Override public void insert( int i, Objects vs ) { insert( i, vs, 0, vs.n( ) ); }