Java Reference
In-Depth Information
// advance to the next element (or to end)
while (pos >= arrays[array].length) {
off += arrays[array++].length;
pos = 0;
if (array >= arrays.length)
break;
}
return ret;
}
public void remove() {
throw new UnsupportedOperationException();
}
}
This implementation uses our knowledge of the underlying data struc-
tures to know exactly where the next element is coming from. This is
more efficient than invoking get to implement the iterator's next . (It is
also written to handle empty arrays and an empty ArrayBunchList .)
You can often substantially increase the performance of a resizable list
by overriding the protected removeRange method, which takes two int
parameters, min and max , and removes the elements starting at min , up
to but not including max . The clear method uses remove Range to remove
elements from lists and sublists. The default implementation is to invoke
remove on each element one at a time. Many data structures can do bulk
removes much more efficiently.
AbstractSequentialList extends AbstractList to make it easier to imple-
ment lists that are backed by a sequential access data store where
moving from one element of the data to another requires examining
each element of the data. In such a store, random access requires work
since you must traverse each element to get to the next. A linked list
is a sequential access data store. By contrast, an array can be ran-
domly accessed directly. This is why ArrayList extends AbstractList ,
while LinkedList extends AbstractSequentialList .
 
Search WWH ::




Custom Search