From cbcb5e24d897c8b91cd84bf6ac05bf00c026ae72 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sun, 17 Dec 2017 20:12:48 +0100 Subject: [PATCH] Update / cleanup comments --- m-rbtree.h | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/m-rbtree.h b/m-rbtree.h index a9b26c5f..320f3b66 100644 --- a/m-rbtree.h +++ b/m-rbtree.h @@ -86,9 +86,9 @@ ) /* Max depth of the binary tree - It is twice the depth of a perfectly even tree with maximum elements. - Max number of elements is max of size_t. - A perfectly even tree is log2(max(size_t))child[0] = p->child[1]; \ p->child[0] = x; \ p->child[1] = pp; \ RBTREEI_SET_BLACK(p); \ RBTREEI_SET_RED(pp); \ } else { \ - /* The child is the right child of its father */ \ + /* The child is the right child of its parent */ \ /* Left rotation */ \ pp->child[0] = x->child[1]; \ p->child[1] = x->child[0]; \ @@ -324,9 +324,9 @@ typedef enum { p = x; \ } \ } else { \ - /* The father is the right child of the grand-father */ \ + /* The parent is the right child of the grand-parent */ \ if (which[cpt-1] == 0) { \ - /* The child is the left child of its father */ \ + /* The child is the left child of its parent */ \ pp->child[1] = x->child[0]; \ p->child[0] = x->child[1]; \ x->child[1] = p; \ @@ -336,7 +336,7 @@ typedef enum { RBTREEI_SET_RED(pp); \ p = x; \ } else { \ - /* The child is the right child of its father */ \ + /* The child is the right child of its parent */ \ pp->child[1] = p->child[0]; \ p->child[1] = x; \ p->child[0] = pp; \ @@ -344,7 +344,7 @@ typedef enum { RBTREEI_SET_RED(pp); \ } \ } \ - /* Insert the new grand father */ \ + /* Insert the new grand parent */ \ if (cpt == 2) { \ tree->node = p; \ } else { \ @@ -643,12 +643,8 @@ typedef enum { { \ RBTREEI_CONTRACT (tree1); \ RBTREEI_CONTRACT (tree2); \ - size_t size = tree1->size; \ - tree1->size = tree2->size; \ - tree2->size = size; \ - node_t *node = tree1->node; \ - tree1->node = tree2->node; \ - tree2->node = node; \ + M_SWAP(size_t, tree1->size, tree2->size); \ + M_SWAP(node_t *, tree1->node, tree2->node); \ RBTREEI_CONTRACT (tree1); \ RBTREEI_CONTRACT (tree2); \ } \