On Tuesday, March 17, 2020 at 8:26:38 AM UTC-5, vitalije wrote:
Apart from your intuition do you see any other reason to recompute the
> links after each delete?
>
Here's another part of the problem that can, and *will* cause problems.
Positions in the original list might no longer exist after a previous
delete operation. That's why the code I suggest contains:
# Calculate new_positions.
new_positions = []
for p in aList:
new_p = p.position_after_deleting(del_p)
if new_p:
new_positions.append(new_p)
Without this kind of check, there is a real danger of adjusting child
indices too often.
I can't say for sure whether these precautions are necessary, but I
strongly suspect they are. Even if they aren't strictly necessary, they
seem like the simplest, most prudent, approach.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/leo-editor/9eb44df0-0a14-4e25-99d2-2f7d56782657%40googlegroups.com.