Mercurial > hg > Database > jungle-sharp
changeset 6:4d08270a61c8
fix
line wrap: on
line diff
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/DefaultJungle.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/DefaultJungle.cs Tue Jul 19 16:47:43 2016 +0900 @@ -5,7 +5,7 @@ public class DefaultJungle : Jungle { private Journal journal; - private Dictionary<string, JungleTree> trees; + private Dictionary <string, JungleTree> trees; // ここかな? private string uuid; private TreeEditor editor; @@ -30,7 +30,6 @@ this.editor = editor; } - public JungleTree getTreeByName(string name) { JungleTree j = trees[name]; @@ -49,11 +48,7 @@ InterfaceTraverser traverser = new InterfaceTraverser (root, true); TreeContext tc = new DefaultTreeContext (root, null, list, uuid, name, 0, traverser); JungleTree newTree = new DefaultJungleTree (tc, uuid, journal.getWriter (), editor); - trees.Add (name, newTree); - // Trees.getValue => nullの時 ここはどう書けば? -// if (trees.TryGetValue (name, newTree) != null) { -// return null; -// } + trees.Add (name, newTree); // ここが間違ってるかも return newTree; }
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/JungleTreeEditor.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/JungleTreeEditor.cs Tue Jul 19 16:47:43 2016 +0900 @@ -2,7 +2,7 @@ public interface JungleTreeEditor { Either<Error,JungleTreeEditor> addNewChildAt(NodePath path,int pos); Either<Error,JungleTreeEditor> deleteChildAt(NodePath path,int pos); - Either<Error,JungleTreeEditor> putAttribute(NodePath path,string key, GameObject value); + Either<Error,JungleTreeEditor> putAttribute(NodePath path,string key, byte value); Either<Error,JungleTreeEditor> deleteAttribute(NodePath path,string key); Either<Error, JungleTreeEditor> replaceNewRootNode(); Either<Error,JungleTreeEditor> edit(NodePath path,NodeEditor editor);
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/core/Attributes.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/core/Attributes.cs Tue Jul 19 16:47:43 2016 +0900 @@ -1,5 +1,5 @@ using UnityEngine; public interface Attributes{ - GameObject get (string key); + byte get (string key); string getString (string key); }
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/data/list/DefaultNode.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/data/list/DefaultNode.cs Tue Jul 19 16:47:43 2016 +0900 @@ -12,13 +12,6 @@ this.next = next; } -// public DefaultNode(Node<T> attribute1, TailNode<T> tailNode) -// { -// this.attribute1 = attribute1; -// this.tailNode = tailNode; -// } - - public Node<T> getNext() { return next; }
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/data/treemap/EmptyNode.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/data/treemap/EmptyNode.cs Tue Jul 19 16:47:43 2016 +0900 @@ -28,7 +28,7 @@ return false; } - public override TreeMapNode<K,V> createNode(K k,V value,TreeMapNode<K,V> left, TreeMapNode<K,V> right){ + public override TreeMapNode<K,V> createNode(K key,V value,TreeMapNode<K,V> left, TreeMapNode<K,V> right){ return new RedNode<K,V> (key, value, new EmptyNode<K,V> (), new EmptyNode<K,V> ()); }
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/data/treemap/TreeMap.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/data/treemap/TreeMap.cs Tue Jul 19 16:47:43 2016 +0900 @@ -50,7 +50,7 @@ } public TreeMap<K, V> delete(K key) { - if (key == null) { + if (key.Equals(default(K))) { return this; } rebuildNode<K, V> rootRebuildNode = root.delete (key, null, this.comparator, Rotate.N);
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/impl/TreeNodeAttributes.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/impl/TreeNodeAttributes.cs Tue Jul 19 16:47:43 2016 +0900 @@ -1,8 +1,8 @@ using System.Collections.Generic; using UnityEngine; public interface TreeNodeAttributes : Attributes { - Either<Error,TreeNode> delete(string key); - Either<Error,TreeNode> put(string key, GameObject value); - TreeMap<string,GameObject> getAttributesAsRawMap(); + Either<Error, TreeNode> delete(string key); + Either<Error, TreeNode> put(string key, byte value); + TreeMap<string, byte> getAttributesAsRawMap(); IEnumerator<string> getKeys(); }
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/impl/logger/LoggingAttributes.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/impl/logger/LoggingAttributes.cs Tue Jul 19 16:47:43 2016 +0900 @@ -11,7 +11,7 @@ log = _log; } - public GameObject get(string _key) + public byte get(string _key) { TreeNodeAttributes attributes = wrap.getAttributes(); return attributes.get(_key); @@ -39,7 +39,7 @@ return edit(deleteAttribute); } - public Either<Error,LoggingNode> put(string _key, GameObject _value) + public Either<Error,LoggingNode> put(string _key, byte _value) { PutAttributeOperation putAttribute = new PutAttributeOperation(_key,_value); return edit(putAttribute);
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/operations/AppendChildAtOperation.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/operations/AppendChildAtOperation.cs Tue Jul 19 16:47:43 2016 +0900 @@ -30,9 +30,9 @@ return null; } - public GameObject getValue() + public byte getValue() { - return null; + return 0; } }
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/operations/DeleteAttributeOperation.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/operations/DeleteAttributeOperation.cs Tue Jul 19 16:47:43 2016 +0900 @@ -25,8 +25,8 @@ return key; } - public GameObject getValue() { - return null; + public byte getValue() { + return 0; } }
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/operations/DeleteChildAtOperation.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/operations/DeleteChildAtOperation.cs Tue Jul 19 16:47:43 2016 +0900 @@ -31,9 +31,9 @@ return null; } - public GameObject getValue() + public byte getValue() { - return null; + return 0; } }
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/operations/NodeOperation.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/operations/NodeOperation.cs Tue Jul 19 16:47:43 2016 +0900 @@ -4,5 +4,5 @@ Either<Error,TreeNode> invoke (TreeNode _target); int getPosition(); string getKey(); - GameObject getValue(); + byte getValue(); }
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/operations/PutAttributeOperation.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/operations/PutAttributeOperation.cs Tue Jul 19 16:47:43 2016 +0900 @@ -2,9 +2,9 @@ public class PutAttributeOperation : NodeOperation { private string key; - private GameObject value; + private byte value; - public PutAttributeOperation(string _key,GameObject _value) + public PutAttributeOperation(string _key, byte _value) { key = _key; value = _value; @@ -30,7 +30,7 @@ return key; } - public GameObject getValue() + public byte getValue() { return value; }
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/operations/ReplaceRootNodeOperation.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/operations/ReplaceRootNodeOperation.cs Tue Jul 19 16:47:43 2016 +0900 @@ -20,8 +20,8 @@ return null; } - public GameObject getValue() { - return null; + public byte getValue() { + return 0; } }
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/transformer/PutAttribute.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/store/transformer/PutAttribute.cs Tue Jul 19 16:47:43 2016 +0900 @@ -3,9 +3,9 @@ public class PutAttribute : NodeEditor { private string key; - private GameObject value; + private byte value; - public PutAttribute(string _key,GameObject _value) + public PutAttribute(string _key, byte _value) { key = _key; value = _value;
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/transaction/DefaultJungleTreeEditor.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/transaction/DefaultJungleTreeEditor.cs Tue Jul 19 16:47:43 2016 +0900 @@ -65,7 +65,7 @@ return _edit(_path,deleteChildAt); } - public Either<Error, JungleTreeEditor> putAttribute(NodePath _path, string _key, GameObject _value) { + public Either<Error, JungleTreeEditor> putAttribute(NodePath _path, string _key, byte _value) { PutAttribute putAttribute = new PutAttribute (_key, _value); return _edit (_path, putAttribute); }
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/transaction/DefaultTreeNode.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/transaction/DefaultTreeNode.cs Tue Jul 19 16:47:43 2016 +0900 @@ -1,17 +1,17 @@ using UnityEngine; public class DefaultTreeNode : TreeNode { private List<TreeNode> children; - private TreeMap<string,GameObject> attrs; + private TreeMap<string,byte> attrs; // string nodeId = new VMID().toString(); - private static List<TreeNode> NIL_LIST = new List<TreeNode>(); + private static readonly List<TreeNode> NIL_LIST = new List<TreeNode>(); public DefaultTreeNode() - : this (NIL_LIST, new TreeMap<string,GameObject> ()) + : this (NIL_LIST, new TreeMap<string,byte> ()) { } - public DefaultTreeNode(List<TreeNode> _children, TreeMap<string, GameObject> _attrs) { + public DefaultTreeNode(List<TreeNode> _children, TreeMap<string, byte> _attrs) { attrs = _attrs; children = _children; } @@ -33,7 +33,7 @@ } public Either<Error, TreeNode> appendRootNode() { - TreeNodeChildren newRootChildren = new DefaultTreeNodeChildren(NIL_LIST, new TreeMap<string,GameObject>()); + TreeNodeChildren newRootChildren = new DefaultTreeNodeChildren(NIL_LIST, new TreeMap<string, byte>()); Either<Error, TreeNode> either = newRootChildren.addNewChildAt(0,this); return either; }
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/transaction/DefaultTreeNodeAttribute.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/transaction/DefaultTreeNodeAttribute.cs Tue Jul 19 16:47:43 2016 +0900 @@ -6,14 +6,14 @@ public class DefaultTreeNodeAttribute : TreeNodeAttributes { public List<TreeNode> children; - public TreeMap<string,GameObject> attrs; + public TreeMap<string, byte> attrs; - public DefaultTreeNodeAttribute(List<TreeNode> _children, TreeMap<string,GameObject> _attrs){ + public DefaultTreeNodeAttribute(List<TreeNode> _children, TreeMap<string, byte> _attrs){ children = _children; // null? attrs = _attrs; } - public TreeMap<string, GameObject> getAttributesAsRawMap(){ + public TreeMap<string, byte> getAttributesAsRawMap(){ return attrs; } @@ -26,35 +26,35 @@ return DefaultEither<Error,TreeNode>.newA(NodeEditorError.DELETE_KEY_NOT_FOUND); } - TreeMap<string, GameObject> newMap = attrs.delete(_key); + TreeMap<string, byte> newMap = attrs.delete(_key); TreeNode newNode = new DefaultTreeNode(children, newMap); return DefaultEither<Error,TreeNode>.newB(newNode); } - public Either<Error, TreeNode> put(string _key, GameObject _value){ + public Either<Error, TreeNode> put(string _key, byte _value){ if (_key == null || _value == null) { return DefaultEither<Error, TreeNode>.newA (NodeEditorError.NULL_VALUE_NOT_ALLOWED); } - TreeMap<string, GameObject> newMap = attrs.put (_key, _value); + TreeMap<string, byte> newMap = attrs.put (_key, _value); TreeNode newNode = new DefaultTreeNode (children, newMap); return DefaultEither<Error, TreeNode>.newB (newNode); } - public GameObject get(string _key) { + public byte get(string _key) { if (_key == null) { - return null; + return 0; } - GameObject op = attrs.get(_key); //null + byte op = attrs.get(_key); //null if (op != null) { - return op.gameObject; + return op; } - return null; + return 0; } - public string getString(string key , Encoding enc) { + public string getString(string key, Encoding enc) { char[] attribute = key.ToCharArray(); if (attribute != null){ return new string(attribute);
--- a/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/transaction/DefaultTreeNodeChildren.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/transaction/DefaultTreeNodeChildren.cs Tue Jul 19 16:47:43 2016 +0900 @@ -4,9 +4,9 @@ public class DefaultTreeNodeChildren : TreeNodeChildren { public List<TreeNode> children; - public TreeMap<string, GameObject> attrs; + public TreeMap<string, byte> attrs; - public DefaultTreeNodeChildren(List<TreeNode> _children, TreeMap<string, GameObject> _attrs){ + public DefaultTreeNodeChildren(List<TreeNode> _children, TreeMap<string, byte> _attrs){ children = _children; attrs = _attrs; }
--- a/src/test/csharp/DefaultJungleTreeTest.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/test/csharp/DefaultJungleTreeTest.cs Tue Jul 19 16:47:43 2016 +0900 @@ -10,19 +10,22 @@ return j; } - public static string key = "KEY"; - public GameObject value; + public string key = "moumou"; + private byte value = 1; void Start() { Jungle j = instance (); - JungleTree tree = j.createNewTree ("tree"); // hogeの中にtreeという名前の木を作る - + j.createNewTree ("tree"); // hogeの中にtreeという名前の木を作る + JungleTree tree = j.getTreeByName("tree"); + if (Equals (0, tree.revision ())) { + Debug.Log ("error!"); + } JungleTreeEditor editor1 = tree.getTreeEditor (); // editor - DefaultNodePath path = new DefaultNodePath (); + DefaultNodePath root = new DefaultNodePath (); // NodePath path; - Either<Error, JungleTreeEditor> either = editor1.putAttribute (path, key, value); + Either<Error, JungleTreeEditor> either = editor1.putAttribute (root, key, value); if (either.isA ()) { // 失敗した場合のコード Debug.Log ("失敗しました。"); } @@ -30,9 +33,7 @@ editor1.success (); // 大本にあるTreeにここで変更を加える TreeNode node = tree.getRootNode (); - Debug.Log (node); - Debug.Log (node.getAttributes ().getKeys ()); - GameObject v = node.getAttributes ().get (key); + byte v = node.getAttributes ().get (key); Debug.Log (v); }
--- a/src/test/csharp/jp.ac.u-ryukyu.ie.cr/data/treemap/TreeMapDelete.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/test/csharp/jp.ac.u-ryukyu.ie.cr/data/treemap/TreeMapDelete.cs Tue Jul 19 16:47:43 2016 +0900 @@ -1,5 +1,4 @@ using UnityEngine; -using System.Collections; public class TreeMapDelete : MonoBehaviour { @@ -7,20 +6,18 @@ void Start () { TreeMap<int,int> map = new TreeMap<int, int> (); for (int count = 1; count < 6; count++) { - Debug.Log (count); map = map.put (count, count); - int val = map.get(count); - //Debug.Log ("value : " + val); map.checkDepth (); } // ただ消すための数字をここに入れているだけ - List<int> list = new List<int>(5); - for (int i = 1; i < 5; i++) { - list.addLast (i); + List<int> list = new List<int>(); + for (int count = 1; count < 6; count++) { + list = list.addLast (count); } foreach(int num in list){ + Debug.Log(num); map = map.delete(num); map.checkDepth(); }
--- a/src/test/csharp/jp.ac.u-ryukyu.ie.cr/data/treemap/TreeMapTest.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/test/csharp/jp.ac.u-ryukyu.ie.cr/data/treemap/TreeMapTest.cs Tue Jul 19 16:47:43 2016 +0900 @@ -24,7 +24,12 @@ // if (checknull){ // Debug.Log(map.get()); // } - + for(int count = 5; count > -10; count--){ + int op = map.get(count); + if(op != null) { + Debug.Log("op " + op); + } + } Debug.Log ("end"); }
--- a/src/test/csharp/jp.ac.u-ryukyu.ie.cr/jungle/core/nodeeditor/PutAttributeTest.cs Tue Jul 05 07:20:41 2016 +0900 +++ b/src/test/csharp/jp.ac.u-ryukyu.ie.cr/jungle/core/nodeeditor/PutAttributeTest.cs Tue Jul 19 16:47:43 2016 +0900 @@ -4,7 +4,7 @@ public class PutAttributeTest : MonoBehaviour { string key = "hoge"; - public GameObject value; + public byte value; // Use this for initialization void Start () { @@ -17,7 +17,7 @@ } LoggingNode newnode = either.b (); Debug.Log (newnode); - GameObject ret = newnode.getAttributes ().get (key); + byte ret = newnode.getAttributes ().get (key); Debug.Log ("insertしたものは" + ret); }