Quote (ROM @ Oct 25 2015 01:10pm)
Copy paste of next
Code
public Object previous(){
Object previousValue = _source.previous();
System.out.println("previous() moved from " + _current + " to " + previousValue);
_current = previousValue;
return previousValue;
}
looks like it's just a notation issue.
Quote
its cursor position always lies between the element that would be returned by a call to previous() and the element that would be returned by a call to next()
so if this is your list:
4, 8, 12
here's your cursor per call, line by line, for one iteration of your loop:
cursor, 4, 8, 12
call next: returns 4
4, cursor, 8, 12
call previous: returns 4
cursor, 4, 8, 12
call next: returns 4
4, cursor, 8, 12
so when you call next() you pass a number and return it. when you call previous, you jump right back and return the same number. hence it thinks it's a duplicate. so what you're thinking of as previous in your mind isn't the same as previous in the list. so adjust your code to look at the element you want to look at. keep in mind if you call previous multiple times, you may need to compensate with extra next() to get the cursor where you want. i suggest drawing out what i drew out for your example, by hand. then after you get your trace done, then write your code.
This post was edited by carteblanche on Oct 25 2015 11:23am