当前位置: 首页>>代码示例>>PHP>>正文


PHP SplFixedArray::count方法代码示例

本文整理汇总了PHP中SplFixedArray::count方法的典型用法代码示例。如果您正苦于以下问题:PHP SplFixedArray::count方法的具体用法?PHP SplFixedArray::count怎么用?PHP SplFixedArray::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SplFixedArray的用法示例。


在下文中一共展示了SplFixedArray::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: keep

 /**
  * @param int $numberOfCardsToKeep
  *
  * @return HandInterface
  */
 public function keep(int $numberOfCardsToKeep) : HandInterface
 {
     if ($this->cards->count() <= $numberOfCardsToKeep) {
         return $this;
     }
     return new self(...array_slice($this->getCards(), 0, $numberOfCardsToKeep));
 }
开发者ID:ranpafin,项目名称:phpoker,代码行数:12,代码来源:Hand.php

示例2: getNotificacoes

 /**
  * @return \SplStack
  */
 public function getNotificacoes()
 {
     $notificacoes = new \SplStack();
     for ($i = 0; $i < $this->listaDeItens->count(); $i++) {
         $notificacoes->push($this->listaDeItens[$i]->notify());
     }
     return $notificacoes;
 }
开发者ID:he--,项目名称:liquidaJp,代码行数:11,代码来源:LiquidaJp.php

示例3: sort

 /**
  * {@inheritdoc}
  */
 public function sort(\SplFixedArray $array)
 {
     $length = $array->count();
     for ($i = 1; $i < $length; $i++) {
         $key = $array[$i];
         $j = $i - 1;
         while ($j >= 0 && $array[$j] > $key) {
             $array[$j + 1] = $array[$j];
             $j--;
         }
         $array[$j + 1] = $key;
     }
     return $array;
 }
开发者ID:valdislav,项目名称:SplFixedArray,代码行数:17,代码来源:InsertionSortStrategy.php

示例4: sort

 /**
  * {@inheritdoc}
  */
 public function sort(\SplFixedArray $array)
 {
     $length = $array->count();
     for ($i = 0; $i < $length - 1; $i++) {
         $smallest = $i;
         for ($j = $i + 1; $j < $length; $j++) {
             if ($array[$j] < $array[$smallest]) {
                 $smallest = $j;
             }
         }
         $tmp = $array[$i];
         $array[$i] = $array[$smallest];
         $array[$smallest] = $tmp;
     }
     return $array;
 }
开发者ID:valdislav,项目名称:SplFixedArray,代码行数:19,代码来源:SelectionSortStrategy.php

示例5: selectionsort

function selectionsort(SplFixedArray $arr)
{
    $sIndex = 0;
    $smallestIndex = 0;
    $tmp = null;
    $count = $arr->count();
    while ($sIndex < $count) {
        $smallestIndex = $sIndex;
        for ($i = $sIndex; $i < $count; $i++) {
            if ($arr[$i] < $arr[$smallestIndex]) {
                $smallestIndex = $i;
            }
        }
        if ($sIndex < $smallestIndex) {
            $tmp = $arr[$smallestIndex];
            $arr[$smallestIndex] = $arr[$sIndex];
            $arr[$sIndex] = $tmp;
        }
        $sIndex++;
    }
}
开发者ID:bylexus,项目名称:selsort-bench,代码行数:21,代码来源:selectionsort_fixedarray.php

示例6: SplFixedArray

<?php

$array = new SplFixedArray(5);
echo $array->count(3);
开发者ID:badlamer,项目名称:hhvm,代码行数:4,代码来源:SplFixedArray_count_param_int.php

示例7: count

 /**
  * Returns the number of objects in the collection
  *
  * @return Natural
  */
 public function count()
 {
     return new Natural($this->items->count());
 }
开发者ID:cermat,项目名称:valueobjects,代码行数:9,代码来源:Collection.php

示例8: count

 /**
  * @return int
  */
 public function count()
 {
     return $this->set->count();
 }
开发者ID:nmarley,项目名称:bitcoin-php,代码行数:7,代码来源:MutableCollection.php

示例9: SplFixedArray

<?php

