20
|
1 using UnityEngine;
|
|
2
|
|
3 namespace JungleDB {
|
|
4 public class DefaultTreeNode : TreeNode {
|
|
5
|
|
6 private List<TreeNode> children;
|
31
|
7 private TreeMap<string, object> attrs;
|
20
|
8 private static readonly List<TreeNode> NIL_LIST = new List<TreeNode>();
|
|
9
|
|
10 public DefaultTreeNode()
|
31
|
11 : this (NIL_LIST, new TreeMap<string, object> ())
|
20
|
12 {
|
|
13 }
|
|
14
|
31
|
15 public DefaultTreeNode(List<TreeNode> _children, TreeMap<string, object> _attrs) {
|
20
|
16 attrs = _attrs;
|
|
17 children = _children;
|
|
18 }
|
|
19
|
|
20 public TreeNodeChildren getChildren() {
|
|
21 return new DefaultTreeNodeChildren(children, attrs);
|
|
22 }
|
|
23
|
|
24 public TreeNodeAttributes getAttributes() {
|
|
25 return new DefaultTreeNodeAttribute(children, attrs); // count = null.
|
|
26 }
|
|
27
|
|
28 public TreeNode createNewNode() {
|
|
29 return new DefaultTreeNode();
|
|
30 }
|
|
31
|
|
32 public DefaultTreeNode clone() {
|
|
33 return new DefaultTreeNode(children, attrs);
|
|
34 }
|
|
35
|
|
36 public Either<Error, TreeNode> appendRootNode() {
|
31
|
37 TreeNodeChildren newRootChildren = new DefaultTreeNodeChildren(NIL_LIST, new TreeMap<string, object>());
|
20
|
38 Either<Error, TreeNode> either = newRootChildren.addNewChildAt(0,this);
|
|
39 return either;
|
|
40 }
|
|
41
|
|
42 public int compareTo(TreeNode o) {
|
|
43 return this.GetHashCode() - o.GetHashCode();
|
|
44 }
|
|
45 }
|
|
46 }
|