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 ().
This commit is contained in:
有猫饼 2023-11-03 23:29:14 +08:00 committed by Hccake
parent 15a048d4f0
commit 2f06bd41c8

View file

@ -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),