@Override public void ensureCapacity( int minCapacity ) { int capacity = a.length; if ( minCapacity > capacity ) { long[] aNew = newArray( capacity, minCapacity ); System.arraycopy( a, 0, aNew, 0, n ); this.a = aNew; } }
/** * 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 ) { long[] a = this.a; int capacity = a.length; int n = this.n; int nNew = n + c; if ( nNew > capacity ) { long[] aNew = newArray( capacity, nNew ); System.arraycopy( a, 0, aNew, 0, n ); this.a = aNew; } this.n = nNew; }
/** * 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 ) { long[] a = this.a; int capacity = a.length; int n = this.n; int nNew = n + c; if ( nNew > capacity ) { long[] 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; }