libabigail
Classes | Functions
abigail::diff_utils Namespace Reference

Libabigail's core diffing algorithms. More...

Classes

class  d_path_vec
 The array containing the furthest D-path end-points, for each value of K. MAX_D is the maximum value of the D-Path. That is, M+N if M is the size of the first input string, and N is the size of the second. More...
 
struct  deep_ptr_eq_functor
 An equality functor to deeply compare pointers. More...
 
struct  default_eq_functor
 The default equality functor used by the core diffing algorithms. More...
 
class  deletion
 The abstraction of the deletion of one element of a sequence A. More...
 
class  edit_script
 The abstraction of an edit script for transforming a sequence A into a sequence B. More...
 
class  insertion
 The abstration of an insertion of elements of a sequence B into a sequence A. This is used to represent the edit script for transforming a sequence A into a sequence B. More...
 
class  point
 A class representing a vertex in an edit graph, as explained in the paper. A vertex is a basically a pair of coordinates (abscissa and ordinate). More...
 
class  snake
 The abstraction of the Snake concept, from the paper. More...
 

Functions

template<typename RandomAccessOutputIterator , typename EqualityFunctor >
void compute_diff (RandomAccessOutputIterator a_base, RandomAccessOutputIterator a_begin, RandomAccessOutputIterator a_end, RandomAccessOutputIterator b_base, RandomAccessOutputIterator b_begin, RandomAccessOutputIterator b_end, edit_script &ses)
 Compute the longest common subsequence of two (sub-regions of) sequences as well as the shortest edit script from transforming the first (sub-region of) sequence into the second (sub-region of) sequence. More...
 
template<typename RandomAccessOutputIterator , typename EqualityFunctor >
void compute_diff (RandomAccessOutputIterator a_base, RandomAccessOutputIterator a_begin, RandomAccessOutputIterator a_end, RandomAccessOutputIterator b_base, RandomAccessOutputIterator b_begin, RandomAccessOutputIterator b_end, vector< point > &lcs, edit_script &ses)
 Compute the longest common subsequence of two (sub-regions of) sequences as well as the shortest edit script from transforming the first (sub-region of) sequence into the second (sub-region of) sequence. More...
 
template<typename RandomAccessOutputIterator , typename EqualityFunctor >
void compute_diff (RandomAccessOutputIterator a_base, RandomAccessOutputIterator a_begin, RandomAccessOutputIterator a_end, RandomAccessOutputIterator b_base, RandomAccessOutputIterator b_begin, RandomAccessOutputIterator b_end, vector< point > &lcs, edit_script &ses, int &ses_len)
 Compute the longest common subsequence of two (sub-regions of) sequences as well as the shortest edit script from transforming the first (sub-region of) sequence into the second (sub-region of) sequence. More...
 
template<typename RandomAccessOutputIterator , typename EqualityFunctor >
void compute_diff (RandomAccessOutputIterator a_begin, RandomAccessOutputIterator a_end, RandomAccessOutputIterator b_begin, RandomAccessOutputIterator b_end, edit_script &ses)
 Compute the longest common subsequence of two (sub-regions of) sequences as well as the shortest edit script from transforming the first (sub-region of) sequence into the second (sub-region of) sequence. More...
 
template<typename RandomAccessOutputIterator >
void compute_diff (RandomAccessOutputIterator a_begin, RandomAccessOutputIterator a_end, RandomAccessOutputIterator b_begin, RandomAccessOutputIterator b_end, edit_script &ses)
 Compute the longest common subsequence of two (sub-regions of) sequences as well as the shortest edit script from transforming the first (sub-region of) sequence into the second (sub-region of) sequence. More...
 
template<typename RandomAccessOutputIterator , typename EqualityFunctor >
void compute_diff (RandomAccessOutputIterator a_begin, RandomAccessOutputIterator a_end, RandomAccessOutputIterator b_begin, RandomAccessOutputIterator b_end, vector< point > &lcs, edit_script &ses)
 Compute the longest common subsequence of two (sub-regions of) sequences as well as the shortest edit script from transforming the first (sub-region of) sequence into the second (sub-region of) sequence. More...
 
