128
booleanisLessThan(path,index)
ifthis.path==paththen
return(this.index<index)
endif/*restis"else"afterreturnabove*/
/*trimanycommonprefix,upto,butnotincluding
thefinalinsertionIDofeitherchange*/
my_path=this.path.trim(path)
path=path.trim(this.path)
ifmy_path.length>1then
/*Icanbeorderedbyamove/copydestination*/
my_label=my_path.head().getDestination().getComparisonLabel()
else
/*Iamorderedbyaninsertionposition*/
my_label=
findSegment(my_path.head(),this.index).getComparisonLabel()
endif
ifpath.length>1then
/*otherisorderedbyherdestination*/
label=path.head().getDestination().getComparisonLabel()
else
/*otherisorderedbyaninsertionsegment*/
label=findSegment(path,
index).getAddress().getcomparisonLabel()
endif
returnmy_label<label
F F F F iii ig g g gu u u ur r r re e e e 6666....5555:::: AAAAllllggggoooorrrriiiitttthhhhmmmm ffffoooorrrr ccccoooommmmppppaaaarrrriiiinnnngggg aaaa nnnnoooonnnn----iiiinnnnddddeeeexxxxeeeedddd aaaaddddddddrrrreeeessssssss
Itsuffices,tofindthestartingaddressofthesegmentcontainingagivenindexforapar-
ticularinsertion.ThisisthefindSegmentfunction.Itisalmostcertainlymostpractical
simplytosearchthesegmentsofaninsertion(whichcanbeeasilykeptlinkedtoeach
other)tofindaninsertionoffset.Itwouldcertainlybepossibletokeepasortedlistofindi-
cesforeachinsertiontoguaranteealogarithmicworst-casesearchtimeifverylargesplit-
tingfactorswerepresentinsomeeditingscenario.
Itisworthmakingcomparisonfordestinationaddressesfastbecauseoftheneedfor
comparisonbasedsearchstructuresformoveanddeletionranges.Ininteractiveediting,
however,asimplerstrategyisavailablesothatsearchandcomparisontimeisnotanissue.
129
Aninteractiveeditingprocesscanprovideanaddressdirectly,alongwiththesegmentthe
operationisaffecting.Theapplicationwilloperateonthatsequence,declaringoperationsin
termsofoffsetsintheP-sequencerepresentingitscurrentstate.Ifthereisaninterfacebe-
tweentheapplicationandthePalimpseststore,itshouldmaintainanindexofthePalimp-
sestaddresses(andtheirassociatedsegments)inthecurrentP-sequence.Then,whenanew
operationneedstoinsertanewaddressintothesegmentlist,thecorrectsegmentisavail-
able,enablingtheinsertionandthecreationofanew,labeledaddressrecordasimplemat-
terofdirectlistinsertion.ThisstrategyavoidseventhecostofusingthefindSegment
function.
6.7.2 Sequencecontents
Besidestextsegments,thetextsegmentstorealsocontainsanumberofdifferentobjects
andtheiraddressrecords:insertionpointsformovesandcopies;move,copyanddeletion
rangeendpoints;insomesystems,perhapstheendpointsofhypertextlinkanchors.Inaddi-
tiontorepresentingtheaddressspace,traversalofthesegmentlistishowthecontentsofa
P-sequenceareenumerated.
WenowconsiderthesequentialenumerationofthecontentsofaP-sequencerepresented
byachangesetV.Thefollowingadditionaloperationswillbeusedtochecktheauxiliary
datastructuresassociatedwithV:
1. isDeleted(V,address)checkstheaddresstoseeifitisdeletedbyanyofthe
deletionchangesinV.Takestimelogarithmicinthenumberofdeletions.
2. findDeletionFor(V,address)returnsadeletioninVthatoverlapsthegiven
address,oroneofthedeletionsthatstartsattheleftmostaddresstotherightofthe
givenaddress.Takestimelogarithmicinthenumberofdeletions.
3. getMoveRegion(V,address,changeID)returnthelongesthigher-priority
moveoperationoverlappingthegivenpoints,ifany.IfthechangeIDisnull,any
Previous Page Next Page