当前位置: 首页>>代码示例>>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;未经允许,请勿转载。