template<typename RandomAccessOutputIterator >
void compute_diff (RandomAccessOutputIterator a_begin, RandomAccessOutputIterator a_end, RandomAccessOutputIterator b_begin, RandomAccessOutputIterator b_end, vector< point > &lcs, edit_script &ses)
 Compute the longest common subsequence of two (sub-regions of) sequences as well as the shortest edit script from transforming the first (sub-region of) sequence into the second (sub-region of) sequence. More...
 
template<typename RandomAccessOutputIterator , typename EqualityFunctor >
void compute_diff (RandomAccessOutputIterator a_begin, RandomAccessOutputIterator a_end, RandomAccessOutputIterator b_begin, RandomAccessOutputIterator b_end, vector< point > &lcs, edit_script &ses, int &ses_len)
 Compute the longest common subsequence of two (sub-regions of) sequences as well as the shortest edit script from transforming the first (sub-region of) sequence into the second (sub-region of) sequence. More...
 
void compute_lcs (const char *str1, const char *str2, int &ses_len, string &lcs)
 Compute the longest common subsequence of two strings and return the length of the shortest edit script for transforming the first string into the second. More...
 
bool compute_middle_snake (const char *str1, const char *str2, snake &s, int &ses_len)
 Returns the middle snake of two strings, as well as the length of their shortest editing script. More...
 
template<typename RandomAccessOutputIterator , typename EqualityFunctor >
bool compute_middle_snake (RandomAccessOutputIterator a_begin, RandomAccessOutputIterator a_end, RandomAccessOutputIterator b_begin, RandomAccessOutputIterator b_end, snake &snak, int &ses_len)
 Returns the middle snake of two sequences A and B, as well as the length of their shortest editing script. More...
 
void compute_ses (const char *str1, const char *str2, edit_script &ses)
 Compute the shortest edit script for transforming a string into another. More...
 
template<typename RandomAccessOutputIterator >
void display_edit_script (const edit_script &es, const RandomAccessOutputIterator str1_base, const RandomAccessOutputIterator str2_base, ostream &out)
 Display an edit script on standard output. More...
 
template<typename RandomAccessOutputIterator , typename EqualityFunctor >
bool end_of_fr_d_path_in_k (int k, int d, RandomAccessOutputIterator a_begin, RandomAccessOutputIterator a_end, RandomAccessOutputIterator b_start, RandomAccessOutputIterator b_end, d_path_vec &v, snake &snak)
 Find the end of the furthest reaching d-path on diagonal k, for two sequences. In the paper This is referred to as "the basic algorithm". More...
 
template<typename RandomAccessOutputIterator , typename EqualityFunctor >
bool end_of_frr_d_path_in_k_plus_delta (int k, int d, RandomAccessOutputIterator a_begin, RandomAccessOutputIterator a_end, RandomAccessOutputIterator b_begin, RandomAccessOutputIterator b_end, d_path_vec &v, snake &snak)
 Find the end of the furthest reaching reverse d-path on diagonal k + delta. Delta is abs(M - N), with M being the size of a and N being the size of b. This is the "basic algorithm", run backward. That is, starting from the point (M,N) of the edit graph. More...
 
bool ends_of_furthest_d_paths_overlap (const point &forward_d_path_end, const point &reverse_d_path_end)
 
template<typename RandomAccessOutputIterator >
bool is_match_point (RandomAccessOutputIterator a_begin, RandomAccessOutputIterator a_end, RandomAccessOutputIterator b_begin, RandomAccessOutputIterator b_end, const point &point)
 Tests if a given point is a match point in an edit graph. More...
 
bool point_is_valid_in_graph (point &p, unsigned a_size, unsigned b_size)
 
template<typename RandomAccessOutputIterator >
void print_snake (RandomAccessOutputIterator a_begin, RandomAccessOutputIterator b_begin, const snake &s, ostream &out)
 This prints the middle snake of two strings. More...
 
int ses_len (const char *str1, const char *str2, bool reverse)
 Compute the length of the shortest edit script for two strings. This is done using the "Greedy LCS/SES" of figure 2 in the paper. It can walk the edit graph either foward (when reverse is false) or backward starting from the end (when reverse is true). More...
 
template<typename RandomAccessOutputIterator , typename EqualityFunctor >
int ses_len (RandomAccessOutputIterator a_begin, RandomAccessOutputIterator a_end, RandomAccessOutputIterator b_begin, RandomAccessOutputIterator b_end, d_path_vec &v, bool reverse)
 Compute the length of the shortest edit script for two sequences a and b. This is done using the "Greedy LCS/SES" of figure 2 in the paper. It can walk the edit graph either foward (when reverse is false) or backward starting from the end (when reverse is true). More...
 
