pike.git / lib / modules / Array.pmod

version» Context lines:

pike.git/lib/modules/Array.pmod:58:   //! @[shuffle()] gives back the same elements, but in random order.   //!   //! @seealso   //! @[permute()]   //!   array shuffle(array arr)   {    int i = sizeof(arr);       while(i) { -  int j = random(i--); +  int j = predef::random(i--);    if (j != i) {    mixed tmp = arr[i];    arr[i] = arr[j];    arr[j] = tmp;    }    }    return(arr);   }      //! @[search_array()] works like @[map()], only it returns the index
pike.git/lib/modules/Array.pmod:659:   //! into the somewhat shorter diff arrays   //! @code{({ ..., A, Z, B+C, ... })@}   //! @code{({ ..., A, X+B+Y, B+C, ... })@}   array(array(array)) greedy_diff(array from, array to)   {    array(array) d1, d2;    [d1, d2] = Array.diff(from, to);    [d2, d1] = low_greedy_diff(d2, d1);    return low_greedy_diff(d1, d2);   } +  + //! Returns a random element from the @[in] array. + mixed random(array in) { +  return in[predef::random(sizeof(in))]; + }