If you don't know how Binary Trees work, don't worry about it. Just think of it this way:
instead of having a flat array where the indexes are 0-x, you can have whatever indexes you want. For example:
;Create a binary tree $btNew = _BTreeCreate() ;assign some values _BTreeSet($btNew, 1, 'The first item') _BTreeSet($btNew, 2, 'The second item') _BTreeSet($btNew, 'three', 'The third item') _BTreeSet($btNew, 'fourth', 'The fourth item') _BTreeSet($btNew, 'red', 'A warm color') _BTreeSet($btNew, 'august', 'The 8th month') ;retireve a stored value msgbox(0,'RED',_BTreeGet($btNew, 'RED'));keys are not case sensative
After putting a bunch of values into the tree, you'll want to optimize it, so it's as fast as it can be:
;Create the Binary Tree $btTemp = _BTreeCreate() ;Populate Binary Tree with random key/values ProgressOn('MWR_BTree UDF Test','Populating Keys...') for $i = 1 to 50 $j = Random(1, 1000, 1) _BTreeSet($btTemp, $j, '');set a random key to a blank value ProgressSet($i * 2, $j) Next ProgressOff() ;See how ugly your tree can be MsgBox(0,'MWR_BTree UDF Test: Raw Tree',_BTreePrintKeys($btTemp)) ;See how pretty your tree can be _BTreeOptimize($btTemp) MsgBox(0,'MWR_BTree UDF Test: Optimized Tree',_BTreePrintKeys($btTemp))
And here's what the unoptimized tree looks like:
,-------7
,-------24
| '-------25
| | ,-------54
| '-------116
| | ,-------121
| | | '-------162
| | | | ,-------174
| | | '-------180
| '-------189
,-------237
| | ,-------240
| | ,-------283
| | | | ,-------290
| | | | | '-------291
| | | | | '-------354
| | | | | '-------437
| | | '-------438
| '-------480
| | ,-------489
| '-------522
| | ,-------537
| | | '-------538
| | ,-------547
| '-------549
| | ,-------602
| | | '-------606
| | | '-------624
| '-------655
--------662
| ,-------666
| | '-------667
| ,-------673
| ,-------761
| | | ,-------778
| | '-------808
'-------839
| ,-------843
| ,-------851
| ,-------859
| | | ,-------862
| | '-------910
| | '-------915
| ,-------932
| ,-------938
| | '-------941
| | '-------948
'-------992
'-------998
,-------7
| '-------24
,-------25
| '-------54
| '-------116
,-------121
| | ,-------162
| | | '-------174
| '-------180
| '-------189
| '-------237
,-------240
| | ,-------283
| | | '-------290
| | ,-------291
| | | '-------354
| | | '-------437
| '-------438
| | ,-------480
| | | '-------489
| '-------522
| | ,-------537
| '-------538
| '-------547
--------549
| ,-------602
| | '-------606
| ,-------624
| | '-------655
| | '-------662
| ,-------666
| | | ,-------667
| | | | '-------673
| | '-------761
| | '-------778
| | '-------808
'-------839
| ,-------843
| | '-------851
| ,-------859
| | '-------862
| | '-------910
'-------915
| ,-------932
| | '-------938
'-------941
| ,-------948
'-------992
'-------998







