AVLTree: Tree_Last
issueid=533 22-08-2017 11:30
Member
Number of reported issues by primo: 6
AVLTree: Tree_Last

Thanks Eros for referring to the AVLTree module in my last post, i find it very good and very speedy, i'm still experimenting with it.
not sure if the following is a bug or not
i have used the loop index as keys, and the result of the following code something like this:
1-- 21
2-- 20
3-- 21
4-- 30
5-- 13
6-- 13
7-- 29
8-- 29
9-- 17
10-- 26

First node Key/data is: 1 21
Last node Key/data is: 9 17

the last node refer to the 9 17 while it should refer to 10 26 unless i miss something
Uses "console"

Dim  i  As Long
String sData

'Creating an new AVL Tree, Keys are case sensitive
DWord pTree = Tree_New 'AVL Tree pointer: pTree

Randomize
For i = 1 To 10
  Tree_Set(pTree, Str$(i), Rnd(10,30))
Next

For i = 1 To 10
  sData = Tree_Get(pTree, Str$(i))
  PrintL Str$(i)& "-- " & sData
Next

DWord pRoot, pLast

pRoot = Tree_First(pTree)
pLast = Tree_Last(pTree)

PrintL
PrintL "First node Key/data is:", Tree_GetKey(pRoot) , Tree_GetData(pRoot) 
PrintL "Last  node Key/data is:", Tree_GetKey(pLast) , Tree_GetData(pLast)

Tree_Free(pTree)

WaitKey
Edit:
it works well if we choose the key from 10 and up. but if we choose the key from 1 and up sequently the Tree_Last stop at 9. so i guess the key should be at least 2 characters
Issue Details
Issue Number 533
Project thinBasic
Category Unknown
Status Unconfirmed
Priority Unknown
Affected Version 1.10.2
Fixed Version (none)
Milestone (none)
Users able to reproduce bug 0
Users unable to reproduce bug 0
Assigned Users (none)
Tags (none)




22-08-2017 17:59
Member
now i think the problem is only with Tree_First and Tree_Last
try in the above code
For i = 90 To 110 line 10 and line 14

will output:
First node Key/data is: 100 number
Last node Key/data is: 99 number

+ Reply