diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-07-08 20:58:15 -0400 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-07-08 20:58:15 -0400 |
commit | 4652a276ff53cc56863e26a3c6f852637257a959 (patch) | |
tree | f592a4055b02fb1a0490f7953eb8d6cd541dc440 | |
parent | a2ff97d2a7d14266c22a64224e62934c610b4cd5 (diff) |
Add rotate functions for map trees
-rw-r--r-- | collections/map/map.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/collections/map/map.c b/collections/map/map.c index 747d6ce..f5751b5 100644 --- a/collections/map/map.c +++ b/collections/map/map.c @@ -37,6 +37,32 @@ struct map_node *root; return map_height(root->right) - map_height(root->left); } +void map_rotate_left(node) +struct map_node **node; +{ + struct map_node *tmp; + + tmp = *node; + *node = tmp->right; + tmp->right = (*node)->left; + (*node)->left = tmp; + + return; +} + +void map_rotate_right(node) +struct map_node **node; +{ + struct map_node *tmp; + + tmp = *node; + *node = tmp->left; + tmp->left = (*node)->right; + (*node)->right = tmp; + + return; +} + map* map_new(cmp) cmp_func cmp; { |