Finished AB5
This commit is contained in:
@ -171,11 +171,8 @@ public class BodyLinkedList implements Iterable<Body> {
|
||||
}
|
||||
|
||||
Item item = first;
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (item.body == body) {
|
||||
return i;
|
||||
}
|
||||
item = item.next;
|
||||
for (int i = 0; i < size; i++, item = item.next) {
|
||||
if (item.body == body) return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -217,9 +214,9 @@ public class BodyLinkedList implements Iterable<Body> {
|
||||
public Body next() {
|
||||
if (!yieldedFirst) {
|
||||
yieldedFirst = true;
|
||||
return ptr.body;
|
||||
} else {
|
||||
ptr = ptr.next;
|
||||
}
|
||||
ptr = ptr.next;
|
||||
return ptr.body;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user