diff src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/nodepath/RedBlackTreeNodePath.java @ 310:474728dcfdb8

add PathType
author tatsuki
date Thu, 26 Jan 2017 23:44:14 +0900
parents f8e75ef7ac5d
children a0529572fbcb
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/nodepath/RedBlackTreeNodePath.java	Thu Jan 26 16:19:51 2017 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/store/nodepath/RedBlackTreeNodePath.java	Thu Jan 26 23:44:14 2017 +0900
@@ -11,36 +11,24 @@
 
     private final String key;
     private final ByteBuffer value;
-    /**
-     * traverserを使うかどうかのフラグ
-     * -2だった場合Traverserを使わない
-     * 主にノードの追加、削除等回転処理が行われる処理の場合に使う
-     * <p>
-     * それ以外の値だった場合Traverserを使う
-     * Attribute関係とか
-     * intの理由はgetで受け取れるから
-     * <p>
-     * flagはaddでセットする
-     * ココらへんは後でちゃんと直す
-     */
-    private int flags;
+    private final PathType type;
 
     public RedBlackTreeNodePath() {
         this.key = "default";
         this.value = ByteBuffer.wrap("default".getBytes());
-        this.flags = -2;
+        this.type = PathType.RedBlack;
     }
 
     public RedBlackTreeNodePath(String key, ByteBuffer value) {
         this.key = key;
         this.value = value;
-        this.flags = -2;
+        this.type = PathType.RedBlack;
     }
 
-    private RedBlackTreeNodePath(String key, ByteBuffer value, int flags) {
+    private RedBlackTreeNodePath(String key, ByteBuffer value, PathType type) {
         this.key = key;
         this.value = value;
-        this.flags = flags;
+        this.type = type;
     }
 
     @Override
@@ -55,7 +43,12 @@
 
     @Override
     public PathType getPathType() {
-        return PathType.RedBlack;
+        return type;
+    }
+
+    @Override
+    public NodePath setType(PathType type) {
+        return new RedBlackTreeNodePath(this.getKey(), this.getValue(), type);
     }
 
     //以下使わない
@@ -66,12 +59,12 @@
 
     @Override
     public int get(int index) {
-        return flags;
+        return -2;
     }
 
     @Override
     public NodePath add(int pos) {
-        return new RedBlackTreeNodePath(key, value, pos);
+        return null;
     }
 
     @Override