-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathIUDLLReferenceCode.java
More file actions
94 lines (74 loc) · 2.58 KB
/
IUDLLReferenceCode.java
File metadata and controls
94 lines (74 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.NoSuchElementException;
public class IUDLLReferenceCode {
//Iterator - TODO: merge w/ ListIterator
private class IteratorTemp implements Iterator<E> {
private BidirectionalNode<E> previous;
private BidirectionalNode<E> current;
private BidirectionalNode<E> next;
private int iterModCount;
private int currentIndex; // this is the actual index of the next element to be served
// private int virtualIndex; // this represents what the zero-index value would be...
private boolean canRemove;
// private IteratorTemp() {
// //TODO: incorporate startingIndex logic
// previous = null;
// current = front;
// next = front.getNext();
// iterModCount = modCount;
// currentIndex = 0;
// canRemove = false;
// }
// @Override
// public boolean hasNext() {
// if (iterModCount != modCount) { throw new ConcurrentModificationException(); } // fail-fast
// return currentIndex < count;
// }
// @Override
// public E next() {
// if (!hasNext()) { throw new NoSuchElementException(); }
// E item = get(currentIndex);
// currentIndex++;
// canRemove = true;
// //array - TODO: @watermelon2718 delete
// // E item = list[current];
// // current = increment(current);
// // virtualIndex++;
// // canRemove = true;
// return item;
// }
// public boolean hasPrevious() {
// //TODO
// return false;
// }
// public E previous() {
// //TODO
// return current.getElement();
// }
public void remove() {// TODO: needs to branch based on which direction we just moved the iterator
if (iterModCount != modCount) { throw new ConcurrentModificationException(); } // fail-fast
if (!canRemove) { throw new IllegalStateException(); }
currentIndex--; // ???
if(currentIndex == 0) {
front = next;
} else {
previous.setNext(next);
}
if (next == null) {
rear = previous;
}
current = null;
count--;
iterModCount++;
modCount++;
canRemove = false;
}
// //TODO: do we need this?
// public void set() {
// }
// //TODO: do we need this?
// public void add(){
// }
}
}