353 |
{ |
{ |
354 |
return buffer; |
return buffer; |
355 |
} |
} |
356 |
|
|
357 |
|
/** |
358 |
|
* Replaces a portion of the storage with the specified items. |
359 |
|
* |
360 |
|
* @param position the position at which to remove items |
361 |
|
* @param rmSize the number of items to remove |
362 |
|
* @param addItems the items to add at location |
363 |
|
* @param addSize the number of items to add |
364 |
|
*/ |
365 |
|
protected void replace(int position, int rmSize, Object addItems, |
366 |
|
int addSize) |
367 |
|
{ |
368 |
|
// Remove content |
369 |
|
shiftGap(position); |
370 |
|
gapEnd += rmSize; |
371 |
|
|
372 |
|
// If gap is too small, enlarge the gap. |
373 |
|
if ((gapEnd - gapStart) < addSize) |
374 |
|
shiftEnd(addSize); |
375 |
|
|
376 |
|
// Add new items to the buffer. |
377 |
|
System.arraycopy(addItems, 0, buffer, gapStart, addSize); |
378 |
|
gapStart += addSize; |
379 |
|
} |
380 |
} |
} |