template<typename RandomAccessOutputIterator >
int ses_len (RandomAccessOutputIterator a_begin, RandomAccessOutputIterator a_end, RandomAccessOutputIterator b_begin, RandomAccessOutputIterator b_end, d_path_vec &v, bool reverse)
 Compute the length of the shortest edit script for two sequences a and b. This is done using the "Greedy LCS/SES" of figure 2 in the paper. It can walk the edit graph either foward (when reverse is false) or backward starting from the end (when reverse is true). More...
 
bool snake_end_points (const snake &s, point &x, point &u)
 Get the end points of the snake, as intended by the paper. More...
 

Detailed Description

Libabigail's core diffing algorithms.

This is the namespace defining the core diffing algorithm used by libabigail comparison tools. This based on the diff algorithm from Eugene Myers.

Function Documentation

◆ compute_diff() [1/8]

void abigail::diff_utils::compute_diff ( RandomAccessOutputIterator  a_base,
RandomAccessOutputIterator  a_begin,
RandomAccessOutputIterator  a_end,
RandomAccessOutputIterator  b_base,
RandomAccessOutputIterator  b_begin,
RandomAccessOutputIterator  b_end,
edit_script ses 
)

Compute the longest common subsequence of two (sub-regions of) sequences as well as the shortest edit script from transforming the first (sub-region of) sequence into the second (sub-region of) sequence.

A sequence is determined by a base, a beginning offset and an end offset. The base always points to the container that contains the sequence to consider. The beginning offset is an iterator that points the beginning of the sub-region of the sequence that we actually want to consider. The end offset is an iterator that points to the end of the sub-region of the sequence that we actually want to consider.

This uses the LCS algorithm of the paper at section 4b.

@tparm RandomAccessOutputIterator the type of iterators passed to this function. It must be a random access output iterator kind.

@tparm EqualityFunctor this must be a class that declares a public call operator member returning a boolean and taking two arguments that must be of the same type as the one pointed to by the RandomAccessOutputIterator template parameter. This functor is used to compare the elements referred to by the iterators passed in argument to this function.

Parameters
a_basethe iterator to the base of the first sequence.
a_startan iterator to the beginning of the sub-region of the first sequence to actually consider.
a_endan iterator to the end of the sub-region of the first sequence to consider.
b_basean iterator to the base of the second sequence to consider.
b_startan iterator to the beginning of the sub-region of the second sequence to actually consider.
b_endan iterator to the end of the sub-region of the second sequence to actually consider.
sesthe resulting shortest editing script.
Returns
true upon successful completion, false otherwise.

Definition at line 1908 of file abg-diff-utils.h.

◆ compute_diff() [2/8]

void abigail::diff_utils::compute_diff ( RandomAccessOutputIterator  a_base,
RandomAccessOutputIterator  a_begin,
RandomAccessOutputIterator  a_end,
RandomAccessOutputIterator  b_base,
RandomAccessOutputIterator  b_begin,
RandomAccessOutputIterator  b_end,
vector< point > &  lcs,
edit_script ses 
)

Compute the longest common subsequence of two (sub-regions of) sequences as well as the shortest edit script from transforming the first (sub-region of) sequence into the second (sub-region of) sequence.

A sequence is determined by a base, a beginning offset and an end offset. The base always points to the container that contains the sequence to consider. The beginning offset is an iterator that points the beginning of the sub-region of the sequence that we actually want to consider. The end offset is an iterator that points to the end of the sub-region of the sequence that we actually want to consider.

This uses the LCS algorithm of the paper at section 4b.

@tparm RandomAccessOutputIterator the type of iterators passed to this function. It must be a random access output iterator kind.

@tparm EqualityFunctor this must be a class that declares a public call operator member returning a boolean and taking two arguments that must be of the same type as the one pointed to by the RandomAccessOutputIterator template parameter. This functor is used to compare the elements referred to by the iterators passed in argument to this function.

Parameters
a_basethe iterator to the base of the first sequence.
a_startan iterator to the beginning of the sub-region of the first sequence to actually consider.
a_endan iterator to the end of the sub-region of the first sequence to consider.
b_basean iterator to the base of the second sequence to consider.
b_startan iterator to the beginning of the sub-region of the second sequence to actually consider.
b_endan iterator to the end of the sub-region of the second sequence to actually consider.
lcsthe resulting lcs. This is set iff the function returns true.
sesthe resulting shortest editing script.
Returns
true upon successful completion, false otherwise.

