pike.git / lib / modules / Array.pmod

version» Context lines:

pike.git/lib/modules/Array.pmod:1:   #pike __REAL_VERSION__    + #pragma strict_types +    constant diff = __builtin.diff;   constant diff_longest_sequence = __builtin.diff_longest_sequence;   constant diff_compare_table = __builtin.diff_compare_table;   constant longest_ordered_sequence = __builtin.longest_ordered_sequence;   constant interleave_array = __builtin.interleave_array;      constant sort = __builtin.sort;   constant everynth = __builtin.everynth;   constant splice = __builtin.splice;   constant transpose = __builtin.transpose;
pike.git/lib/modules/Array.pmod:103:    {    for(e=0;e<sizeof(arr);e++)    if(([array(function(mixed...:mixed))]arr)[e](@args))    return e;    return -1;    }       error("Bad argument 2 to search_array().\n");   }    - array sum_arrays(function sum, mixed ... args) + //! Applies the function @[sum] columnwise on the elements in the + //! provided arrays. E.g. @tt{sum_array(`+,a,b,c)@} does the same + //! as @tt{`+(a[*],b[*],c[*])@}. + array sum_arrays(function(mixed ...:mixed) sum, array ... args)   { -  array ret; -  int e,d; -  ret=allocate(sizeof(args[0])); -  for(e=0;e<sizeof(args[0]);e++) -  ret[e]=([function(mixed...:mixed)]sum)(@ column(args, e)); +  array ret = allocate(sizeof(args[0])); +  for(int e=0; e<sizeof(args[0]); e++) +  ret[e] = sum( @column(args, e) );    return ret;   }      //! This function sorts an array after a compare-function @[cmp]   //! which takes two arguments and should return @tt{1@} if the first argument   //! is larger then the second.   //!   //! The remaining arguments @[args] will be sent as 3rd, 4th etc. argument   //! to @[cmp].   //!
pike.git/lib/modules/Array.pmod:583:   //! @item arrayp(x)   //! arrayify(x) => x   //! @item zero_type(x)   //! arrayify(x) => ({})   //! @item otherwise   //! arrayify(x) => ({ x })   //! @enddl   array arrayify(void|array|mixed x)   {    if(zero_type(x)) return ({}); -  if(arrayp(x)) return x; +  if(arrayp(x)) return [array]x;    return ({ x });   }      //! Sort with care of numerical sort for OID values:   //! "1.2.1" before "1.11.1"   int oid_sort_func(string a0,string b0)   {    string a2="",b2="";    int a1, b1;    sscanf(a0,"%d.%s",a1,a2);    sscanf(b0,"%d.%s",b1,b2);    if (a1>b1) return 1;    if (a1<b1) return 0;    if (a2==b2) return 0;    return oid_sort_func(a2,b2);   }    - static array(array) low_greedy_diff(array d1, array d2) + static array(array(array)) low_greedy_diff(array(array) d1, array(array) d2)   {    array r1, r2, x, y, yb, b, c;    r1 = r2 = ({});    int at, last, seen;    while(-1 != (at = search(d1, ({}), last)))    {    last = at + 1;    if(at < 2) continue;    b = d2[at-1]; yb = d2[at];   out:if(sizeof(yb) > sizeof(b))
pike.git/lib/modules/Array.pmod:637:    {    // At last chunk. There is no C.    r1 += d1[seen..at-2] + ({ b });    r2 += d2[seen..at-3] + ({ x+b+y }) + ({ b });    }    seen = at + 5;    }    }    if(!seen)    return ({ d1, d2 }); // No change. -  return ({ r1 + d1[seen..], r2 + d2[seen..] }); +  return ({ [array(array)]r1 + d1[seen..], +  [array(array)]r2 + d2[seen..] });   }      //! Like @[Array.diff], but tries to generate bigger continuous chunks of the   //! differences, instead of maximizing the number of difference chunks. More   //! 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) greedy_diff(array from, array to) + array(array(array)) greedy_diff(array from, array to)   { -  array d1, d2; +  array(array) d1, d2;    [d1, d2] = Array.diff(from, to);    [d2, d1] = low_greedy_diff(d2, d1);    return low_greedy_diff(d1, d2);   }