Page 1 of 1
Native binary tree data structure
Posted: Wed Jul 13, 2011 11:58 am
by Mistrel
We have lists, maps, and arrays. Now all we need are binary trees.

Re: Native binary tree data structure
Posted: Wed Jul 13, 2011 8:15 pm
by GPI
what is a binary tree?
Re: Native binary tree data structure
Posted: Wed Jul 13, 2011 8:17 pm
by STARGÅTE
Code: Select all
Structure Tree
List Child.Tree()
EndStructure
Re: Native binary tree data structure
Posted: Wed Jul 13, 2011 9:11 pm
by Guimauve
GPI wrote:what is a binary tree?
http://en.wikipedia.org/wiki/Binary_tree
Best Regards.
Guimauve
Re: Native binary tree data structure
Posted: Thu Jul 14, 2011 9:08 am
by Mistrel
STARGÅTE wrote:Code: Select all
Structure Tree
List Child.Tree()
EndStructure
Searching a binary tree is MUCH faster than stepping through a list. A tree also has several different ways of being iterated, some of which will produce an output which is automatically sorted.
To be honest, I'd rather see PureBasic provide support for OO programming and do away with the built in data structures completely. They don't want to support OO yet what are PureBasic Lists, Arrays, and Maps? Maybe they're not actual objects underneath but they're certainly not primitives and cannot be treated as such.
I wrote my own linked list before they were supported in PB structures. I suppose I'll have to do the same for trees. But working with them in this way can be extremely cumbersome. PureBasic would benefit from the addition of pass-by-reference:
http://www.purebasic.fr/english/viewtop ... =3&t=36923