public E remove ( int index ) { E e = data [ index ] ; // make copy of element to remove so it can be returned data [ index ] = data [ -- size ] ; // overwrite item to remove with last element data [ size ] = null ; // null last element, so gc can do its work return e ; }
Removes the element at the specified position in this Bag . Order of elements is not preserved .