[Riskquantify-devel] Updates to red-black trees
Status: Beta
Brought to you by:
bah
From: Brett H. <br...@hu...> - 2006-01-03 19:01:56
|
I added support to Risk Quantify to remove nodes from red-black =20 trees. I also found that an in-order insertion into the red-black =20 tree didn=E2=80=99t actually rebalance the tree, so I=E2=80=99ve fixed = this bug as =20 well. This may mean that existing code will have better performance - =20= especially if the data being loaded into the tree is already ordered, =20= and there are lots of searches. I=E2=80=99ve added a rq_tree_rb_size() =20= function to get a count of the number of nodes in the tree. I=E2=80=99ve created a file to test the new red-black tree functions, = called =20 test_tree_rb.c which is in the test/code directory. If you invoke it =20 with an argument, you can get a prompt allowing you to test the =20 functionality interactively. The test file is designed to fill the =20 tree with integers, so if you are using it interactively; type in =20 something like =E2=80=9Ca 1=E2=80=B3 to add a node with the key =E2=80=9C1= =E2=80=B3, =E2=80=9Ca 2=E2=80=B3 =20 will add a node with the key =E2=80=9C2=E2=80=B3, etc. =E2=80=9Cp=E2=80=9D= will print the =20 current state of the tree. =E2=80=9Cr 2=E2=80=B3 will remove the node = with key 2 =20 from the tree. Please let me know if you find any problems with the implementation. -- Brett Hutley - Quantitative Developer mailto:br...@hu... http://hutley.net/brett |