Lines Matching refs:child

72 /* Swap parent with child. Child moves closer to the root, parent moves away. */
75 struct heap_node* child) {
80 *parent = *child;
81 *child = t;
83 parent->parent = child;
84 if (child->left == child) {
85 child->left = parent;
86 sibling = child->right;
88 child->right = parent;
89 sibling = child->left;
92 sibling->parent = child;
99 if (child->parent == NULL)
100 heap->min = child;
101 else if (child->parent->left == parent)
102 child->parent->left = child;
104 child->parent->right = child;
111 struct heap_node** child;
128 parent = child = &heap->min;
130 parent = child;
132 child = &(*child)->right;
134 child = &(*child)->left;
141 *child = newnode;
145 * It's a min heap so parent < child must be true.
156 struct heap_node* child;
183 child = *max;
187 if (child == NULL) {
194 if (child == node) {
196 if (child == heap->min) {
203 child->left = node->left;
204 child->right = node->right;
205 child->parent = node->parent;
207 if (child->left != NULL) {
208 child->left->parent = child;
211 if (child->right != NULL) {
212 child->right->parent = child;
216 heap->min = child;
218 node->parent->left = child;
220 node->parent->right = child;
224 * It's a min heap so parent < child must be true. If the parent is bigger,
225 * swap it with the smallest child.
228 smallest = child;
229 if (child->left != NULL && less_than(child->left, smallest))
230 smallest = child->left;
231 if (child->right != NULL && less_than(child->right, smallest))
232 smallest = child->right;
233 if (smallest == child)
235 heap_node_swap(heap, child, smallest);
242 while (child->parent != NULL && less_than(child, child->parent))
243 heap_node_swap(heap, child->parent, child);