echo "Commit from Mint command line";
$array = new SplFixedArray(5);
echo $array->count();
$array->setSize(10);
echo '<br>' . $array->count();
$array[4] = 'lalala';
$array[1] = 'bababa';
$array->next();
echo '<br>' . $array->current();
echo '<br>' . $array->key();
echo "commit from mint PhpStorm";
开发者ID:beregsys,项目名称:test,代码行数:13,代码来源:test.php

示例10: __construct

 /**
  * Constructor
  * @param \Segment\Model\SearchValues|\Segment\Model\Expression $value1
  * @param \Segment\Model\SearchValues|\Segment\Model\Expression $values Variable-length variable.
  */
 public function __construct($value1, ...$values)
 {
     $count = count($values);
     $v_arr = new \SplFixedArray($count + 1);
     $v_arr->offsetSet(0, $value1);
     for ($i = 0; $i < $count; $i++) {
         $v_arr->offsetSet($i + 1, $values[$i]);
     }
     $this->values = $v_arr;
     $this->count = $v_arr->count();
 }
开发者ID:Michael-Mosher,项目名称:Segment,代码行数:16,代码来源:model_h.php

示例11: valid

 /**
  * (PHP 5 &gt;= 5.0.0)<br/>
  * Checks if current position is valid
  *
  * @link http://php.net/manual/en/iterator.valid.php
  * @return boolean The return value will be casted to boolean and then evaluated.
  *       Returns true on success or false on failure.
  */
 public function valid()
 {
     return $this->index < $this->rawData->count() || $this->index < $this->objectData->count();
 }
开发者ID:marviktintor,项目名称:pos-1,代码行数:12,代码来源:Database.php

示例12: SplFixedArray

<?php

/**
 * spl数据结构demo
 * 阵列 SplFixedArray
 *
 */
// 定义一个长度为5的阵列
$array = new SplFixedArray(5);
$array[1] = 2;
$array[3] = 'value2';
// count()
// 阵列长度
$array->count();
// key()
// 获得当前节点的索引
$array->key();
// valid()
// 判断是否还存在值
$array->valid();
// rewind()
// 回到初始节点
$array->rewind();
// current()
// 获得当前节点
$array->current();
// next()
// 指针移动到下一个节点
$array->next();
// setSize(int $size)
// 重新设置阵列数组的大小
开发者ID:ray0916,项目名称:learn,代码行数:31,代码来源:splFixedArray.php

示例13: count

 public function count()
 {
     return -parent::count();
 }
开发者ID:badlamer,项目名称:hhvm,代码行数:4,代码来源:fixedarray_018.php

示例14: SplFixedArray

<?php

// Create a fixed array
$fixedArray = new SplFixedArray(5);
// Fill it up
for ($i = 0; $i < 5; $i++) {
    $fixedArray[$i] = "PHPNW Testfest";
}
// Test count() returns correct error when parameters are passed.
$fixedArray->count(1);
开发者ID:badlamer,项目名称:hhvm,代码行数:10,代码来源:SplFixedArray_toArray_with-params.php

示例15: SplFixedArray

<?php

#Examples
#Example #1 SplFixedArray usage example
// Initialize the array with a fixed length
$array = new SplFixedArray(5);
$array[1] = 2;
$array[4] = "foo";
echo "<pre>";
var_dump($array[0]);
// NULL
var_dump($array[1]);
// int(2)
var_dump($array["4"]);
// string(3) "foo"
echo "\n Array Count defined : " . $array->count() . "\n";
// Increase the size of the array to 10
$array->setSize(10);
// getting the array size
echo "\n getSize :" . $array->getSize() . "\n";
$array[9] = "asdf";
echo "\n Array Count increase : " . $array->count() . "\n";
// Shrink the array to a size of 2
$array->setSize(2);
echo "\n Array Count shrink : " . $array->count() . "\n";
// The following lines throw a RuntimeException: Index invalid or out of range
try {
    var_dump($array["non-numeric"]);
} catch (RuntimeException $re) {
    echo "RuntimeException: " . $re->getMessage() . "\n";
}
开发者ID:jestintab,项目名称:zendphp,代码行数:31,代码来源:spl-fixedarray-ex1.php


注:本文中的SplFixedArray::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。