From cda144aa2a3f77528670a1dd4b0d23d88e5ea9ea Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Mon, 4 Apr 2022 12:48:13 +0200 Subject: [PATCH] Refactor List and Tree --- src/BodyForceTreeMap.java | 47 +++++++++++++++++++++++++++++++++++ src/BodyForceTreeMapItem.java | 46 ---------------------------------- src/BodyLinkedList.java | 34 +++++++++++++++++++++++++ src/BodyLinkedListItem.java | 33 ------------------------ 4 files changed, 81 insertions(+), 79 deletions(-) delete mode 100644 src/BodyForceTreeMapItem.java delete mode 100644 src/BodyLinkedListItem.java diff --git a/src/BodyForceTreeMap.java b/src/BodyForceTreeMap.java index 1d250bc..719f168 100644 --- a/src/BodyForceTreeMap.java +++ b/src/BodyForceTreeMap.java @@ -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; + } +} diff --git a/src/BodyForceTreeMapItem.java b/src/BodyForceTreeMapItem.java deleted file mode 100644 index a7151e2..0000000 --- a/src/BodyForceTreeMapItem.java +++ /dev/null @@ -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; - } -} diff --git a/src/BodyLinkedList.java b/src/BodyLinkedList.java index f949721..454dbf7 100644 --- a/src/BodyLinkedList.java +++ b/src/BodyLinkedList.java @@ -225,3 +225,37 @@ public class BodyLinkedList implements Iterable { }; } } + +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; + } +} diff --git a/src/BodyLinkedListItem.java b/src/BodyLinkedListItem.java deleted file mode 100644 index 36e42a3..0000000 --- a/src/BodyLinkedListItem.java +++ /dev/null @@ -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; - } -}