]> wimlib.net Git - wimlib/blobdiff - src/avl_tree.c
Use more comprehensive public domain dedications
[wimlib] / src / avl_tree.c
index caaba3ed6905471e8307ff359e94915456066c8b..d3afae4e2114e7de667113b433d905af98dc6c24 100644 (file)
@@ -1,17 +1,29 @@
 /*
 /*
- * avl_tree.c
+ * avl_tree.c - intrusive, nonrecursive AVL tree data structure (self-balancing
+ *             binary search tree), implementation file
  *
  *
- * Intrusive, nonrecursive AVL tree data structure (self-balancing binary search
- * tree), implementation file.
+ * The following copying information applies to this specific source code file:
  *
  *
- * Author:  Eric Biggers
- * Year:    2014
+ * Written in 2014 by Eric Biggers <ebiggers3@gmail.com>
  *
  *
- * This file is placed into the public domain.  You can do whatever you want
- * with it.
+ * To the extent possible under law, the author(s) have dedicated all copyright
+ * and related and neighboring rights to this software to the public domain
+ * worldwide via the Creative Commons Zero 1.0 Universal Public Domain
+ * Dedication (the "CC0").
+ *
+ * This software is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the CC0 for more details.
+ *
+ * You should have received a copy of the CC0 along with this software; if not
+ * see <http://creativecommons.org/publicdomain/zero/1.0/>.
  */
 
  */
 
-#include <wimlib/avl_tree.h>
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "wimlib/avl_tree.h"
 
 /* Starts an in-order traversal of the tree: returns the least-valued node, or
  * NULL if the tree is empty.  */
 
 /* Starts an in-order traversal of the tree: returns the least-valued node, or
  * NULL if the tree is empty.  */
@@ -127,15 +139,6 @@ avl_get_balance_factor(const struct avl_tree_node *node)
        return (int)(node->parent_balance & 3) - 1;
 }
 
        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).  */
 /* 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).  */
@@ -380,12 +383,10 @@ avl_handle_subtree_growth(struct avl_tree_node ** const root_ptr,
                 */
                avl_rotate(root_ptr, parent, -sign);
 
                 */
                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 */
 
                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
                avl_adjust_balance_factor(node, -sign);   /* B */
        } else {
                /* @node (B below) is heavy in the direction opposite