121
tionoperations,andalsousedtotracktherelativepositionsofsignificantaddresses,which
areusedinaddresscomparison.ThecomparisonofaddressesisdiscussedinSection6.7.1.
TheapplicationstrategydiscussedinSection3.4.2aallowsapplicationstoincreasemerge
possibilitiesbyautomaticallytranslatingdestinationaddresseswithinmoveresultstotheir
ultimatesource.Suchanaddresshastheform(I
1 …I
n , i),whereI
1 …I
n–1 aremovesorcopies,
andI
n isaninsertionoperation.Suchadestinationisstoredasifitwereinsertedat(I
n , i),
toeasethetraversalofaP-sequence.Thealteredlocationcorrectlyreflectsitsorderingwith
respecttotheotherdatawithinthemovedorcopiedcontext.Theinsertionpoint,andits
actualaddress,(I
1 …I
n , i)mustalsobeindexedintheircorrectrelativepositionforaddress
comparison.
Inserteddataisrepresentedbyalogicallistofsubsequencesegments.Eachsegmentis
taggedwithitsinsertionoforigin.Whendataisinsertedintothemiddleofasegment,that
segmentissplit,andthenewdataistaggedwithitsowninsertiontag.Thefirstsegmentof
anyinsertionmaintainsapointertoitslastsegment.Thisallowsanabsentinsertiontobe
quicklytraversed,sincenodatainsertedinsideofitcanbepresentinaversionfromwhich
itisabsent.Thistrickforsequentialenumerationofsegmentsessentiallyskipsanyinserted
segmentsthatarecausallythananinsertionnotpresentintheversionofinterest.
Segmentsinsertedintopost-moveorpost-copycontextswillhavebeentranslatedback-
wardstothesourcesoftheircontext-definingoperations.Theyareadditionallytaggedwith
theIDofthemoveorcopychangestoindicatethattheyareonlyvalidwithinthedestina-
tionregionofaparticularsetofmoveorcopyoperations.Whenencounteredinothercon-
textstheyareignored,justlikeonesthatarenotpartofthecurrentversion.Thisstructure
alsocontainspointmarkersrepresentingthedestinationsofmoveandcopyoperations,
whoseIDsallowtheirsourceregionstobedetermined.Theseareessentiallytransclusion
linksinthesenseof(Nelson1987;Nelson1987).Theyrepresentthetransparentinclusionof
materialstoredelsewhere.WhentraversingasegmentlisttoenumeratethecontentsofaP-
122
sequence,suchamoveorcopydestinationisasignaltotraversethepartoftheinsertion
segmentstructurecorrespondingtothesourceoftheoperation.
ThesegmentlistalsoprovidesawaytospeedthecomparisonofPalimpsestaddresses,by
makingiteasytodeterminetherelativeorderingofthedestinationsofalloperations.Each
destinationhasaplaceinthelistofsegments,andtheserelativelocationscanbeusedto
speedthecomparisonofdestinations,bymaintainingintegerlabelsontheelementsofthe
list.Maintainingsuchlabelsonlistitems(toenablecomparisoninanunkeyedsequence)is
lnownastheordermaintenanceproblemanditcanbesolved(DietzandSleator1987)forn
segmentsinO(1)amortizedtimeatthecostofsomeimplementationcomplexity,orvery
simplyinO(logn)time.Eachinsertionintothesegmentlistusesavariantofthisalgorithm
tomaintainorderinglabelsonalladdressescontainedinstoredchanges.
6.5 Trackingdeletions
Deletionsmustbestoredsoasenablequickdeterminationofwhetheraparticularposi-
tionisdeleted,andaftersuchaninitialsearch,shouldprovidequickenumerationoffol-
lowingdeletedsegments.Sincedeletionswillbeaddedandoccasionallyundone,thesetof
intervalsrepresentingthedeletedsegmentsmustbedynamic.Efficientintervaloverlap
testingispossiblewithanumberofquerystructures.
Oneofthemostflexiblestructurestomaintainsuchinformationwithgoodaccesstime
istheprioritysearchtree(McCreight1985).Thebalancedvariantofthisdatastructurecan
insertanddeleteinO(log n)timefornsegmentsand,givenaquerysegment,canenumer-
atealloverlappingsegmentsinO(log n + k)timeforkresultsegments.Aprioritysearchtree
canbeusedsothatthefirstoverlappingsegmentfoundinanysearchwillbetheonewith
thelargestrightendpoint.Thisendpointisagoodstartingpointinsearchingforthenext
deletioninthesequence.Inthecaseofmanyoverlappingregions,itisaproblemtoperform
Previous Page Next Page