Trying to implement my own iterator in Java

  • Comp Sci
  • Thread starter trouty323
  • Start date
  • #1
24
0

Homework Statement


Basically, I am assigned to implement my own iterator using a Doubly Linked List. The methods, of course, are hasNext(), next(), and remove(). The one that is giving me the most grief is the remove() method.


Homework Equations





The Attempt at a Solution



The code that I have currently is:

Code:
public void remove() {
	lastItemReturned = lastItemReturned.prev;
	nextItem = lastItemReturned.next.next;
	index--;
}
Now, this could actually be right and I may be messing up somewhere else in the code, but I have a feeling this is not the case. Does anybody know if this part of code is right?

Homework Statement





Homework Equations





The Attempt at a Solution

 

Answers and Replies

Related Threads on Trying to implement my own iterator in Java

Replies
2
Views
9K
Replies
5
Views
1K
Replies
3
Views
2K
Replies
1
Views
19K
Replies
0
Views
1K
Replies
2
Views
10K
Replies
2
Views
4K
Top