# pike.git/lib/modules/Array.pmod

Branch: Tag:

## 2002-03-18

#### 2002-03-18 17:29:14 by Johan SundstrÃ¶m <oyasumi@gmail.com>

• 45098665c711ec1640d0f8897e287a2160e7a719 (11 lines) (+6/-5) [ Show | Annotate ]
Branch: 7.9
Nilsson came up with a better name than chunky_diff: greedy_diff.

Rev: lib/modules/Array.pmod:1.65

608:    return oid_sort_func(a2,b2);   }    - static array(array) low_chunky_diff(array d1, array d2) + static array(array) low_greedy_diff(array d1, array d2)   {    array r1, r2, x, y, yb, b, c;    r1 = r2 = ({});
649:      //! Like @[Array.diff], but tries to generate bigger continuous chunks of the   //! differences, instead of maximizing the number of difference chunks. More - //! specifically, @[chunky_diff] optimizes the cases where @[Array.diff] returns + //! specifically, @[greedy_diff] optimizes the cases where @[Array.diff] returns   //! @code{({ ..., A, Z, B, ({}), C, ... })@}   //! @code{({ ..., A, X, B, Y+B, C, ... })@}   //! into the somewhat shorter diff arrays   //! @code{({ ..., A, Z, B+C, ... })@}   //! @code{({ ..., A, X+B+Y, B+C, ... })@} - array(array) chunky_diff(array from, array to) + array(array) greedy_diff(array from, array to)   {    array d1, d2;    [d1, d2] = Array.diff(from, to); -  [d2, d1] = low_chunky_diff(d2, d1); -  return low_chunky_diff(d1, d2); +  [d2, d1] = low_greedy_diff(d2, d1); +  return low_greedy_diff(d1, d2);   }