diff --git a/src/collections_me.c b/src/collections_me.c index 7db055e..9bb2430 100644 --- a/src/collections_me.c +++ b/src/collections_me.c @@ -122,14 +122,6 @@ ZEND_BEGIN_ARG_INFO(binary_search_by_arginfo, 0) ZEND_ARG_TYPE_INFO(0, to_index, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(binary_search_with_arginfo, 0) - ZEND_ARG_INFO(0, element) - ZEND_ARG_CALLABLE_INFO(0, comparator, 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, to_index, IS_LONG, 0) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO(chuncked_arginfo, 0) ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0) ZEND_ARG_CALLABLE_INFO(0, transform, 0) @@ -156,7 +148,6 @@ const zend_function_entry collection_methods[] = { PHP_ME(Collection, average, NULL, 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, binarySearchWith, binary_search_with_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, chunked, chuncked_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, containsAll, other_arginfo, ZEND_ACC_PUBLIC) PHP_ME(Collection, containsAllKeys, other_arginfo, ZEND_ACC_PUBLIC) diff --git a/src/collections_methods.c b/src/collections_methods.c index 7964a83..d5e1973 100644 --- a/src/collections_methods.c +++ b/src/collections_methods.c @@ -987,7 +987,7 @@ PHP_METHOD(Collection, binarySearchBy) Bucket* end = current->arData + to_idx; for (; bucket < end; ++bucket) { CALLBACK_KEYVAL_INVOKE(params, bucket); - memcpy(&ref[idx++].val, &bucket->val, sizeof(zval)); + memcpy(&ref[idx++].val, &retval, sizeof(zval)); if (UNEXPECTED(cmp == NULL)) { cmp = compare_func_init(&retval, 0, flags); } @@ -1000,11 +1000,6 @@ PHP_METHOD(Collection, binarySearchBy) free(ref); } -PHP_METHOD(Collection, binarySearchWith) -{ - -} - PHP_METHOD(Collection, chunked) { zend_long size; diff --git a/src/php_collections_me.h b/src/php_collections_me.h index 89867b9..c2344b5 100644 --- a/src/php_collections_me.h +++ b/src/php_collections_me.h @@ -20,7 +20,6 @@ PHP_METHOD(Collection, associateByTo); PHP_METHOD(Collection, average); PHP_METHOD(Collection, binarySearch); PHP_METHOD(Collection, binarySearchBy); -PHP_METHOD(Collection, binarySearchWith); PHP_METHOD(Collection, chunked); PHP_METHOD(Collection, containsAll); PHP_METHOD(Collection, containsAllKeys); diff --git a/stubs/Collection.php b/stubs/Collection.php index 3dca4fa..93fee83 100644 --- a/stubs/Collection.php +++ b/stubs/Collection.php @@ -124,21 +124,6 @@ class Collection implements ArrayAccess, Countable */ function binarySearchBy($element, $selector, $flags, $from_index, $to_index) {} - /** - * 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 into ascending order according to - * the specified comparator, otherwise the result is undefined. - * - * @param mixed $element - * @param callable $comparator (Pair($key, $value), Pair($key, $value)) -> int - * @param int $from_index[optional] - * @param int $to_index[optional] - * @return int|null - */ - function binarySearchWith($element, $comparator, $from_index, $to_index) {} - /** * Splits this collection into a collection of arrays each not exceeding the given size. * diff --git a/tests/058-binary-search-by.phpt b/tests/058-binary-search-by.phpt index de91d05..912da9d 100644 --- a/tests/058-binary-search-by.phpt +++ b/tests/058-binary-search-by.phpt @@ -23,6 +23,7 @@ $array = array_map(function ($value) { $selector = function ($value) { return $value[0]; }; +$collection = Collection::init($array); if ($collection->binarySearchBy($which, $selector, 0, $from, $to) != $idx) { echo 'Collection::binarySearchBy() failed.', PHP_EOL; }