* Author: Eric Biggers
* Year: 2014
*
- * This file is placed into the public domain. You can do whatever you want
- * with it.
+ * The author dedicates this file to the public domain.
+ * You can do whatever you want with this file.
*/
#include <wimlib/avl_tree.h>
return (int)(node->parent_balance & 3) - 1;
}
-/* Sets the balance factor of the specified AVL tree node. This must be
- * -1, 0, or 1. */
-static AVL_INLINE void
-avl_set_balance_factor(struct avl_tree_node *node, int balance_factor)
-{
- node->parent_balance =
- (node->parent_balance & ~3) | (balance_factor + 1);
-}
-
/* Adds @amount to the balance factor of the specified AVL tree node.
* The caller must ensure this still results in a valid balance factor
* (-1, 0, or 1). */
*/
avl_rotate(root_ptr, parent, -sign);
- /* Equivalent to:
- * avl_set_balance_factor(parent, 0); */
+ /* Equivalent to setting @parent's balance factor to 0. */
avl_adjust_balance_factor(parent, -sign); /* A */
- /* Equivalent to:
- * avl_set_balance_factor(node, 0); */
+ /* Equivalent to setting @node's balance factor to 0. */
avl_adjust_balance_factor(node, -sign); /* B */
} else {
/* @node (B below) is heavy in the direction opposite