Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-02

Tree structure

15 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt
to Leonardo M. Ramé
Leonardo M. Ramé wrote
Hi, I would like to know if there's a standard tree structure where each node is a TObject. With "standard" I mean, in a standard package, like fcl-base.

there is one in the generics. But not as a regular class.

Michael.

Torsten Bonde Christiansen
to Leonardo M. Ramé: Hi, I would like to know if there's a standard tree structure where each node is a…
Leonardo M. Ramé wrote 11 lines
Hi, I would like to know if there's a standard tree structure where each node is a TObject. With "standard" I mean, in a standard package, like fcl-base. Leonardo M. Ramé http://leonardorame.blogspot.com _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

FCL_base does have one: avl_tree

but so does LCL, which is named AvgLvlTree (found in LazUtils)

I hope that helps... ;)

Kind regards,
Torsten Bonde Christiansen.

Michael Van Canneyt
to Torsten Bonde Christiansen
Torsten Bonde Christiansen wrote 15 lines
On 2013-02-12 16:13, Leonardo M. Ramé wrote: Hi, I would like to know if there's a standard tree structure where each node is a TObject. With "standard" I mean, in a standard package, like fcl-base.   Leonardo M. Ramé http://leonardorame.blogspot.com _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal FCL_base does have one: avl_tree

Does not allow multiple children, only left/right, no ?

Michael.

Torsten Bonde Christiansen
to Michael Van Canneyt
Michael Van Canneyt wrote 25 lines
On Tue, 12 Feb 2013, Torsten Bonde Christiansen wrote: > On 2013-02-12 16:13, Leonardo M. Ramé wrote: > Hi, I would like to know if there's a standard tree structure > where each node is a TObject. With "standard" I mean, in a standard > package, like > fcl-base. > > > Leonardo M. Ramé > http://leonardorame.blogspot.com > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > FCL_base does have one: avl_tree Does not allow multiple children, only left/right, no ? Michael.

True - but the original question gives no hint to whether this is desired or not... :)

-Torsten.

Leonardo M. Ramé
to Michael Van Canneyt: Does not allow multiple children, only left/right, no ? Michael.
Show quoted text 24 lines
________________________________ From: Michael Van Canneyt To: FPC-Pascal users discussions Sent: Tuesday, February 12, 2013 12:36 PM Subject: Re: [fpc-pascal] Tree structure On Tue, 12 Feb 2013, Torsten Bonde Christiansen wrote: > On 2013-02-12 16:13, Leonardo M. Ramé wrote: >       Hi, I would like to know if there's a standard tree structure where each node is a TObject. With "standard" I mean, in a standard package, like >       fcl-base. > >   > Leonardo M. Ramé > http://leonardorame.blogspot.com > > > FCL_base does have one: avl_tree Does not allow multiple children, only left/right, no ? Michael.