Definition at line 1751 of file abg-diff-utils.h.

◆ compute_diff() [3/8]

void abigail::diff_utils::compute_diff ( RandomAccessOutputIterator  a_base,
RandomAccessOutputIterator  a_begin,
RandomAccessOutputIterator  a_end,
RandomAccessOutputIterator  b_base,
RandomAccessOutputIterator  b_begin,
RandomAccessOutputIterator  b_end,
vector< point > &  lcs,
edit_script ses,
int &  ses_len 
)

Compute the longest common subsequence of two (sub-regions of) sequences as well as the shortest edit script from transforming the first (sub-region of) sequence into the second (sub-region of) sequence.

A sequence is determined by a base, a beginning offset and an end offset. The base always points to the container that contains the sequence to consider. The beginning offset is an iterator that points the beginning of the sub-region of the sequence that we actually want to consider. The end offset is an iterator that points to the end of the sub-region of the sequence that we actually want to consider.

This uses the LCS algorithm of the paper at section 4b.

@tparm RandomAccessOutputIterator the type of iterators passed to this function. It must be a random access output iterator kind.

@tparm EqualityFunctor this must be a class that declares a public call operator member returning a boolean and taking two arguments that must be of the same type as the one pointed to by the RandomAccessOutputIterator template parameter. This functor is used to compare the elements referred to by the iterators passed in argument to this function.

Parameters
a_basethe iterator to the base of the first sequence.
a_startan iterator to the beginning of the sub-region of the first sequence to actually consider.
a_endan iterator to the end of the sub-region of the first sequence to consider.
b_basean iterator to the base of the second sequence to consider.
b_startan iterator to the beginning of the sub-region of the second sequence to actually consider.
b_endan iterator to the end of the sub-region of the second sequence to actually consider.
lcsthe resulting lcs. This is set iff the function returns true.
sesthe resulting shortest editing script.
ses_lenthe length of the ses above. Normally this can be retrieved from ses.length(), but this parameter is here for sanity check purposes. The function computes the length of the ses in two redundant ways and ensures that both methods lead to the same result.
Returns
true upon successful completion, false otherwise.

Definition at line 1482 of file abg-diff-utils.h.

◆ compute_diff() [4/8]

void abigail::diff_utils::compute_diff ( RandomAccessOutputIterator  a_begin,
RandomAccessOutputIterator  a_end,
RandomAccessOutputIterator  b_begin,
RandomAccessOutputIterator  b_end,
edit_script ses 
)

Compute the longest common subsequence of two (sub-regions of) sequences as well as the shortest edit script from transforming the first (sub-region of) sequence into the second (sub-region of) sequence.

This uses the LCS algorithm of the paper at section 4b.

@tparm RandomAccessOutputIterator the type of iterators passed to this function. It must be a random access output iterator kind.

@tparm EqualityFunctor this must be a class that declares a public call operator member returning a boolean and taking two arguments that must be of the same type as the one pointed to by the RandomAccessOutputIterator template parameter. This functor is used to compare the elements referred to by the iterators passed in argument to this function.

Parameters
a_startan iterator to the beginning of the first sequence to consider.
a_endan iterator to the end of the first sequence to consider.
b_startan iterator to the beginning of the second sequence to consider.
b_endan iterator to the end of the second sequence to consider.
sesthe resulting shortest editing script.
Returns
true upon successful completion, false otherwise.

Definition at line 1959 of file abg-diff-utils.h.

◆ compute_diff() [5/8]

void abigail::diff_utils::compute_diff ( RandomAccessOutputIterator  a_begin,
RandomAccessOutputIterator  a_end,
RandomAccessOutputIterator  b_begin,
RandomAccessOutputIterator  b_end,
edit_script ses 
)

Compute the longest common subsequence of two (sub-regions of) sequences as well as the shortest edit script from transforming the first (sub-region of) sequence into the second (sub-region of) sequence.

This uses the LCS algorithm of the paper at section 4b.

@tparm RandomAccessOutputIterator the type of iterators passed to this function. It must be a random access output iterator kind.

