view Main/jungle-main/transaction/DefaultTreeNode.cs @ 20:1f99e150f336

fix folder and add Object Mapper.
author Kazuma Takeda
date Thu, 15 Dec 2016 22:52:48 +0900
parents
children 1466993c104c
line wrap: on
line source

using UnityEngine;

namespace JungleDB {
	public class DefaultTreeNode : TreeNode {
		
		private List<TreeNode> children;
		private TreeMap<string,byte[]> attrs;
		private static readonly List<TreeNode> NIL_LIST = new List<TreeNode>();

		public DefaultTreeNode() 
			: this (NIL_LIST, new TreeMap<string,byte[]> ())
		{
		}

		public DefaultTreeNode(List<TreeNode> _children, TreeMap<string, byte[]> _attrs) {
			attrs = _attrs;
			children = _children;
		}

		public TreeNodeChildren getChildren() {
			return new DefaultTreeNodeChildren(children, attrs);
		}

		public TreeNodeAttributes getAttributes() {
			return new DefaultTreeNodeAttribute(children, attrs); // count = null.
		}

		public TreeNode createNewNode() {
			return new DefaultTreeNode();
		}

		public DefaultTreeNode clone() {
			return new DefaultTreeNode(children, attrs);
		}

		public Either<Error, TreeNode> appendRootNode() {
			TreeNodeChildren newRootChildren = new DefaultTreeNodeChildren(NIL_LIST, new TreeMap<string, byte[]>());
			Either<Error, TreeNode> either = newRootChildren.addNewChildAt(0,this);
			return either;
		}

		public int compareTo(TreeNode o) {
			return this.GetHashCode() - o.GetHashCode();
		}
	}
}