diff Main/jungle-main/store/impl/logger/DefaultTreeOperationLog.cs @ 20:1f99e150f336

fix folder and add Object Mapper.
author Kazuma Takeda
date Thu, 15 Dec 2016 22:52:48 +0900
parents
children f2ea780b3e80
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Main/jungle-main/store/impl/logger/DefaultTreeOperationLog.cs	Thu Dec 15 22:52:48 2016 +0900
@@ -0,0 +1,67 @@
+using UnityEngine;
+using System.Collections.Generic;
+using System;
+using System.Collections;
+using System.Linq;
+
+namespace JungleDB {
+	public class DefaultTreeOperationLog : TreeOperationLog {
+		private IEnumerable<TreeOperation> list;
+		private int size;
+
+		IEnumerator IEnumerable.GetEnumerator()
+		{
+			// call the generic version of the method
+			return this.GetEnumerator();
+		}
+
+		public IEnumerator<TreeOperation> GetEnumerator()
+		{
+			foreach (var i in list) {
+				yield return i;
+			}
+		}
+
+
+		public DefaultTreeOperationLog()
+		{
+			list = new List<TreeOperation>();
+			size = 0;
+		}
+
+		public DefaultTreeOperationLog(IEnumerable<TreeOperation> _list,int _size)
+		{
+			list = _list;
+			size = _size;
+		}
+
+	//	public IEnumerator<TreeOperation> iterator()
+	//	{
+	//		return list.itetator();
+	//	}
+
+		public TreeOperationLog add(NodePath _p, NodeOperation _op)
+		{
+			TreeOperation op = new DefaultTreeOperation(_p,_op);
+			List<TreeOperation> newList =  new List<TreeOperation>(op);
+			// java write Iterables.concat ここは間違い
+			IEnumerable<TreeOperation> concat = list.Union<TreeOperation>(newList);
+
+			return new DefaultTreeOperationLog(concat,size + 1);
+		}
+
+		public TreeOperationLog append(TreeOperationLog _log)
+		{
+			int argumentLogSize = _log.length();
+			// java write Iterables.concat
+			IEnumerable<TreeOperation> concat = list.Union<TreeOperation>(_log);
+
+			return new DefaultTreeOperationLog(concat,argumentLogSize + size);
+		}
+
+
+		public int length(){
+			return size;
+		}
+	}
+}