Parameters
a_startan iterator to the beginning of the first sequence to consider.
a_endan iterator to the end of the first sequence to consider.
b_startan iterator to the beginning of the second sequence to consider.
b_endan iterator to the end of the second sequence to consider.
sesthe resulting shortest editing script.
Returns
true upon successful completion, false otherwise.

Definition at line 1998 of file abg-diff-utils.h.

◆ compute_diff() [6/8]

void abigail::diff_utils::compute_diff ( RandomAccessOutputIterator  a_begin,
RandomAccessOutputIterator  a_end,
RandomAccessOutputIterator  b_begin,
RandomAccessOutputIterator  b_end,
vector< point > &  lcs,
edit_script ses 
)

Compute the longest common subsequence of two (sub-regions of) sequences as well as the shortest edit script from transforming the first (sub-region of) sequence into the second (sub-region of) sequence.

This uses the LCS algorithm of the paper at section 4b.

@tparm RandomAccessOutputIterator the type of iterators passed to this function. It must be a random access output iterator kind.

@tparm EqualityFunctor this must be a class that declares a public call operator member returning a boolean and taking two arguments that must be of the same type as the one pointed to by the RandomAccessOutputIterator template parameter. This functor is used to compare the elements referred to by the iterators passed in argument to this function.

Parameters
a_startan iterator to the beginning of the first sequence to consider.
a_endan iterator to the end of the first sequence to consider.
b_startan iterator to the beginning of the sequence to actually consider.
b_endan iterator to the end of second sequence to consider.
lcsthe resulting lcs. This is set iff the function returns true.
sesthe resulting shortest editing script.
Returns
true upon successful completion, false otherwise.

Definition at line 1806 of file abg-diff-utils.h.

◆ compute_diff() [7/8]

void abigail::diff_utils::compute_diff ( RandomAccessOutputIterator  a_begin,
RandomAccessOutputIterator  a_end,
RandomAccessOutputIterator  b_begin,
RandomAccessOutputIterator  b_end,
vector< point > &  lcs,
edit_script ses 
)

Compute the longest common subsequence of two (sub-regions of) sequences as well as the shortest edit script from transforming the first (sub-region of) sequence into the second (sub-region of) sequence.

This uses the LCS algorithm of the paper at section 4b.

@tparm RandomAccessOutputIterator the type of iterators passed to this function. It must be a random access output iterator kind.

Parameters
a_startan iterator to the beginning of the first sequence to consider.
a_endan iterator to the end of the first sequence to consider.
b_startan iterator to the beginning of the sequence to actually consider.
b_endan iterator to the end of second sequence to consider.
lcsthe resulting lcs. This is set iff the function returns true.
sesthe resulting shortest editing script.
Returns
true upon successful completion, false otherwise.

Definition at line 1849 of file abg-diff-utils.h.

◆ compute_diff() [8/8]

void abigail::diff_utils::compute_diff ( RandomAccessOutputIterator  a_begin,
RandomAccessOutputIterator  a_end,
RandomAccessOutputIterator  b_begin,
RandomAccessOutputIterator  b_end,
vector< point > &  lcs,
edit_script ses,
int &  ses_len 
)

Compute the longest common subsequence of two (sub-regions of) sequences as well as the shortest edit script from transforming the first (sub-region of) sequence into the second (sub-region of) sequence.

This uses the LCS algorithm of the paper at section 4b.

@tparm RandomAccessOutputIterator the type of iterators passed to this function. It must be a random access output iterator kind.

@tparm EqualityFunctor this must be a class that declares a public call operator member returning a boolean and taking two arguments that must be of the same type as the one pointed to by the RandomAccessOutputIterator template parameter. This functor is used to compare the elements referred to by the iterators passed in argument to this function.

Parameters
a_startan iterator to the beginning of the first sequence to consider.
a_endan iterator to the end of the first sequence to consider.
b_startan iterator to the beginning of the second sequence to consider.
b_endan iterator to the end of the second sequence to consider.
lcsthe resulting lcs. This is set iff the function returns true.
sesthe resulting shortest editing script.
ses_lenthe length of the ses above. Normally this can be retrieved from ses.length(), but this parameter is here for sanity check purposes. The function computes the length of the ses in two redundant ways and ensures that both methods lead to the same result.
Returns
true upon successful completion, false otherwise.

Definition at line 1686 of file abg-diff-utils.h.

