On Fri, May 17, 2013 at 9:11 AM, Edward K. Ream <[email protected]> wrote:
> Let's hold off on further discussion just now while I create scripts that
will clarify matters.
Consider the following outline, dumped using export-headlines:
+ root
+ a
- b
- c
- b
+ a
- b
- c
- b
**Important**: all nodes with the same names are clones of each other.
Here is a script that will traverse this outline, dumping each position as
it goes::
root = g.findNodeAnywhere(c,'root')
line = 0
for p in root.self_and_subtree():
line += 1
print('%s: %4s @ %d p._childIndex: %d p.stack: %s' % (
line,
p.h,
id(p.v),
p._childIndex,
'[%s]' % ', '.join(['(v:%s @ %s, %s)' % (v.h,id(v),i) for v,i
in p.stack]),
))
The output of this script is as follows, with newlines added for clarity so
as to put the stack on a different line::
1: root @ 173840816 p._childIndex: 0 p.stack: []
2: a @ 173840880 p._childIndex: 0 p.stack: [
(v:root @ 173840816, 0)]
3: b @ 172686704 p._childIndex: 0 p.stack: [
(v:root @ 173840816, 0), (v:a @ 173840880, 0)]
4: c @ 172702288 p._childIndex: 1 p.stack: [
(v:root @ 173840816, 0), (v:a @ 173840880, 0)]
5: b @ 172686704 p._childIndex: 2 p.stack: [
(v:root @ 173840816, 0), (v:a @ 173840880, 0)]
6: a @ 173840880 p._childIndex: 1 p.stack: [
(v:root @ 173840816, 0)]
7: b @ 172686704 p._childIndex: 0 p.stack: [
(v:root @ 173840816, 0), (v:a @ 173840880, 1)]
8: c @ 172702288 p._childIndex: 1 p.stack: [
(v:root @ 173840816, 0), (v:a @ 173840880, 1)]
9: b @ 172686704 p._childIndex: 2 p.stack: [
(v:root @ 173840816, 0), (v:a @ 173840880, 1)]
This is worth careful study, especially for implementers. The highlights::
A. There is only one copy of each vnode, as shown by the vnode addresses
that follow the @ signs.
B. The same *vnode* may appear in two different childIndex places in a
parent node. For example, the p._childIndex field for node b is 0 in line
7, and 2 in line 8.
C. *Positions* may visit the same *vnode* arbitrarily many times. In this
example, vnode b is visited 4 times, in lines 3, 5, 7 and 9. Note that all
these positions are *different*, because of different child indices in the
stack, or different p._childIndex fields.
Please feel free to ask questions about the output.
That's all for now. I'll say more later when I have time. This is all
preliminary work for the real task of testing algorithms that will delete
nodes.
Edward
P.S. As was researching this topic, I noticed two different ways of
archiving positions, p.key and p.archivedPosition. The differences between
these not concern us now. The point is that *any* form of archived
position will become invalid when the outline changes.
EKR
--
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.