Mercurial > hg > Members > tatsuki > bench > jungle-core
changeset 150:1432adf6f490
add ParentIndex.java
author | one |
---|---|
date | Sat, 22 Nov 2014 12:54:28 +0900 |
parents | feb2346ace19 |
children | d9fbddf77bf6 |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/ParentIndex.java |
diffstat | 1 files changed, 43 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/store/index/ParentIndex.java Sat Nov 22 12:54:28 2014 +0900 @@ -0,0 +1,43 @@ +package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.TreeMapOrd; +import fj.data.Option; +import fj.data.TreeMap; + +public class ParentIndex { + + private final TreeMap<TreeNode, TreeNode> parentIndex; + + public ParentIndex() { + parentIndex = TreeMap.empty(TreeMapOrd.treeNodeOrd); + } + + public ParentIndex(TreeMap<TreeNode, TreeNode> parentIndex) { + this.parentIndex = parentIndex; + } + + public ParentIndex(ParentIndex parentIndex) { + this.parentIndex = parentIndex.getParentIndex(); + } + + private TreeMap<TreeNode, TreeNode> getParentIndex() { + return parentIndex; + } + + public Option<TreeNode> get(TreeNode child) { + Option<TreeNode> parentOp = parentIndex.get(child); + return parentOp; + } + + public ParentIndex set(TreeNode child, TreeNode parent){ + TreeMap<TreeNode, TreeNode> newParentIndex = parentIndex.set(child,parent); + return new ParentIndex(newParentIndex); + } + + public ParentIndex delete(TreeNode child) { + TreeMap<TreeNode, TreeNode> newParentIndex = parentIndex.delete(child); + return new ParentIndex(newParentIndex); + } + +}