summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/data/Tree.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2017-02-20 01:55:25 -0500
committerbculkin2442 <bjculkin@mix.wvu.edu>2017-02-20 01:55:25 -0500
commit3c7460950c060d93bffc395f074f09c18948d91c (patch)
tree19eaba394061f720c31cf8507fe199b8357fe5c8 /BJC-Utils2/src/main/java/bjc/utils/data/Tree.java
parent699c2890ca50f9b33ee8e228e544105754b0daca (diff)
Minor updates
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/Tree.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/data/Tree.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/Tree.java b/BJC-Utils2/src/main/java/bjc/utils/data/Tree.java
index b812650..c44eece 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/Tree.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/Tree.java
@@ -300,4 +300,29 @@ public class Tree<ContainedType> implements ITree<ContainedType> {
action.accept(data);
}
}
+
+ public boolean equals(Object other) {
+ if(!(other instanceof Tree)) return false;
+
+ Tree<ContainedType> otr = (Tree<ContainedType>) other;
+
+ if(!otr.data.equals(data)) return false;
+
+ if(children == null && otr.children == null) return true;
+
+ if(children == null && otr.children != null) return false;
+ if(children != null && otr.children == null) return false;
+
+ if(children.getSize() != otr.children.getSize()) return false;
+
+ int childNo = 0;
+
+ for(ITree<ContainedType> child : children) {
+ if(!otr.children.getByIndex(childNo).equals(child)) return false;
+
+ childNo += 1;
+ }
+
+ return true;
+ }
}