Refactor List and Tree

This commit is contained in:
2022-04-04 12:48:13 +02:00
parent 4bb1d6a36c
commit cda144aa2a
4 changed files with 81 additions and 79 deletions

View File

@@ -225,3 +225,37 @@ public class BodyLinkedList implements Iterable<Body> {
};
}
}
class BodyLinkedListItem {
private final Body body;
private BodyLinkedListItem prev;
private BodyLinkedListItem next;
public BodyLinkedListItem(Body body) {
this.body = body;
this.prev = null;
this.next = null;
}
public Body body() {
return body;
}
public BodyLinkedListItem prev() {
return prev;
}
public void setPrev(BodyLinkedListItem prev) {
this.prev = prev;
if (prev != null) prev.next = this;
}
public BodyLinkedListItem next() {
return next;
}
public void setNext(BodyLinkedListItem next) {
this.next = next;
if (next != null) next.prev = this;
}
}