view src/test/csharp/jp.ac.u-ryukyu.ie.cr/junge-main/DefaultJungleTreeTest.cs @ 12:b71d9ea6bd8e

Add Network Operation Class. this codes can not test yet.
author Kazuma
date Sun, 23 Oct 2016 12:25:57 +0900
parents
children
line wrap: on
line source

using UnityEngine;
using System;
//using System.Diagnostics;

public class DefaultJungleTreeTest : MonoBehaviour {
	// apiの仕様的にこんな感じ
	private readonly int COUNT = 500;

	public string key = "moumou";
	private byte[] value = BitConverter.GetBytes(10);

	public void Start () {
		Jungle j = new DefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser()));
		JungleTree t = j.createNewTree("tree");

		JungleTreeEditor editor1 = t.getTreeEditor();

		DefaultNodePath root = new DefaultNodePath();
		NodePath path = root.add(0);
		// NodePath path = root.pop().rights();

		print(path.ToString());


		float check_time = Time.realtimeSinceStartup;

		for(int i = 0; i < COUNT; i++) { 
			Either<Error, JungleTreeEditor> either = editor1.putAttribute(root, i.ToString(), value);
			if (either.isA()) {
				Debug.Log("失敗しました。");
			}
			editor1 = either.b ();

			Either<Error, JungleTreeEditor> r = editor1.success();
			if (!r.isA()) {
				Debug.Log("失敗しました。");
			}
			r.b();
		}
		check_time = Time.realtimeSinceStartup - check_time;
		print ("処理時間 : " + check_time);

		TreeNode node = t.getRootNode();
		for (int i = 0; i < COUNT; i++) {
			byte[] v = node.getAttributes ().get (i.ToString());
			print (BitConverter.ToInt32 (v, 0));
		}
	}

}