java.util.TreeMap.replaceInParent()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中java.util.TreeMap.replaceInParent()方法的一些代码示例,展示了TreeMap.replaceInParent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeMap.replaceInParent()方法的具体详情如下:
包路径:java.util.TreeMap
类名称:TreeMap
方法名:replaceInParent

TreeMap.replaceInParent介绍

暂无

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Rotates the subtree so that its root's right child is the new root.
 */
private void rotateLeft(Node<K, V> root) {
  Node<K, V> left = root.left;
  Node<K, V> pivot = root.right;
  Node<K, V> pivotLeft = pivot.left;
  Node<K, V> pivotRight = pivot.right;
  // move the pivot's left child to the root's right
  root.right = pivotLeft;
  if (pivotLeft != null) {
    pivotLeft.parent = root;
  }
  replaceInParent(root, pivot);
  // move the root to the pivot's left
  pivot.left = root;
  root.parent = pivot;
  // fix heights
  root.height = Math.max(left != null ? left.height : 0,
      pivotLeft != null ? pivotLeft.height : 0) + 1;
  pivot.height = Math.max(root.height,
      pivotRight != null ? pivotRight.height : 0) + 1;
}

代码示例来源:origin: robovm/robovm

/**
 * Rotates the subtree so that its root's left child is the new root.
 */
private void rotateRight(Node<K, V> root) {
  Node<K, V> pivot = root.left;
  Node<K, V> right = root.right;
  Node<K, V> pivotLeft = pivot.left;
  Node<K, V> pivotRight = pivot.right;
  // move the pivot's right child to the root's left
  root.left = pivotRight;
  if (pivotRight != null) {
    pivotRight.parent = root;
  }
  replaceInParent(root, pivot);
  // move the root to the pivot's right
  pivot.right = root;
  root.parent = pivot;
  // fixup heights
  root.height = Math.max(right != null ? right.height : 0,
      pivotRight != null ? pivotRight.height : 0) + 1;
  pivot.height = Math.max(root.height,
      pivotLeft != null ? pivotLeft.height : 0) + 1;
}

代码示例来源:origin: robovm/robovm