◆ compute_lcs()

void compute_lcs ( const char *  str1,
const char *  str2,
int &  ses_len,
string &  lcs 
)

Compute the longest common subsequence of two strings and return the length of the shortest edit script for transforming the first string into the second.

Parameters
str1the first string to consider.
str2the second string to consider.
ses_lenthe length of the shortest edit script. This is set by the function iff it returns true.
thelongest common subsequence of the two strings. This is set the function iff it returns true.
Returns
true if the function could compute an lcs, false otherwise.

Definition at line 157 of file abg-diff-utils.cc.

◆ compute_middle_snake() [1/2]

bool compute_middle_snake ( const char *  str1,
const char *  str2,
snake s,
int &  ses_len 
)

Returns the middle snake of two strings, as well as the length of their shortest editing script.

Parameters
str1the first string to consider.
str2the second string to consider.
snake_beginthe point representing the beginning

Definition at line 97 of file abg-diff-utils.cc.

◆ compute_middle_snake() [2/2]

bool abigail::diff_utils::compute_middle_snake ( RandomAccessOutputIterator  a_begin,
RandomAccessOutputIterator  a_end,
RandomAccessOutputIterator  b_begin,
RandomAccessOutputIterator  b_end,
snake snak,
int &  ses_len 
)

Returns the middle snake of two sequences A and B, as well as the length of their shortest editing script.

This uses the "linear space refinement" algorithm presented in section 4b in the paper. As the paper says, "The idea for doing so is to simultaneously run the basic algorithm in both the forward and reverse directions until furthest reaching forward and reverse paths starting at opposing corners 'overlap'."

@tparm RandomAccessOutputIterator the type of iterators passed to this function. It must be a random access output iterator kind.

@tparm EqualityFunctor this must be a class that declares a public call operator member returning a boolean and taking two arguments that must be of the same type as the one pointed to by the RandomAccessOutputIterator template parameter. This functor is used to compare the elements referred to by the iterators passed in argument to this function.

Parameters
a_beginan iterator pointing to the begining of sequence A.
a_endan iterator pointing to the end of sequence A. Note that this points right /after/ the end of vector A.
b_beginan iterator pointing to the begining of sequence B.
b_endan iterator pointing to the end of sequence B. Note that this points right /after/ the end of vector B
snakout parameter. This is the snake current when the two paths overlapped. This is set iff the function returns true; otherwise, this is not touched.
Returns
true is the snake was found, false otherwise.

Definition at line 1140 of file abg-diff-utils.h.

◆ compute_ses()

void compute_ses ( const char *  str1,
const char *  str2,
edit_script ses 
)

Compute the shortest edit script for transforming a string into another.

Parameters
str1the first string to consider.
str2the second string to consider.
sesthe resulting edit script.

@pram ses_len the length of the edit script.

Definition at line 187 of file abg-diff-utils.cc.

◆ display_edit_script()

void abigail::diff_utils::display_edit_script ( const edit_script es,
const RandomAccessOutputIterator  str1_base,
const RandomAccessOutputIterator  str2_base,
ostream &  out 
)

Display an edit script on standard output.

Parameters
esthe edit script to display
str1_basethe first string the edit script is about.

@pram str2_base the second string the edit script is about.

Definition at line 2024 of file abg-diff-utils.h.

◆ end_of_fr_d_path_in_k()

bool abigail::diff_utils::end_of_fr_d_path_in_k ( int  k,
int  d,
RandomAccessOutputIterator  a_begin,
RandomAccessOutputIterator  a_end,
RandomAccessOutputIterator  b_start,
RandomAccessOutputIterator  b_end,
d_path_vec v,
snake snak 
)

Find the end of the furthest reaching d-path on diagonal k, for two sequences. In the paper This is referred to as "the basic algorithm".

Unlike in the paper, the coordinates of the edit graph start at (-1,-1), rather than (0,0), and they end at (M-1, N-1), rather than (M,N).

@tparm RandomAccessOutputIterator the type of iterators passed to this function. It must be a random access output iterator kind.

@tparm EqualityFunctor this must be a class that declares a public call operator member returning a boolean and taking two arguments that must be of the same type as the one pointed to by the RandomAccessOutputIterator template parameter. This functor is used to compare the elements referred to by the iterators passed in argument to this function.

