Lines Matching refs:child

71 /* Swap parent with child. Child moves closer to the root, parent moves away. */
74 struct heap_node* child) {
79 *parent = *child;
80 *child = t;
82 parent->parent = child;
83 if (child->left == child) {
84 child->left = parent;
85 sibling = child->right;
87 child->right = parent;
88 sibling = child->left;
91 sibling->parent = child;
98 if (child->parent == NULL)
99 heap->min = child;
100 else if (child->parent->left == parent)
101 child->parent->left = child;
103 child->parent->right = child;
110 struct heap_node** child;
127 parent = child = &heap->min;
129 parent = child;
131 child = &(*child)->right;
133 child = &(*child)->left;
140 *child = newnode;
144 * It's a min heap so parent < child must be true.
155 struct heap_node* child;
184 child = *max;
187 if (child == node) {
189 if (child == heap->min) {
196 child->left = node->left;
197 child->right = node->right;
198 child->parent = node->parent;
200 if (child->left != NULL) {
201 child->left->parent = child;
204 if (child->right != NULL) {
205 child->right->parent = child;
209 heap->min = child;
211 node->parent->left = child;
213 node->parent->right = child;
217 * It's a min heap so parent < child must be true. If the parent is bigger,
218 * swap it with the smallest child.
221 smallest = child;
222 if (child->left != NULL && less_than(child->left, smallest))
223 smallest = child->left;
224 if (child->right != NULL && less_than(child->right, smallest))
225 smallest = child->right;
226 if (smallest == child)
228 heap_node_swap(heap, child, smallest);
235 while (child->parent != NULL && less_than(child, child->parent))
236 heap_node_swap(heap, child->parent, child);