Native binary tree data structure

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Native binary tree data structure

Post by Mistrel »

We have lists, maps, and arrays. Now all we need are binary trees. :)
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: Native binary tree data structure

Post by GPI »

what is a binary tree?
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Native binary tree data structure

Post by STARGÅTE »

Code: Select all

Structure Tree
  List Child.Tree()
EndStructure
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: Native binary tree data structure

Post by Guimauve »

GPI wrote:what is a binary tree?
http://en.wikipedia.org/wiki/Binary_tree

Best Regards.
Guimauve
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Native binary tree data structure

Post 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
Post Reply