Refactor List and Tree
This commit is contained in:
@ -105,3 +105,50 @@ public class BodyForceTreeMap {
|
||||
return toString(root);
|
||||
}
|
||||
}
|
||||
|
||||
class BodyForceTreeMapItem {
|
||||
private final Body key;
|
||||
private Vector3 value;
|
||||
private BodyForceTreeMapItem parent;
|
||||
private BodyForceTreeMapItem left;
|
||||
private BodyForceTreeMapItem right;
|
||||
|
||||
public BodyForceTreeMapItem(Body key, Vector3 value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Body key() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public void setValue(Vector3 value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Vector3 value() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public BodyForceTreeMapItem left() {
|
||||
return this.left;
|
||||
}
|
||||
|
||||
public BodyForceTreeMapItem right() {
|
||||
return this.right;
|
||||
}
|
||||
|
||||
public BodyForceTreeMapItem parent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
public void setLeft(BodyForceTreeMapItem left) {
|
||||
this.left = left;
|
||||
if (left != null) left.parent = this;
|
||||
}
|
||||
|
||||
public void setRight(BodyForceTreeMapItem right) {
|
||||
this.right = right;
|
||||
if (right != null) right.parent = this;
|
||||
}
|
||||
}
|
||||
|
@ -1,46 +0,0 @@
|
||||
class BodyForceTreeMapItem {
|
||||
private final Body key;
|
||||
private Vector3 value;
|
||||
private BodyForceTreeMapItem parent;
|
||||
private BodyForceTreeMapItem left;
|
||||
private BodyForceTreeMapItem right;
|
||||
|
||||
public BodyForceTreeMapItem(Body key, Vector3 value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Body key() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public void setValue(Vector3 value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Vector3 value() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public BodyForceTreeMapItem left() {
|
||||
return this.left;
|
||||
}
|
||||
|
||||
public BodyForceTreeMapItem right() {
|
||||
return this.right;
|
||||
}
|
||||
|
||||
public BodyForceTreeMapItem parent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
public void setLeft(BodyForceTreeMapItem left) {
|
||||
this.left = left;
|
||||
if (left != null) left.parent = this;
|
||||
}
|
||||
|
||||
public void setRight(BodyForceTreeMapItem right) {
|
||||
this.right = right;
|
||||
if (right != null) right.parent = this;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user