pike.git / lib / modules / Array.pmod

version» Context lines:

pike.git/lib/modules/Array.pmod:59:   //! The array is modified destructively.   //!   //! @seealso   //! @[permute()]   //!   array shuffle(array arr)   {    int i = sizeof(arr);       while(i) { -  int j = predef::random(i--); +  int j = 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:685:    {    mapping(mixed:int) res = ([]);    if(mappingp(haystack))    haystack = values([mapping]haystack);    foreach((array)haystack, mixed what)    res[what]++;    return res;    }    return sizeof(filter(haystack, `==, needle));   } -  - //! Returns a random element from the @[in] array. - mixed random(array in) { -  return in[predef::random(sizeof(in))]; - } +