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

first commit
author Kazuma
date Tue, 21 Jun 2016 17:11:12 +0900
parents
children 02b2ab7bffe6
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/store/impl/logger/DefaultTreeOperationLog.cs	Tue Jun 21 17:11:12 2016 +0900
@@ -0,0 +1,68 @@
+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;
+
+	TreeOperation[] _array;
+	TreeOperation Count;
+
+	IEnumerator IEnumerable.GetEnumerator()
+	{
+		// call the generic version of the method
+		return this.GetEnumerator();
+	}
+
+	public IEnumerator<TreeOperation> GetEnumerator()
+	{
+		for (int i = 0; i < Convert.ToInt32(Count); i++)
+			yield return _array[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;
+	}
+}