131
enumerateContents(version,address,enumerate)
/*afairamountofsetupforthemainenumerationloop*/
/*themovestacktracksthecurrentlyactivemoveoperation*/
ifaddress.path().length>1then
PutmoveIDsandendpointsofmovesourceranges
formovesinaddress.path()ontomc_stack.
Theymustbeenteredinreverseorder.Thismeansthat
address.path().head()shouldbetopofthestack.
else
mc_stack=empty
endif
cur_address=address
cur_seg=findSegment(version,address.path(),address.index())
cur_deletion=findDeletionFor(version,cur_address)
while(cur_seg!=null&&applicationstillwantsdata) then
ifcur_deletion.start()<cur_address)
cur_address=cur_deletion.end().next()
else
test_move=getMoveRegion(version,cur_address,
mc_stack.top().getID())
iftest_move!=nullthen
cur_address=test_move.end()
else
/*wearenowsurethatthedata(ifany)isOK.*/
/*wealwayshaveawholesegment,becauseboundaries
fordeletionsandmovessplitsegments*/
cur_address=process(cur_seg,mc_stack,enumerate,
version)
endif
endif
ifcur_address=mc_stack.top().sourceRegion().end()
cur_address=mc_stack.top().destAddress().next()
mc_stack.pop()
endif
cur_deletion=findDeletionFor(cur_address)
endwhile
F F F F iii ig g g gu u u ur r r re e e e 6666....6666:::: AAAAllllggggoooorrrriiiitttthhhhmmmm ffffoooorrrr eeeennnnuuuummmmeeeerrrraaaattttiiiinnnngggg tttthhhheeee ccccoooonnnntttteeeennnnttttssss ooooffff aaaa PPPP----sssseeeeqqqquuuueeeennnncccceeee
Thepseudo-codeinFigure6.6showsexactlyhowtheinformationaboutdeletedand
movedsubsequencescanbeusedtoskipoverportionsofthesequencethatarenotpartof
thecurrentversion.Oneaspectnotshownisthatthesegment.next()operationcouldbe
modifiedtotakeanargument,version,specifyingthechangesetbeingtraversed.This
132
wouldenableoptimizingtheoverallalgorithmbyusinganauxiliarycopyoftheelementse-
quencecontainingonlyitemsinthechangeset.Thisoptimizationwouldalsoeliminatethe
needforthefirstnestedif-statementatthestartofthecodeinFigure6.7,whichchecksfor
themembershipofaninsertionsegmentinthechangeset.
process(cur_seg,mc_stack,enumerate,version)
ifcur_seg.type()=insertion
ifthissegmentisinversion
ifcur_setismarkedaspartofamovedestination,and
thatdestinationisnotonmc_stackthen
returncur_seg.finalSegment().next()
enumerate(cur_seg)
returncur_seg.next()
else
returncur_seg.finalSegment().next()
endif
elseifcur_seg.type()==moveDestination
||cur_seg.type()==copyDestination
pushoperationonmc_stack
returncur_seg.getSource.start()
F F F F iii ig g g gu u u ur r r re e e e 6666....7777:::: AAAAuuuuxxxxiiiilllliiiiaaaarrrryyyy ffffuuuunnnnccccttttiiiioooonnnn ffffoooorrrr pppprrrroooocccceeeessssssssiiiinnnngggg aaaa sssseeeeggggmmmmeeeennnntttt dddduuuurrrriiiinnnngggg eeeennnnuuuummmmeeeerrrraaaattttiiiioooonnnn
Thehandlingofmoveandcopyduringenumerationisperhapsnotobvious.Thestrategy
usedisbasedonthefactthatmovedsubsequencesnesthierarchicallyattheirdestination,
becausetheentireregionofaddressescreatedbyamoveorcopyisinsertedatoneplace.Of
course,othersubsequencesmayalsooccurwithinsucharegion.Therearetwosortsofsub-
sequencethatcanoccurinamovedestination:
1. Datainsertedinthesourcerangeofamoveorcopyalwayshasanaddresswhose
pathstartswiththeIDofthemoveorcopy.Allsuchaddresseshavecounterparts
withoutthispathprefix,atthesourceoftheoperation.
2. Datainsertedatthetargetofamoveorcopymayhaveanykindofaddress,de-
pendingonitssource(move,copy,orinsertion).
AsdiscussedinSection3.4.2a,addresseswithinmovedestinationsareusuallybestrepre-
sentedatthemove’ssourcebecauseitallowsadditionalmergepossibilitiesbyreducingthe
Previous Page Next Page