Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 212:bdfd1e7c8bb7
minner change
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/list/DefaultNode.java Tue Aug 04 07:54:30 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/list/DefaultNode.java Tue Aug 04 09:54:01 2015 +0900 @@ -57,7 +57,7 @@ return new DefaultNode(this.attribute, this.next.getNext()); } - Node<T> newNode = next.delete(currentNum, deleteNum); + Node<T> newNode = next.delete(currentNum + 1, deleteNum); if (newNode == null) return null;
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/list/List.java Tue Aug 04 07:54:30 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/list/List.java Tue Aug 04 09:54:01 2015 +0900 @@ -97,7 +97,6 @@ Node<T> newNode = head.delete(0, num); if (newNode == null) return this; - Node<T> newHead = new headNode<>(newNode); return new List<T>(newNode); } @@ -108,8 +107,8 @@ return new List<T>(newHead); } - public T last() { - return head.getNext().getAttribute(); + public T tail() { + return index(length() - 1); } public T head() {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/impl/DefaultTreeEditor.java Tue Aug 04 07:54:30 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/impl/DefaultTreeEditor.java Tue Aug 04 09:54:01 2015 +0900 @@ -48,7 +48,7 @@ } // target - Direction<TreeNode> targetDirection = path.last(); + Direction<TreeNode> targetDirection = path.head(); TreeNode target = targetDirection.getTarget(); Either<Error,LoggingNode> either = editor.edit(target); if(either.isA()){
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/DefaultEvaluator.java Tue Aug 04 07:54:30 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/DefaultEvaluator.java Tue Aug 04 09:54:01 2015 +0900 @@ -27,7 +27,7 @@ if (head == _pos) { result = Result.ACCEPT; nextEvaluator = new DefaultEvaluator(pop.right()); - } else if (_pos < _current.getChildren().size() - 1) { + } else if (_pos > _current.getChildren().size() - 1) { result = Result.BREAK; nextEvaluator = null; } else {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/DefaultTraverser.java Tue Aug 04 07:54:30 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/traverser/DefaultTraverser.java Tue Aug 04 09:54:01 2015 +0900 @@ -47,7 +47,7 @@ List<Direction<TreeNode>> list = ret.b(); final Iterable<Direction<TreeNode>> iterable = list; - final TreeNode destination = ret.b().last().getTarget(); + final TreeNode destination = ret.b().head().getTarget(); Traversal traversal = new Traversal() { @Override
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/impl/treeeditor/DefaultTreeEditorTest.java Tue Aug 04 07:54:30 2015 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/core/impl/treeeditor/DefaultTreeEditorTest.java Tue Aug 04 09:54:01 2015 +0900 @@ -34,7 +34,7 @@ DefaultTreeEditor currentEditor = editor; String key = "path"; - String aaa = root.getChildren().at(0).b().getAttributes().getString(key); + TreeNode currentRoot = root; for (DefaultNodePath part : path.inits()) { String str = part.toString();
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/traverse/TraverserTest.java Tue Aug 04 07:54:30 2015 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/jungle/traverse/TraverserTest.java Tue Aug 04 09:54:01 2015 +0900 @@ -1,35 +1,29 @@ -/* -package jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverse; +package jp.ac.u_ryukyu.ie.cr.jungle.traverse; + -import List; -import NodePath; -import DefaultNodePath; -import TreeNode; -import DefaultTreeNode; -import DefaultEvaluator; -import Direction; -import Traversal; -import Traverser; -import Either; -import Error; +import jp.ac.u_ryukyu.ie.cr.jungle.data.list.List; +import jp.ac.u_ryukyu.ie.cr.jungle.store.NodePath; +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.DefaultNodePath; +import jp.ac.u_ryukyu.ie.cr.jungle.store.impl.TreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.transaction.DefaultTreeNode; +import jp.ac.u_ryukyu.ie.cr.jungle.traverser.*; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Either; +import jp.ac.u_ryukyu.ie.cr.jungle.util.Error; +import junit.framework.Assert; import junit.framework.TestCase; -import org.junit.Assert; import java.nio.ByteBuffer; -public abstract class TraverserTest extends TestCase +public class TraverserTest extends TestCase { - public abstract Traverser instance(); public void testTraverse() { int maxHeight = 3; - TreeNode root = createTree(0,0,maxHeight,new DefaultNodePath()); - //TraversableNodeWrapper<DefaultTreeNode> traversable = new TraversableNodeWrapper<DefaultTreeNode>(root); - Traverser traverser = instance(); + TreeNode root = createTree(0,0,maxHeight,new DefaultNodePath()); + Traverser traverser = new DefaultTraverser(); - // generate all pattern. List<DefaultNodePath> paths = generatePathPattern(new DefaultNodePath(),0,maxHeight); paths = paths.addLast(new DefaultNodePath()); @@ -50,8 +44,8 @@ List<DefaultNodePath> parts = path.inits(); for(Direction<TreeNode> d : traversal){ - DefaultNodePath part = parts.head(); - parts = parts.last(); + DefaultNodePath part = parts.tail(); + parts = parts.delete(parts.length() - 1); value = d.getTarget().getAttributes().get(key); String actualCurrentPathStr = new String(value.array()); String expectCurrentPathStr = part.toString(); @@ -62,14 +56,14 @@ public List<DefaultNodePath> generatePathPattern(DefaultNodePath _cur,int _curHeight,int _maxHeight) { - List<DefaultNodePath> paths = List.nil(); + List<DefaultNodePath> paths = new List(); for(int p = 0;p <= _curHeight;p ++){ DefaultNodePath path = _cur.add(p); if(_curHeight != _maxHeight - 1){ List<DefaultNodePath> newpaths = generatePathPattern(path,_curHeight+1,_maxHeight); paths = paths.append(newpaths); } - paths = paths.cons(path); + paths = paths.addLast(path); } return paths; @@ -105,4 +99,3 @@ return parent; } } -*/ \ No newline at end of file
--- a/src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/treemap/TreeMapDelete.java Tue Aug 04 07:54:30 2015 +0900 +++ b/src/test/java/jp/ac/u_ryukyu/ie/cr/tatsuki/treemap/TreeMapDelete.java Tue Aug 04 09:54:01 2015 +0900 @@ -17,7 +17,7 @@ TreeMap<Integer, Integer> map = new TreeMap(); for (int count = 1; count < 1000; count++) { map = map.put(count, count); - map.checkDepth(); + // map.checkDepth(); } ArrayList<Integer> list = new ArrayList(); @@ -29,7 +29,7 @@ System.out.println(num); TreeMap newMap = map.delete(num); map = newMap; - map.checkDepth(); + // map.checkDepth(); } System.out.println("end"); }