Isn't that a balanced binary tree? I'm looking for a simple tree structure (http://en.wikipedia.org/wiki/Tree_%28data_structure%29)

Leonardo M. Ramé
http://leonardorame.blogspot.com

Leonardo M. Ramé
to Michael Van Canneyt: there is one in the generics. But not as a regular class. Michael.

----- Original Message -----

Show quoted text 17 lines
From: Michael Van Canneyt To: Leonardo M. Ramé ; FPC-Pascal users discussions Cc: Sent: Tuesday, February 12, 2013 12:28 PM Subject: Re: [fpc-pascal] Tree structure On Tue, 12 Feb 2013, Leonardo M. Ramé wrote: > Hi, I would like to know if there's a standard tree structure where each node is a TObject. With "standard" I mean, in a standard package, like fcl-base. there is one in the generics.  But not as a regular class. Michael

Which one?.

 
Leonardo M. Ramé
http://leonardorame.blogspot.com

Graeme Geldenhuys
to Leonardo M. Ramé: Isn't that a balanced binary tree? I'm looking for a simple tree structure…
Leonardo M. Ramé wrote
Isn't that a balanced binary tree? I'm looking for a simple tree structure (http://en.wikipedia.org/wiki/Tree_%28data_structure%29)

It should be rather simple to create. A simple Composite design pattern and about 30-45 minutes with some accompanied unit tests, and you should have everything you want.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/
Leonardo M. Ramé
to Leonardo M. Ramé: ----- Original Message ----- Which one?.   Leonardo M. Ramé…

----- Original Message -----

Show quoted text 33 lines
From: Leonardo M. Ramé To: FPC-Pascal users discussions Cc: Sent: Tuesday, February 12, 2013 12:45 PM Subject: Re: [fpc-pascal] Tree structure ----- Original Message ----- > From: Michael Van Canneyt > To: Leonardo M. Ramé ; FPC-Pascal users discussions > Cc: > Sent: Tuesday, February 12, 2013 12:28 PM > Subject: Re: [fpc-pascal] Tree structure > > > > On Tue, 12 Feb 2013, Leonardo M. Ramé wrote: > >>   Hi, I would like to know if there's a standard tree structure where > each node is a TObject. With "standard" I mean, in a standard package, > like fcl-base. > > there is one in the generics.  But not as a regular class. > > Michael Which one?.

Well, I think TAvlTree fits the bill.

 
Leonardo M. Ramé
http://leonardorame.blogspot.com

Sven Barth
to Leonardo M. Ramé: Isn't that a balanced binary tree? I'm looking for a simple tree structure…
Leonardo M. Ramé wrote 27 lines
> ________________________________ > From: Michael Van Canneyt > To: FPC-Pascal users discussions > Sent: Tuesday, February 12, 2013 12:36 PM > Subject: Re: [fpc-pascal] Tree structure > > > > On Tue, 12 Feb 2013, Torsten Bonde Christiansen wrote: > >> On 2013-02-12 16:13, Leonardo M. Ramé wrote: >> Hi, I would like to know if there's a standard tree structure where each node is a TObject. With "standard" I mean, in a standard package, like >> fcl-base. >> >> >> Leonardo M. Ramé >> http://leonardorame.blogspot.com >> >> >> FCL_base does have one: avl_tree > > Does not allow multiple children, only left/right, no ? > > Michael. Isn't that a balanced binary tree? I'm looking for a simple tree structure (http://en.wikipedia.org/wiki/Tree_%28data_structure%29)

You could take a look at $fpcdir/packages/fcl-stl/gtree.pp (only in 2.7.1).

Regards,
Sven

Leonardo M. Ramé
to leledumbo

----- Original Message -----

Show quoted text 11 lines
From: leledumbo To: Cc: Sent: Wednesday, February 13, 2013 10:14 AM Subject: [fpc-pascal] Re: Tree structure Ah... finally somebody needs it. Please use the gtree unit, I would like to see whether it's really worth developing the unit for other people (than myself) :)

Hi Leledumbo, I think it will work. I take the opportunity to ask you for a little example on how can I traverse a nested tree, I need this for populating a TTreeView from a generic TTree.

 
Leonardo M. Ramé
http://leonardorame.blogspot.com

Roberto P.
to Leonardo M. Ramé

I can't find the unit gtree...where is it located or downloadable from ?

Thanks,

R#

2013/2/13 Leonardo M. Ramé

Show quoted text 28 lines
----- Original Message ----- > From: leledumbo > To: > Cc: > Sent: Wednesday, February 13, 2013 10:14 AM > Subject: [fpc-pascal] Re: Tree structure > > Ah... finally somebody needs it. Please use the gtree unit, I would like to > see whether it's really worth developing the unit for other people (than > myself) :) > > Hi Leledumbo, I think it will work. I take the opportunity to ask you for a little example on how can I traverse a nested tree, I need this for populating a TTreeView from a generic TTree. Leonardo M. Ramé http://leonardorame.blogspot.com _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Sven Barth
to Roberto P.
Roberto P. wrote
I can't find the unit gtree...where is it located or downloadable from ?

If you have a current checkout of FPC's trunk or a recent snapshot the unit is located in $fpcsr/packages/fcl-stl/src. It's currently only provided in trunk.

Regards,
Sven

Leonardo M. Ramé
to Roberto P.: I can't find the unit gtree...where is it located or downloadable from ? R# 2013/2/13…
Show quoted text 13 lines
________________________________ From: Roberto P. To: Leonardo M. Ramé ; FPC-Pascal users discussions Sent: Wednesday, February 13, 2013 11:27 AM Subject: Re: [fpc-pascal] Re: Tree structure I can't find the unit gtree...where is it located or downloadable from ? Thanks,

In <FPC SOURCES>/packages/fcl-stl/src you'll have to update your svn trunk repository.

Leonardo M. Ramé
http://leonardorame.blogspot.com