Parameters
kthe number of the diagonal on which we want to find the end of the furthest reaching D-path.
dthe D in D-Path. That's the number of insertions/deletions (the number of changes, in other words) in the changeset. That is also the number of non-diagonals in the D-Path.
a_beginan iterator to the beginning of the first sequence
a_endan iterator that points right after the last element of the second sequence to consider.
b_beginan iterator to the beginning of the second sequence.
b_endan iterator that points right after the last element of the second sequence to consider.
vthe vector of furthest end points of d_paths, at (d-1). It contains the abscissas of the furthest end points for different values of k, at (d-1). That is, for k in [-D + 1, -D + 3, -D + 5, ..., D - 1], v[k] is the abscissa of the end of the furthest reaching (D-1)-path on diagonal k.
snakthe last snake of the furthest path found. The end point of the snake is the end point of the furthest path.
Returns
true if the end of the furthest reaching path that was found was inside the boundaries of the edit graph, false otherwise.

Definition at line 841 of file abg-diff-utils.h.

◆ end_of_frr_d_path_in_k_plus_delta()

bool abigail::diff_utils::end_of_frr_d_path_in_k_plus_delta ( int  k,
int  d,
RandomAccessOutputIterator  a_begin,
RandomAccessOutputIterator  a_end,
RandomAccessOutputIterator  b_begin,
RandomAccessOutputIterator  b_end,
d_path_vec v,
snake snak 
)

Find the end of the furthest reaching reverse d-path on diagonal k + delta. Delta is abs(M - N), with M being the size of a and N being the size of b. This is the "basic algorithm", run backward. That is, starting from the point (M,N) of the edit graph.

Unlike in the paper, the coordinates of the edit graph start at (-1,-1), rather than (0,0), and they end at (M-1, N-1), rather than (M,N).

@tparm RandomAccessOutputIterator the type of iterators passed to this function. It must be a random access output iterator kind.

@tparm EqualityFunctor this must be a class that declares a public call operator member returning a boolean and taking two arguments that must be of the same type as the one pointed to by the RandomAccessOutputIterator template parameter. This functor is used to compare the elements referred to by the iterators passed in argument to this function.

Parameters
kthe number of the diagonal on which we want to find the end of the furthest reaching reverse D-path. Actually, we want to find the end of the furthest reaching reverse D-path on diagonal (k
  • delta).
dthe D in D-path. That's the number of insertions/deletions (the number of changes, in other words) in the changeset. That is also the number of non-diagonals in the D-Path.
a_beginan iterator to the beginning of the first sequence
a_endan iterator that points right after the last element of the second sequence to consider.
b_beginan iterator to the beginning of the second sequence.
b_endan iterator that points right after the last element of the second sequence to consider.
vthe vector of furthest end points of d_paths, at (d-1). It contains the abscissae of the furthest end points for different values of k - delta, at (d-1). That is, for k in [-D + 1, -D + 3, -D + 5, ..., D - 1], v[k - delta] is the abscissa of the end of the furthest reaching (D-1)-path on diagonal k - delta.
snakthe last snake of the furthest path found. The end point of the snake is the end point of the furthest path.
Returns
true iff the end of the furthest reaching path that was found was inside the boundaries of the edit graph, false otherwise.

Definition at line 982 of file abg-diff-utils.h.

◆ ends_of_furthest_d_paths_overlap()

bool ends_of_furthest_d_paths_overlap ( const point forward_d_path_end,
const point reverse_d_path_end 
)
Returns
true iff the end of a furthest forward d_path overlaps the end of a furtherst reverse d_path on the same diagonal. This is defined by the lemma 3 of the paper.
Parameters
forward_d_path_end

Definition at line 32 of file abg-diff-utils.cc.

◆ is_match_point()

bool abigail::diff_utils::is_match_point ( RandomAccessOutputIterator  a_begin,
RandomAccessOutputIterator  a_end,
RandomAccessOutputIterator  b_begin,
RandomAccessOutputIterator  b_end,
const point point 
)

Tests if a given point is a match point in an edit graph.

Parameters
a_beginthe begin iterator of the first input sequence of the edit graph.
a_endthe end iterator of the first input sequence of the edit graph. This points to one element passed the end of the sequence.
b_beginthe begin iterator of the second input sequence of the edit graph.
b_endthe end iterator of the second input sequence of the edit graph. This points the one element passed the end of the sequence.
pointthe point to test for being a match point.
Returns
true iff point is a match point.

