Update signature for `binarySearch()` and `binarySearchBy()`.

This commit is contained in:
CismonX 2018-09-09 23:05:00 +08:00
parent d39b273251
commit 693e404667
2 changed files with 21 additions and 9 deletions

View File

@ -101,17 +101,25 @@ ZEND_BEGIN_ARG_INFO(copy_of_range_arginfo, 0)
ZEND_ARG_TYPE_INFO(0, num_elements, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(element_from_to_arginfo, 0)
ZEND_BEGIN_ARG_INFO(fill_arginfo, 0)
ZEND_ARG_INFO(0, element)
ZEND_ARG_TYPE_INFO(0, from_index, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, num_elements, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(binary_search_arginfo, 0)
ZEND_ARG_INFO(0, element)
ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, from_index, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, num_elements, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(binary_search_by_arginfo, 0)
ZEND_ARG_INFO(0, element)
ZEND_ARG_CALLABLE_INFO(0, selector, 0)
ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, from_index, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, num_elements, IS_LONG, 0)
ZEND_ARG_CALLABLE_INFO(0, selector, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(chuncked_arginfo, 0)
@ -138,7 +146,7 @@ const zend_function_entry collection_methods[] = {
PHP_ME(Collection, associateBy, associate_by_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Collection, associateByTo, associate_by_to_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Collection, average, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Collection, binarySearch, element_from_to_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Collection, binarySearch, binary_search_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Collection, binarySearchBy, binary_search_by_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Collection, chunked, chuncked_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Collection, containsAll, other_arginfo, ZEND_ACC_PUBLIC)
@ -155,7 +163,7 @@ const zend_function_entry collection_methods[] = {
PHP_ME(Collection, dropLast, n_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Collection, dropLastWhile, predicate_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Collection, dropWhile, predicate_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Collection, fill, element_from_to_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Collection, fill, fill_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Collection, filter, predicate_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Collection, filterNot, predicate_arginfo, ZEND_ACC_PUBLIC)
PHP_ME(Collection, filterNotTo, destination_predicate_arginfo, ZEND_ACC_PUBLIC)

View File

@ -96,29 +96,33 @@ class Collection implements ArrayAccess, Countable
* Searches the array or the range of the array for the provided element using the
* binary search algorithm.
*
* The array is expected to be packed and sorted, otherwise the result is undefined.
* The array is expected to be packed and sorted into ascending order, otherwise the
* result is undefined.
*
* @param mixed $element
* @param int $flags[optional]
* @param int $from_index[optional]
* @param int $num_elements[optional]
* @return int|null
*/
function binarySearch($element, $from_index, $num_elements) {}
function binarySearch($element, $flags, $from_index, $num_elements) {}
/**
* Searches the array or the range of the array for the provided element using the
* binary search algorithm, where the element equals to the one returned by the
* corresponding selector function.
*
* The array is expected to be packed and sorted, otherwise the result is undefined.
* The array is expected to be packed and sorted into ascending order, otherwise the
* result is undefined.
*
* @param mixed $element
* @param callable $selector ($value, $key) -> $new_value
* @param int $flags[optional]
* @param int $from_index[optional]
* @param int $num_elements[optional]
* @param callable $selector ($value, $key) -> $new_value
* @return int|null
*/
function binarySearchBy($element, $from_index, $num_elements, $selector) {}
function binarySearchBy($element, $selector, $flags, $from_index, $num_elements) {}
/**
* Splits this collection into a collection of arrays each not exceeding the given size.