Mercurial > hg > Members > shoshi > jungle > jungle-core
changeset 296:16c0e2b625dc
tmp
author | tatsuki |
---|---|
date | Wed, 04 Jan 2017 20:03:41 +0900 |
parents | 1a5f3d3f3437 |
children | 1f929fe9c153 |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/redBlackTree/BlackTreeNode.java src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/redBlackTree/ColorlessTreeNode.java |
diffstat | 2 files changed, 43 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/redBlackTree/BlackTreeNode.java Wed Jan 04 19:12:26 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/redBlackTree/BlackTreeNode.java Wed Jan 04 20:03:41 2017 +0900 @@ -113,4 +113,9 @@ return minCount; } + @Override + protected RebuildNode replaceNode(ColorlessTreeNode parent) { + return null; + } + }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/redBlackTree/ColorlessTreeNode.java Wed Jan 04 19:12:26 2017 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/transaction/node/redBlackTree/ColorlessTreeNode.java Wed Jan 04 20:03:41 2017 +0900 @@ -77,14 +77,13 @@ ColorlessTreeNode newNode = rightChild.addNewChild(insertKey, insertValue); newNode = createNode(getAttrs(), key(), value(), left(), newNode); return newNode.insBalance(); - } else - if (result < 0) { - ColorlessTreeNode newNode = leftChild.addNewChild(insertKey, insertValue); - newNode = createNode(getAttrs(), key(), value(), newNode, right()); - return newNode.insBalance(); - } else { - return null; - } + } else if (result < 0) { + ColorlessTreeNode newNode = leftChild.addNewChild(insertKey, insertValue); + newNode = createNode(getAttrs(), key(), value(), newNode, right()); + return newNode.insBalance(); + } else { + return null; + } } protected abstract ColorlessTreeNode insBalance(); @@ -105,23 +104,39 @@ int result = this.compare(insertValue); if (result > 0) { rebuildNode = right().delete(insertKey, insertValue, this, Rotate.R); - } else - if (result < 0) { - rebuildNode = left().delete(insertKey, insertValue, this, Rotate.L); - } else { - rebuildNode = replaceNode(parent); - if (parent == null || rebuildNode == null) - return rebuildNode; - ColorlessTreeNode node = rebuildNode.getNode(); - if (rebuildNode.rebuild()) { - // return node.deleteBalance(parent); - } - } return null; + } else if (result < 0) { + rebuildNode = left().delete(insertKey, insertValue, this, Rotate.L); + } else { + rebuildNode = replaceNode(parent); + } + if (parent == null || rebuildNode == null) + return rebuildNode; + + ColorlessTreeNode node = rebuildNode.getNode(); + if (rebuildNode.rebuild()) { + return node.deleteBalance(parent); + } + ColorlessTreeNode newParent; + if (side == Rotate.L) + newParent = parent.createNode(parent.getAttrs(), parent.key(), parent.value(), node, parent.right()); + else + newParent = parent.createNode(parent.getAttrs(), parent.key(), parent.value(), parent.left(), node); + + return new RebuildNode(false, newParent); } - return null; + return null; } - protected RebuildNode replaceNode(ColorlessTreeNode parent) { - return null; + + public RebuildNode deleteBalance(ColorlessTreeNode parent) { + ColorlessTreeNode newNode = null; + if (!isRed()) { + + } + return null; + } + + protected RebuildNode replaceNode(ColorlessTreeNode parent) { + return null; } }