[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Source view] [Print] [Project Stats]
Methods to play with arrays. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
File Size: | 187 lines (6 kb) |
Included or required: | 0 times |
Referenced: | 1 time |
Includes or requires: | 0 files |
ArrayUtils:: (4 methods):
consistentHashSort()
pickRandom()
findLowerBound()
arrayDiffAssocRecursive()
Class: ArrayUtils - X-Ref
A collection of static methods to play with arrays.consistentHashSort( &$array, $key, $separator = "\000" ) X-Ref |
Sort the given array in a pseudo-random order which depends only on the given key and each element value. This is typically used for load balancing between servers each with a local cache. Keys are preserved. The input array is modified in place. Note: Benchmarking on PHP 5.3 and 5.4 indicates that for small strings, md5() is only 10% slower than hash('joaat',...) etc., since the function call overhead dominates. So there's not much justification for breaking compatibility with installations compiled with ./configure --disable-hash. param: array $array Array to sort param: string $key param: string $separator A separator used to delimit the array elements and the |
pickRandom( $weights ) X-Ref |
Given an array of non-normalised probabilities, this function will select an element and return the appropriate key param: array $weights return: bool|int|string |
findLowerBound( $valueCallback, $valueCount,$comparisonCallback, $target) X-Ref |
Do a binary search, and return the index of the largest item that sorts less than or equal to the target value. param: array $valueCallback A function to call to get the value with param: int $valueCount The number of items accessible via $valueCallback, param: array $comparisonCallback A callback to compare two values, returning param: string $target The target value to find. return: int|bool The item index of the lower bound, or false if the target value |
arrayDiffAssocRecursive( $array1 ) X-Ref |
Do array_diff_assoc() on multi-dimensional arrays. Note: empty arrays are removed. param: array $array1 The array to compare from param: array $array2,... More arrays to compare against return: array An array containing all the values from array1 |
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |