Mercurial > hg > Database > jungle-sharp
changeset 8:d132d442dc34
List fix and Code delete
author | Kazuma |
---|---|
date | Wed, 12 Oct 2016 22:56:14 +0900 |
parents | 02b2ab7bffe6 |
children | e6ad9016601c |
files | src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/data/list/List.cs src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/impl/DefaultNodePath.cs src/test/csharp/jp.ac.u-ryukyu.ie.cr/DefaultJungleTreeTest.cs |
diffstat | 3 files changed, 63 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/data/list/List.cs Tue Sep 27 18:36:05 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/data/list/List.cs Wed Oct 12 22:56:14 2016 +0900 @@ -55,8 +55,7 @@ public IEnumerator<T> iterator() { Node<T> currentNode = head.getNext(); - while (currentNode.getAttribute() != null) { - Debug.Log (currentNode.getAttribute ().ToString()); + while (currentNode != null) { yield return (T)currentNode.getAttribute(); currentNode = currentNode.getNext (); } @@ -109,12 +108,6 @@ return head.length(); } - public string toString() { - //IEnumerator<T> iterator = reverseIterator(); - // pathString += ">"; - return "toString"; - } - public List<T> append(List<T> list) { IEnumerator<T> iterator = list.iterator(); List<T> newList = this; @@ -124,12 +117,4 @@ } return newList; } - -// public IEnumerator<T> iterator() { -// Node<T> currentNode = head.getNext(); -// while (currentNode != null) { -// yield return currentNode; -// currentNode = currentNode.getNext(); -// } -// } }
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/impl/DefaultNodePath.cs Tue Sep 27 18:36:05 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/impl/DefaultNodePath.cs Wed Oct 12 22:56:14 2016 +0900 @@ -50,7 +50,18 @@ } public override string ToString() { - return path.toString(); + string s = "List <"; + int list_count = this.path.length(); + int count = 0; + foreach(var i in this.path) { + if (count != list_count -1){ + s += i.ToString() + ","; + } else { + s += i.ToString(); + } + count++; + } + return s + ">"; } public int size() {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/csharp/jp.ac.u-ryukyu.ie.cr/DefaultJungleTreeTest.cs Wed Oct 12 22:56:14 2016 +0900 @@ -0,0 +1,50 @@ +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)); + } + } + +} \ No newline at end of file