mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix bug
This commit is contained in:
parent
81cbb0d8a0
commit
04b6c3bcdc
@ -128,9 +128,10 @@ public class LinkedForestMap<K, V> implements ForestMap<K, V> {
|
|||||||
// 2.将目标的子节点直接将目标的父节点作为父节点
|
// 2.将目标的子节点直接将目标的父节点作为父节点
|
||||||
if (target.hasParent()) {
|
if (target.hasParent()) {
|
||||||
final TreeEntryNode<K, V> parent = target.getDeclaredParent();
|
final TreeEntryNode<K, V> parent = target.getDeclaredParent();
|
||||||
|
final Map<K, TreeEntry<K, V>> targetChildren = target.getChildren();
|
||||||
parent.removeDeclaredChild(target.getKey());
|
parent.removeDeclaredChild(target.getKey());
|
||||||
target.getDeclaredChildren()
|
target.clear();
|
||||||
.forEach((k, c) -> parent.addChild((TreeEntryNode<K, V>)c));
|
targetChildren.forEach((k, c) -> parent.addChild((TreeEntryNode<K, V>)c));
|
||||||
}
|
}
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
@ -577,6 +578,7 @@ public class LinkedForestMap<K, V> implements ForestMap<K, V> {
|
|||||||
), null);
|
), null);
|
||||||
|
|
||||||
// 调整该节点的信息
|
// 调整该节点的信息
|
||||||
|
child.parent = this;
|
||||||
child.traverseChildNodes(true, (i, c) -> {
|
child.traverseChildNodes(true, (i, c) -> {
|
||||||
c.root = getRoot();
|
c.root = getRoot();
|
||||||
c.weight = i + getWeight() + 1;
|
c.weight = i + getWeight() + 1;
|
||||||
@ -598,14 +600,13 @@ public class LinkedForestMap<K, V> implements ForestMap<K, V> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 断开该节点与其父节点的关系
|
// 断开该节点与其父节点的关系
|
||||||
child.getDeclaredParent().children.remove(key);
|
this.children.remove(key);
|
||||||
|
|
||||||
// 将子节点从当前节点中移除,并重置子节点及其下属节点的相关属性
|
// 重置子节点及其下属节点的相关属性
|
||||||
children.remove(child.getKey());
|
|
||||||
child.parent = null;
|
child.parent = null;
|
||||||
child.traverseChildNodes(true, (index, node) -> {
|
child.traverseChildNodes(true, (i, c) -> {
|
||||||
node.root = child;
|
c.root = child;
|
||||||
node.weight = index;
|
c.weight = i;
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ public interface TreeEntry<K, V> extends Map.Entry<K, V> {
|
|||||||
* @return 是否
|
* @return 是否
|
||||||
*/
|
*/
|
||||||
default boolean hasChildren() {
|
default boolean hasChildren() {
|
||||||
return CollUtil.isEmpty(getDeclaredChildren());
|
return CollUtil.isNotEmpty(getDeclaredChildren());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user