replaceInParent(node, adjacent);
  return;
} else if (left != null) {
  replaceInParent(node, left);
  node.left = null;
} else if (right != null) {
  replaceInParent(node, right);
  node.right = null;
} else {
  replaceInParent(node, null);

代码示例来源:origin: MobiVM/robovm

/**
 * Rotates the subtree so that its root's right child is the new root.
 */
private void rotateLeft(Node<K, V> root) {
  Node<K, V> left = root.left;
  Node<K, V> pivot = root.right;
  Node<K, V> pivotLeft = pivot.left;
  Node<K, V> pivotRight = pivot.right;
  // move the pivot's left child to the root's right
  root.right = pivotLeft;
  if (pivotLeft != null) {
    pivotLeft.parent = root;
  }
  replaceInParent(root, pivot);
  // move the root to the pivot's left
  pivot.left = root;
  root.parent = pivot;
  // fix heights
  root.height = Math.max(left != null ? left.height : 0,
      pivotLeft != null ? pivotLeft.height : 0) + 1;
  pivot.height = Math.max(root.height,
      pivotRight != null ? pivotRight.height : 0) + 1;
}

代码示例来源:origin: ibinti/bugvm

/**
 * Rotates the subtree so that its root's right child is the new root.
 */
private void rotateLeft(Node<K, V> root) {
  Node<K, V> left = root.left;
  Node<K, V> pivot = root.right;
  Node<K, V> pivotLeft = pivot.left;
  Node<K, V> pivotRight = pivot.right;
  // move the pivot's left child to the root's right
  root.right = pivotLeft;
  if (pivotLeft != null) {
    pivotLeft.parent = root;
  }
  replaceInParent(root, pivot);
  // move the root to the pivot's left
  pivot.left = root;
  root.parent = pivot;
  // fix heights
  root.height = Math.max(left != null ? left.height : 0,
      pivotLeft != null ? pivotLeft.height : 0) + 1;
  pivot.height = Math.max(root.height,
      pivotRight != null ? pivotRight.height : 0) + 1;
}

代码示例来源:origin: com.jtransc/jtransc-rt

/**
 * Rotates the subtree so that its root's left child is the new root.
 */
private void rotateRight(Node<K, V> root) {
  Node<K, V> pivot = root.left;
  Node<K, V> right = root.right;
  Node<K, V> pivotLeft = pivot.left;
  Node<K, V> pivotRight = pivot.right;
  // move the pivot's right child to the root's left
  root.left = pivotRight;
  if (pivotRight != null) {
    pivotRight.parent = root;
  }
  replaceInParent(root, pivot);
  // move the root to the pivot's right
  pivot.right = root;
  root.parent = pivot;
  // fixup heights
  root.height = Math.max(right != null ? right.height : 0,
      pivotRight != null ? pivotRight.height : 0) + 1;
  pivot.height = Math.max(root.height,
      pivotLeft != null ? pivotLeft.height : 0) + 1;
}

代码示例来源:origin: ibinti/bugvm

/**
 * Rotates the subtree so that its root's left child is the new root.
 */
private void rotateRight(Node<K, V> root) {
  Node<K, V> pivot = root.left;
  Node<K, V> right = root.right;
  Node<K, V> pivotLeft = pivot.left;
  Node<K, V> pivotRight = pivot.right;
  // move the pivot's right child to the root's left
  root.left = pivotRight;
  if (pivotRight != null) {
    pivotRight.parent = root;
  }
  replaceInParent(root, pivot);
  // move the root to the pivot's right
  pivot.right = root;
  root.parent = pivot;
  // fixup heights
  root.height = Math.max(right != null ? right.height : 0,
      pivotRight != null ? pivotRight.height : 0) + 1;
  pivot.height = Math.max(root.height,
      pivotLeft != null ? pivotLeft.height : 0) + 1;
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Rotates the subtree so that its root's left child is the new root.
 */
private void rotateRight(Node<K, V> root) {
  Node<K, V> pivot = root.left;
  Node<K, V> right = root.right;
  Node<K, V> pivotLeft = pivot.left;
  Node<K, V> pivotRight = pivot.right;
  // move the pivot's right child to the root's left
  root.left = pivotRight;
  if (pivotRight != null) {
    pivotRight.parent = root;
  }
  replaceInParent(root, pivot);
  // move the root to the pivot's right
  pivot.right = root;
  root.parent = pivot;
  // fixup heights
  root.height = Math.max(right != null ? right.height : 0,
      pivotRight != null ? pivotRight.height : 0) + 1;
  pivot.height = Math.max(root.height,
      pivotLeft != null ? pivotLeft.height : 0) + 1;
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * Rotates the subtree so that its root's right child is the new root.
 */
private void rotateLeft(Node<K, V> root) {
  Node<K, V> left = root.left;
  Node<K, V> pivot = root.right;
  Node<K, V> pivotLeft = pivot.left;
  Node<K, V> pivotRight = pivot.right;
  // move the pivot's left child to the root's right
  root.right = pivotLeft;
  if (pivotLeft != null) {
    pivotLeft.parent = root;
  }
  replaceInParent(root, pivot);
  // move the root to the pivot's left
  pivot.left = root;
  root.parent = pivot;
  // fix heights
  root.height = Math.max(left != null ? left.height : 0,
      pivotLeft != null ? pivotLeft.height : 0) + 1;
  pivot.height = Math.max(root.height,
      pivotRight != null ? pivotRight.height : 0) + 1;
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Rotates the subtree so that its root's right child is the new root.
 */
private void rotateLeft(Node<K, V> root) {
  Node<K, V> left = root.left;
  Node<K, V> pivot = root.right;
  Node<K, V> pivotLeft = pivot.left;
  Node<K, V> pivotRight = pivot.right;
  // move the pivot's left child to the root's right
  root.right = pivotLeft;
  if (pivotLeft != null) {
    pivotLeft.parent = root;
  }
  replaceInParent(root, pivot);
  // move the root to the pivot's left
  pivot.left = root;
  root.parent = pivot;
  // fix heights
  root.height = Math.max(left != null ? left.height : 0,
      pivotLeft != null ? pivotLeft.height : 0) + 1;
  pivot.height = Math.max(root.height,
      pivotRight != null ? pivotRight.height : 0) + 1;
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * Rotates the subtree so that its root's left child is the new root.
 */
private void rotateRight(Node<K, V> root) {
  Node<K, V> pivot = root.left;
  Node<K, V> right = root.right;
  Node<K, V> pivotLeft = pivot.left;
  Node<K, V> pivotRight = pivot.right;
  // move the pivot's right child to the root's left
  root.left = pivotRight;
  if (pivotRight != null) {
    pivotRight.parent = root;
  }
  replaceInParent(root, pivot);
  // move the root to the pivot's right
  pivot.right = root;
  root.parent = pivot;
  // fixup heights
  root.height = Math.max(right != null ? right.height : 0,
      pivotRight != null ? pivotRight.height : 0) + 1;
  pivot.height = Math.max(root.height,
      pivotLeft != null ? pivotLeft.height : 0) + 1;
}

代码示例来源:origin: MobiVM/robovm

/**
 * Rotates the subtree so that its root's left child is the new root.
 */
private void rotateRight(Node<K, V> root) {
  Node<K, V> pivot = root.left;
  Node<K, V> right = root.right;
  Node<K, V> pivotLeft = pivot.left;
  Node<K, V> pivotRight = pivot.right;
  // move the pivot's right child to the root's left
  root.left = pivotRight;
  if (pivotRight != null) {
    pivotRight.parent = root;
  }
  replaceInParent(root, pivot);
  // move the root to the pivot's right
  pivot.right = root;
  root.parent = pivot;
  // fixup heights
  root.height = Math.max(right != null ? right.height : 0,
      pivotRight != null ? pivotRight.height : 0) + 1;
  pivot.height = Math.max(root.height,
      pivotLeft != null ? pivotLeft.height : 0) + 1;
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Rotates the subtree so that its root's left child is the new root.
 */
private void rotateRight(Node<K, V> root) {
  Node<K, V> pivot = root.left;
  Node<K, V> right = root.right;
  Node<K, V> pivotLeft = pivot.left;
  Node<K, V> pivotRight = pivot.right;
  // move the pivot's right child to the root's left
  root.left = pivotRight;
  if (pivotRight != null) {
    pivotRight.parent = root;
  }
  replaceInParent(root, pivot);
  // move the root to the pivot's right
  pivot.right = root;
  root.parent = pivot;
  // fixup heights
  root.height = Math.max(right != null ? right.height : 0,
      pivotRight != null ? pivotRight.height : 0) + 1;
  pivot.height = Math.max(root.height,
      pivotLeft != null ? pivotLeft.height : 0) + 1;
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Rotates the subtree so that its root's right child is the new root.
 */
private void rotateLeft(Node<K, V> root) {
  Node<K, V> left = root.left;
  Node<K, V> pivot = root.right;
  Node<K, V> pivotLeft = pivot.left;
  Node<K, V> pivotRight = pivot.right;
  // move the pivot's left child to the root's right
  root.right = pivotLeft;
  if (pivotLeft != null) {
    pivotLeft.parent = root;
  }
  replaceInParent(root, pivot);
  // move the root to the pivot's left
  pivot.left = root;
  root.parent = pivot;
  // fix heights
  root.height = Math.max(left != null ? left.height : 0,
      pivotLeft != null ? pivotLeft.height : 0) + 1;
  pivot.height = Math.max(root.height,
      pivotRight != null ? pivotRight.height : 0) + 1;
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Rotates the subtree so that its root's left child is the new root.
 */
private void rotateRight(Node<K, V> root) {
  Node<K, V> pivot = root.left;
  Node<K, V> right = root.right;
  Node<K, V> pivotLeft = pivot.left;
  Node<K, V> pivotRight = pivot.right;
  // move the pivot's right child to the root's left
  root.left = pivotRight;
  if (pivotRight != null) {
    pivotRight.parent = root;
  }
  replaceInParent(root, pivot);
  // move the root to the pivot's right
  pivot.right = root;
  root.parent = pivot;
  // fixup heights
  root.height = Math.max(right != null ? right.height : 0,
      pivotRight != null ? pivotRight.height : 0) + 1;
  pivot.height = Math.max(root.height,
      pivotLeft != null ? pivotLeft.height : 0) + 1;
}

代码示例来源:origin: com.jtransc/jtransc-rt

/**
 * Rotates the subtree so that its root's right child is the new root.
 */
private void rotateLeft(Node<K, V> root) {
  Node<K, V> left = root.left;
  Node<K, V> pivot = root.right;
  Node<K, V> pivotLeft = pivot.left;
  Node<K, V> pivotRight = pivot.right;
  // move the pivot's left child to the root's right
  root.right = pivotLeft;
  if (pivotLeft != null) {
    pivotLeft.parent = root;
  }
  replaceInParent(root, pivot);
  // move the root to the pivot's left
  pivot.left = root;
  root.parent = pivot;
  // fix heights
  root.height = Math.max(left != null ? left.height : 0,
      pivotLeft != null ? pivotLeft.height : 0) + 1;
  pivot.height = Math.max(root.height,
      pivotRight != null ? pivotRight.height : 0) + 1;
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Rotates the subtree so that its root's right child is the new root.
 */
private void rotateLeft(Node<K, V> root) {
  Node<K, V> left = root.left;
  Node<K, V> pivot = root.right;
  Node<K, V> pivotLeft = pivot.left;
  Node<K, V> pivotRight = pivot.right;
  // move the pivot's left child to the root's right
  root.right = pivotLeft;
  if (pivotLeft != null) {
    pivotLeft.parent = root;
  }
  replaceInParent(root, pivot);
  // move the root to the pivot's left
  pivot.left = root;
  root.parent = pivot;
  // fix heights
  root.height = Math.max(left != null ? left.height : 0,
      pivotLeft != null ? pivotLeft.height : 0) + 1;
  pivot.height = Math.max(root.height,
      pivotRight != null ? pivotRight.height : 0) + 1;
}

代码示例来源:origin: ibinti/bugvm

replaceInParent(node, adjacent);
  return;
} else if (left != null) {
  replaceInParent(node, left);
  node.left = null;
} else if (right != null) {
  replaceInParent(node, right);
  node.right = null;
} else {
  replaceInParent(node, null);

代码示例来源:origin: MobiVM/robovm

replaceInParent(node, adjacent);
  return;
} else if (left != null) {
  replaceInParent(node, left);
  node.left = null;
} else if (right != null) {
  replaceInParent(node, right);
  node.right = null;
} else {
  replaceInParent(node, null);

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

replaceInParent(node, adjacent);
  return;
} else if (left != null) {
  replaceInParent(node, left);
  node.left = null;
} else if (right != null) {
  replaceInParent(node, right);
  node.right = null;
} else {
  replaceInParent(node, null);

相关文章