MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / deleteNode

Method deleteNode

vm/JavaAPI/src/java/util/TreeMap.java:5037–5073  ·  view source on GitHub ↗
(Node<K, V> node)

Source from the content-addressed store, hash-verified

5035 }
5036
5037 private void deleteNode(Node<K, V> node) {
5038 if (node.right == null) {
5039 if (node.left != null) {
5040 attachToParent(node, node.left);
5041 } else {
5042 attachNullToParent(node);
5043 }
5044 fixNextChain(node);
5045 } else if(node.left == null) { // node.right != null
5046 attachToParent(node, node.right);
5047 fixNextChain(node);
5048 } else {
5049 // Here node.left!=nul && node.right!=null
5050 // node.next should replace node in tree
5051 // node.next!=null by tree logic.
5052 // node.next.left==null by tree logic.
5053 // node.next.right may be null or non-null
5054 Node<K, V> toMoveUp = node.next;
5055 fixNextChain(node);
5056 if(toMoveUp.right==null){
5057 attachNullToParent(toMoveUp);
5058 } else {
5059 attachToParent(toMoveUp, toMoveUp.right);
5060 }
5061 // Here toMoveUp is ready to replace node
5062 toMoveUp.left = node.left;
5063 if (node.left != null) {
5064 node.left.parent = toMoveUp;
5065 }
5066 toMoveUp.right = node.right;
5067 if (node.right != null) {
5068 node.right.parent = toMoveUp;
5069 }
5070 attachToParentNoFixup(node,toMoveUp);
5071 toMoveUp.color = node.color;
5072 }
5073 }
5074
5075 private void attachToParentNoFixup(Node<K, V> toDelete, Node<K, V> toConnect) {
5076 // assert toConnect!=null

Callers 3

removeLeftmostMethod · 0.95
removeRightmostMethod · 0.95
removeMiddleElementMethod · 0.95

Calls 4

attachToParentMethod · 0.95
attachNullToParentMethod · 0.95
fixNextChainMethod · 0.95
attachToParentNoFixupMethod · 0.95

Tested by

no test coverage detected