From 2f06bd41c80ec263aa2add1146a2ea0e927aba28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=89=E7=8C=AB=E9=A5=BC?= Date: Fri, 3 Nov 2023 23:29:14 +0800 Subject: [PATCH] fix: correct comments in rax.h - The characters in the node should be sorted in ascending order, so [t b] should be changed to [b t]. - "foo" is not a key node, so it should be represented using (). --- src/rax.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/rax.h b/src/rax.h index 6b1fd4188..e768baa39 100644 --- a/src/rax.h +++ b/src/rax.h @@ -46,13 +46,13 @@ * \ * (o) "fo" * \ - * [t b] "foo" + * [b t] "foo" * / \ - * "foot" (e) (a) "foob" + * "foob" (a) (e) "foot" * / \ - * "foote" (r) (r) "fooba" + * "fooba" (r) (r) "foote" * / \ - * "footer" [] [] "foobar" + * "foobar" [] [] "footer" * * However, this implementation implements a very common optimization where * successive nodes having a single child are "compressed" into the node @@ -61,13 +61,13 @@ * provided inside the representation. So the above representation is turned * into: * - * ["foo"] "" + * ("foo") "" * | - * [t b] "foo" + * [b t] "foo" * / \ - * "foot" ("er") ("ar") "foob" + * "foob" ("ar") ("er") "foot" * / \ - * "footer" [] [] "foobar" + * "foobar" [] [] "footer" * * However this optimization makes the implementation a bit more complex. * For instance if a key "first" is added in the above radix tree, a @@ -82,11 +82,11 @@ * / \ * "firs" ("rst") (o) "fo" * / \ - * "first" [] [t b] "foo" + * "first" [] [b t] "foo" * / \ - * "foot" ("er") ("ar") "foob" + * "foob" ("ar") ("er") "foot" * / \ - * "footer" [] [] "foobar" + * "foobar" [] [] "footer" * * Similarly after deletion, if a new chain of nodes having a single child * is created (the chain must also not include nodes that represent keys),