diff src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-main/store/impl/logger/DefaultTreeOperationLog.cs @ 17:01a08cf4b2d9

Liq Files
author Kazuma
date Mon, 07 Nov 2016 01:05:24 +0900
parents abe0c247f5a5
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle-main/store/impl/logger/DefaultTreeOperationLog.cs	Mon Nov 07 01:05:24 2016 +0900
@@ -0,0 +1,66 @@
+using UnityEngine;
+using System.Collections.Generic;
+using System;
+using System.Collections;
+using System.Linq;
+
+
+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;
+	}
+}