The proposed algorithm for cut-paste string composite operation ITCutPaste (Inclusive Transformation of Cut-Paste) is based on inclusive transformation of operational transformation. The algorithm ABTS (Shao et al. 2009), already contains ITII (Inclusive Transformation of Insert–Insert)/ITID (Inclusive Transformation of Insert–Delete)/ITDD (Inclusive Transformation of Delete–Delete)/ITDI (Inclusive Transformation of Delete–Insert) algorithms for transformation of insert and delete string operations. So to perform cut-paste operation, first the substring ‘s’ get deleted from p by operation delete(s, p) and then ‘s’ get inserted at position q by operation insert(s, q). Here, delete(s, p) and insert(s, q) are independent operations. At all sharing sites, transformation functions corresponding to both delete(p, s) and insert(q, s) get called which results in increase in the time complexity.
This research work proposes a single transformation algorithm for composite string operation cut-paste. So all sites require only single transformation function for cut-paste operation. The time complexity of transformation function ITCutPaste for cut-paste operation is same as transformation function for insert or delete ITDI/ITID. It is based on inclusive transformation and ABT Framework so it can be formally proved.
Type of operations
ITCutPaste consists of operations o1, o2 as input and o1′ as output. Operations o1, o2 and o1′ may be string or character operations which operate on shared data in multi-user groupware collaborative applications like group editors.
o1 and o2 are contextually equivalent o1||o2, o1Uo2 and if input is o1 and output then output should be o2→o1′.
Design and analysis of algorithms
ITCutPaste consists many sub-algorithms ITDCp (Inclusive Transformation of Deletion with Cut-Paste), ITICp (Inclusive Transformation of Insertion with Cut-Paste), ITCpI (Inclusive Transformation of Cut-Paste with Insertion), and ITCpD (Inclusive Transformation of Cut-Paste with Deletion). The proposed algorithm satisfies causality and admissibility preservation.
If we have exec(oi), then all exec(oi−1) must be completed then only oi satisfies causality.
If o1Uo2 then IT(o1,o2) satisfies admissibility. It does not have inconsistent order at shared environment.
Let H is admissible history of operation which satisfies causality. Also, sq is a sequence of operations and sq~
~H. Then, if o is executed in state s, we have exec(s, H). There should be sq′~~ (sq.o) and sq′ must be consistent.
The ITCutPaste(o1, o2) transforms o1 with another operation o2 with output of this function is o1′. The precondition of ITCutPaste(o1, o2) is o1Uo2 and the post-condition is o2→o1′. The following “Type of operations” presented the algorithm ITDCp and “Design and analysis of algorithms” presented the algorithm ITICp. In algorithm ITCutPaste if o1 operation type is insert and o2 operation type is CutPaste then ITICp is called and if o1 operation type is delete and o2 operation type is CutPaste then ITDCp is called. If o1 operation type is CutPaste and o2 operation type is insert, then ITCpI is called and if o1 operation type is CutPaste and o2 operation type is delete then ITCpD is called.
Algorithm ITDCp takes as parameters o1 and o2 and return o1′. Here, o1 is deletion operation and o2 is Cut-Paste operation. Here, precondition is o1Uo2 and post-condition is o2→o1′. GSMRITFDD(o1, o2) used in Algorithm ITDCp is transformation algorithm to transform o1 (delete) and o2 (delete) operations.
Algorithm ITICp takes as parameters o1 and o2 and return o1′. Here, o1 is insertion operation and o2 is Cut-Paste operation. Here, precondition is o1Uo2 and post-condition is o2→o1′.
The new algorithm GSMRITFDD is proposed that removed all faults of existing ITDD (Shao et al. 2009) for inclusive transformation of two deletions and work well in all possible cases. It needs to consider the following cases regarding the relations between the two target regions, R1 = s [o1.pos :(|o1.str| + o1.pos)] and R2 = s[o2.pos:(|o2.pos| + |o2.str|)]
Consider the following cases regarding the relations between the two target regions, R2 = s [o2.pos: (o2.pos + lo2.strl)] and R1 = s [o1.pos: (lo1.strl + o1.pos)].
(By line-9) When R2 is completely on the right of R1. In this case, Deletion of R2 does not affect o1 and hence o1 is returned as-is.
(By line-7) If R1 is on the right of R2. In this case, after R2 is deleted, we shift o1′.pos by 1o2.strl characters to the left to get transformed string operation o1′.
(By line-16) R1 is included in R2. In this case, after o2 is executed, R1 is already deleted. So there is no longer need to execute o1. That is why it returns an empty operation ¢.
(By line-13) When R2 partially overlaps with R1 around the left border of R1. After o2 is executed, the left part of R1 is already deleted. Hence, in this case, we need to reset o1.pos so that it will start from (o2.pos). So o1.str only needs to include the right part that is not deleted by o2, starting from (o2.pos + lo2.strl)—o1.pos in the original o1.str.
(By line-11) When R2 partially overlaps with R1 around the right border of R1. In this case, this is similar to case (4). After o2 is executed, o1 only needs to delete the left part that is not deleted by o2.
(By line-18) R2 is included in R1. The deletion of R2 within R1 divides R1 into three parts, among which the middle overlapping part is already deleted by o2. Hence, o1 must be split into two sub-operations that delete the two remaining substrings left and right, respectively.