From e2a99fae3709a5e0fdff92c2a787cde595bdffcc Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Thu, 31 Dec 2020 03:20:37 -0500 Subject: Add function to get full length of rope --- structures/rope/rope.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/structures/rope/rope.c b/structures/rope/rope.c index e1ae4a9..f3828df 100644 --- a/structures/rope/rope.c +++ b/structures/rope/rope.c @@ -28,6 +28,18 @@ rope* rope_new() return tmp; } +size_t rope_len(root) +rope *root; +{ + if (!root) + return 0; + + if (root->str) + return strlen(root->str); + + return rope_len(root->left) + rope_len(root->right); +} + rope* str_to_rope(str) char *str; { -- cgit v1.1