I have the latter in mind (sublist based on positions of the cursors
when the sublist is created). Getting the nextIndex from the cursor
would work, but I want to avoid the list traversals that occur in the
existing sublist constructor (in the calls to _list.getListableAt).
These traversals are superfluous since the cursor already knows the
right place in the list.
I haven't written the code yet-- I wanted to see if it made sense to do
so first. But roughly, ignoring edge conditions and parameter
validation, it would be something ike this:
CursorableSubList(CursorableLinkedList list, Cursor start, Cursor end) {
_list = List;
_head.setNext (start._cur);
_head.setPrev(end._cur);
_pre = start._cur;
_post = end._cur;
_modCount = _list._modCount;
// don't know how to set _size without a list traversal
}
"Waldhoff, Rodney" wrote:
>
>
> I'm not sure I understand. Do you intend the sublist to be dynamic
> (i.e., the sublist shrinks or grows as the start/end cursors are
> moved), or simply that you obtain a sublist containing the elements
> between the two cursors at the time the sublist is created?
>
> If it's the former, that sounds interesting but complicated
> (especially if you consider moving the cursors around so that head >
> tail, etc.). If it's the later, wouldn't it be enough to expose the
> _nextIndex attribute of Cursor (actually inherited from ListIter) and
> use the existing CursorableSubList factory methods? E.g.,
> list.sublist(cursor1.getIndex(),cursor2.getIndex()) or something like
> that. (Of course, we could make the API a little smarter using
> list.sublist(cursor1,cursor2) or something like that.)
>
> Have I missed your point entirely? Do you have a patch that
> demonstrates?
>
> - Rod