Hi Marcus,

My objective was simple, parenting is the main focus and it should be done
 once and only once for each node in the hierarchy. To achieve this, during
each iteration the node should have knowledge about his parent just by
knowing its position (indent).

I did not want complex processing of saving states and whole trees and then
lookup up and down. The node should have a place (the tuple list) to look
for its parent. It simply asks this question - I have this position, who is
my parent. This is typically looking for an insertion point in an array and
bisect was a perfect candidate for these requirements.

After finding the parent, the node attaches itself to the list replacing
the current node at that position so that preceding nodes can find it as a
parent when required.

Using a dict is a better option just for the reason of O(1) lookup times,
but then you should do this lookup only once for each node and not iterate
through each key and then deep inside it until some condition is reached.
To me, that is a bit complex.

On Fri, Sep 16, 2016 at 8:44 PM, Marcus Ottosson <konstrukt...@gmail.com>
wrote:

> Ok, Alok, I had a closer look at your example and the bisect module in
> Python.
>
> In my example, a dict replaces bisect. The dict is limited, in that once a
> parent at the same level as an above parent appears, the above parent
> vanishes from consideration. But in this case, maybe that works to our
> advantage? Could you tell me about your motivation for using bisect?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/python_inside_maya/d86fb040-1d59-492d-8b7c-
> 50dc5cf67d96%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/d86fb040-1d59-492d-8b7c-50dc5cf67d96%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



--

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMTaOkfYe0G_x3JCMxfDwiJzeYeQMyAObKCGuPqA2n7foQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to