diff_myers: Diff two character vectors

Description Usage Arguments Details Value

View source: R/core.R

Description

Implementation of Myer's Diff algorithm with linear space refinement originally implemented by Mike B. Allen as part of libmba version 0.9.1. This implementation is a heavily modified version of the original C code and is not compatible with the libmba library. The C code is simplified by using fixed size arrays instead of variable ones for tracking the longest reaching paths and for recording the shortest edit scripts. Additionally all error handling and memory allocation calls have been moved to the internal R functions designed to handle those things. A failover result is provided in the case where max diffs allowed is exceeded. Ability to provide custom comparison functions is removed.

Usage

1
diff_myers(a, b, max.diffs = -1L, warn = FALSE)

Arguments

a

character

b

character

max.diffs

integer(1L) how many differences before giving up; set to -1 to allow as many as there are up to the maximum allowed (~INT_MAX/4).

warn

TRUE or FALSE, whether to warn if we hit 'max.diffs'.

Details

The result format indicates operations required to convert a into b in a precursor format to the GNU diff shortest edit script. The operations are “Match” (do nothing), “Insert” (insert one or more values of b into a), and “Delete” (remove one or more values from a). The length slot dictates how many values to advance along, insert into, or delete from a. The offset slot changes meaning depending on the operation. For “Match” and “Delete”, it is the starting index of that operation in a. For “Insert”, it is the starting index in b of the values to insert into a; the index in a to insert at is implicit in previous operations.

Value

MyersMbaSes object


diffobj documentation built on Oct. 5, 2021, 9:07 a.m.