當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArrayUtils::findLowerBound方法代碼示例

本文整理匯總了PHP中ArrayUtils::findLowerBound方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayUtils::findLowerBound方法的具體用法?PHP ArrayUtils::findLowerBound怎麽用?PHP ArrayUtils::findLowerBound使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ArrayUtils的用法示例。


在下文中一共展示了ArrayUtils::findLowerBound方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testFindLowerBound

 /**
  * @covers ArrayUtils::findLowerBound
  * @dataProvider provideFindLowerBound
  */
 function testFindLowerBound($valueCallback, $valueCount, $comparisonCallback, $target, $expected)
 {
     $this->assertSame(ArrayUtils::findLowerBound($valueCallback, $valueCount, $comparisonCallback, $target), $expected);
 }
開發者ID:eliagbayani,項目名稱:LiteratureEditor,代碼行數:8,代碼來源:ArrayUtilsTest.php

示例2: getFirstLetter

 public function getFirstLetter($string)
 {
     $string = strval($string);
     if ($string === '') {
         return '';
     }
     $firstChar = mb_substr($string, 0, 1, 'UTF-8');
     // If the first character is a CJK character, just return that character.
     if (ord($firstChar) > 0x7f && self::isCjk(UtfNormal\Utils::utf8ToCodepoint($firstChar))) {
         return $firstChar;
     }
     $sortKey = $this->getPrimarySortKey($string);
     // Do a binary search to find the correct letter to sort under
     $min = ArrayUtils::findLowerBound([$this, 'getSortKeyByLetterIndex'], $this->getFirstLetterCount(), 'strcmp', $sortKey);
     if ($min === false) {
         // Before the first letter
         return '';
     }
     $sortLetter = $this->getLetterByIndex($min);
     if ($this->useNumericCollation) {
         // If the sort letter is a number, return '0–9' (or localized equivalent).
         // ASCII value of 0 is 48. ASCII value of 9 is 57.
         // Note that this also applies to non-Arabic numerals since they are
         // mapped to Arabic numeral sort letters. For example, ২ sorts as 2.
         if (ord($sortLetter) >= 48 && ord($sortLetter) <= 57) {
             $sortLetter = wfMessage('category-header-numerals')->numParams(0, 9)->text();
         }
     }
     return $sortLetter;
 }
開發者ID:paladox,項目名稱:mediawiki,代碼行數:30,代碼來源:IcuCollation.php

示例3: getFirstLetter

 function getFirstLetter($string)
 {
     $string = strval($string);
     if ($string === '') {
         return '';
     }
     // Check for CJK
     $firstChar = mb_substr($string, 0, 1, 'UTF-8');
     if (ord($firstChar) > 0x7f && self::isCjk(UtfNormal\Utils::utf8ToCodepoint($firstChar))) {
         return $firstChar;
     }
     $sortKey = $this->getPrimarySortKey($string);
     // Do a binary search to find the correct letter to sort under
     $min = ArrayUtils::findLowerBound(array($this, 'getSortKeyByLetterIndex'), $this->getFirstLetterCount(), 'strcmp', $sortKey);
     if ($min === false) {
         // Before the first letter
         return '';
     }
     return $this->getLetterByIndex($min);
 }
開發者ID:Acidburn0zzz,項目名稱:mediawiki,代碼行數:20,代碼來源:Collation.php

示例4: findLowerBound

 /**
  * Do a binary search, and return the index of the largest item that sorts
  * less than or equal to the target value.
  *
  * @deprecated in 1.23; use ArrayUtils::findLowerBound() instead
  *
  * @param array $valueCallback A function to call to get the value with
  *     a given array index.
  * @param int $valueCount The number of items accessible via $valueCallback,
  *     indexed from 0 to $valueCount - 1
  * @param array $comparisonCallback A callback to compare two values, returning
  *     -1, 0 or 1 in the style of strcmp().
  * @param string $target The target value to find.
  *
  * @return int|bool The item index of the lower bound, or false if the target value
  *     sorts before all items.
  */
 function findLowerBound($valueCallback, $valueCount, $comparisonCallback, $target)
 {
     wfDeprecated(__METHOD__, '1.23');
     return ArrayUtils::findLowerBound($valueCallback, $valueCount, $comparisonCallback, $target);
 }
開發者ID:biribogos,項目名稱:wikihow-src,代碼行數:22,代碼來源:Collation.php


注:本文中的ArrayUtils::findLowerBound方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。