Definition at line 1086 of file abg-diff-utils.h.

◆ point_is_valid_in_graph()

bool point_is_valid_in_graph ( point p,
unsigned  a_size,
unsigned  b_size 
)
Parameters
pthe point to test.
a_sizethe size of abscissas. That is, the size of the first input to consider.
b_sizethe of ordinates. That is, the size of the second input to consider.
Returns
true iff a point is within the boundaries of the edit graph.

Definition at line 52 of file abg-diff-utils.cc.

◆ print_snake()

void abigail::diff_utils::print_snake ( RandomAccessOutputIterator  a_begin,
RandomAccessOutputIterator  b_begin,
const snake s,
ostream &  out 
)

This prints the middle snake of two strings.

Parameters
a_beginthe beginning of the first string.
b_beginthe beginning of the second string.
sthe snake to print.
outthe output stream to print the snake to.

Definition at line 1266 of file abg-diff-utils.h.

◆ ses_len() [1/3]

int ses_len ( const char *  str1,
const char *  str2,
bool  reverse 
)

Compute the length of the shortest edit script for two strings. This is done using the "Greedy LCS/SES" of figure 2 in the paper. It can walk the edit graph either foward (when reverse is false) or backward starting from the end (when reverse is true).

Parameters
str1the first string to consider.
str2the second string to consider.
reversewhen true, walk the edit graph backward, starting from the point (M,N) (with M and N being the length of str1 and str2). When false, walk the edit graph forward, starting from the point (0,0).
Returns
the length of the shortest edit script.

Definition at line 128 of file abg-diff-utils.cc.

◆ ses_len() [2/3]

int abigail::diff_utils::ses_len ( RandomAccessOutputIterator  a_begin,
RandomAccessOutputIterator  a_end,
RandomAccessOutputIterator  b_begin,
RandomAccessOutputIterator  b_end,
d_path_vec v,
bool  reverse 
)

Compute the length of the shortest edit script for two sequences a and b. This is done using the "Greedy LCS/SES" of figure 2 in the paper. It can walk the edit graph either foward (when reverse is false) or backward starting from the end (when reverse is true).

Here, note that the real content of a and b should start at index 1, for this implementatikon algorithm to match the paper's algorithm in a straightforward manner. So pleast make sure that at index 0, we just get some non-used value.

@tparm RandomAccessOutputIterator the type of iterators passed to this function. It must be a random access output iterator kind.

@tparm EqualityFunctor this must be a class that declares a public call operator member returning a boolean and taking two arguments that must be of the same type as the one pointed to by the RandomAccessOutputIterator template parameter. This functor is used to compare the elements referred to by the iterators passed in argument to this function.

Parameters
athe first sequence we care about.
bthe second sequence we care about.
vthe vector that contains the end points of the furthest reaching d-path and (d-1)-path.

Definition at line 1323 of file abg-diff-utils.h.

◆ ses_len() [3/3]

int abigail::diff_utils::ses_len ( RandomAccessOutputIterator  a_begin,
RandomAccessOutputIterator  a_end,
RandomAccessOutputIterator  b_begin,
RandomAccessOutputIterator  b_end,
d_path_vec v,
bool  reverse 
)

Compute the length of the shortest edit script for two sequences a and b. This is done using the "Greedy LCS/SES" of figure 2 in the paper. It can walk the edit graph either foward (when reverse is false) or backward starting from the end (when reverse is true).

Here, note that the real content of a and b should start at index 1, for this implementatikon algorithm to match the paper's algorithm in a straightforward manner. So pleast make sure that at index 0, we just get some non-used value.

Note that the equality operator used to compare the elements passed in argument to this function is the default "==" operator.

@tparm RandomAccessOutputIterator the type of iterators passed to this function. It must be a random access output iterator kind.

Parameters
athe first sequence we care about.
bthe second sequence we care about.
vthe vector that contains the end points of the furthest reaching d-path and (d-1)-path.

Definition at line 1406 of file abg-diff-utils.h.

◆ snake_end_points()

bool snake_end_points ( const snake s,
point x,
point u 
)

Get the end points of the snake, as intended by the paper.

Parameters
sthe snake to consider.
xthe starting point of the snake.
uthe end point of the snake.

Definition at line 70 of file abg-diff-utils.cc.