[Development] Explicit tree data structure in Qt (was: Re[2]: Proposal to change connectSlotsByName behavior)

André Somers andre at familiesomers.nl
Fri Dec 4 09:52:35 CET 2015



------ Original Message ------
From: "Thiago Macieira" <thiago.macieira at intel.com>
To: development at qt-project.org
Sent: 04/12/2015 09:33:03
Subject: Re: [Development] Proposal to change connectSlotsByName 
behavior

>On Friday 04 December 2015 08:16:43 André Somers wrote:
>>  >But I'd expect that the flattening of the tree produces depth-first.
>>  >Breadth-
>>  >first could result in a violation of the principle of least 
>>surprise.
>>
>>  Why? That is not my expectation at all. If you ask somebody if he has 
>>a
>>  child named Maria, is he most likely to first name his second 
>>daughter
>>  or the granddaughter by his first child you think?
>
>I agree and disagree. The listing people may use in their heads may 
>look like
>breadth first, but it's actually more chaotic. If you asked someone to 
>name all
>the descendants of a grandparent, they will probably group siblings, 
>and the
>groups may be sorted by generation, but within each generation the 
>groups may
>be out of order.
>
>        Nana
>  Alice Bob Charlie Dave
>Elsa, Frank Gerald, Hector, Isabel Joey,Kevin Lisa
>
>If you ask for someone to list that, it may come out as "Alice, Bob, 
>Dave,
>Charlie, Gerald, Hector, Isabel, Lisa, Elsa, Frank, Kevin, Joey"
Well, indeed you are right. If I am to name or even count descendants, 
I'd probably go depth-first.

>
>However, when talking about computer programming, I'd wager that people 
>expect
>depth-first, if not for the simple reason that this is how they'd 
>implement it
>if they were asked to.
>
This is getting off topic, but this discussion does make me wonder - 
again - if we shouldn't move away from this intrusive parent-children 
data structure completely. We are not using intrusive data structures 
any more to create (linked) lists, why do we still do that for 
trees/forests? Then, you would just get the iterator with the behaviour 
you need (depth first or breath first or some other access pattern) and 
run whatever algorithm you need on that. And yes, that would be a very, 
very intrusive change.

André




More information about the Development mailing list