本文整理汇总了PHP中SplDoublyLinkedList::count方法的典型用法代码示例。如果您正苦于以下问题:PHP SplDoublyLinkedList::count方法的具体用法?PHP SplDoublyLinkedList::count怎么用?PHP SplDoublyLinkedList::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplDoublyLinkedList
的用法示例。
在下文中一共展示了SplDoublyLinkedList::count方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hasListeners
/**
* Returns true, if the item has any listeners.
*
* @return Boolean
*/
public function hasListeners()
{
if ($this->_listeners === null) {
return false;
}
return $this->_listeners->count() > 0;
}
示例2: count
/**
* Returns the number or items in this collection
*
* @return int
*/
public function count()
{
if (!$this->_started) {
$this->rewind();
}
while ($this->valid()) {
$this->next();
}
return $this->_buffer->count();
}
示例3:
// push($value)
// 在结尾插入一个新值
$list->push('value1');
$list->push('value2');
$list->push('value3');
$list->push('value4');
$list->push('value5');
// pop()
// 抛出结尾的一个元素,会使得链表结构减少一个
$list->pop();
// key()
// 获得当前节点的索引值
$list->key();
// count()
// 获得链表的数量
$list->count();
// rewind()
// 将指针返回至初始节点
$list->rewind();
// current()
// 获得当前节点
$list->current();
// top()
// 返回最后一个节点的值
$list->top();
// bottom()
// 返回第一个节点的值
$list->bottom();
// next()
// 指针移到下一个节点
$list->next();
示例4: SplDoublyLinkedList
<?php
$dll = new SplDoublyLinkedList(2);
$dll->count(new SplDoublyLinkedList(2));
示例5:
?>
">
<i class="glyphicon glyphicon-shopping-cart icon-white"></i>
Enviar al Carrito
</a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
if ($listPila->count() == 0) {
?>
<p>No se encuentran productos, por favor regrese e intente seleccionar otro producto.</p>
<a class="btn btn-default btn-lg" href="products.php?pas=<?php
echo $_GET['pas'];
?>
&type=<?php
echo $_GET['type'];
?>
&select=1">
<i class="glyphicon glyphicon-chevron-left"></i>
Seleccionar otro producto
</a>
<?php
}
?>
示例6: unset
echo "Mem real: " . __convert(memory_get_usage(true)) . "\n";
unset($array);
echo "\n-- SplDoublyLinkedList \n";
echo "Mem usage: " . __convert(memory_get_usage()) . "\n";
echo "Mem real: " . __convert(memory_get_usage(true)) . "\n";
$s = microtime(true);
$spl = new SplDoublyLinkedList();
for ($i = 0; $i < $v; $i++) {
$spl->push($i);
}
try {
$spl->offsetUnset(102);
var_dump($spl->offsetGet(100));
var_dump($spl->offsetGet(102));
} catch (OutOfRangeException $e) {
echo $e;
}
$e = microtime(true);
echo "Count: " . $spl->count() . "\n";
echo "Elapsed time: " . ($e - $s) . " sec.\n";
echo "Mem usage: " . __convert(memory_get_usage()) . "\n";
echo "Mem real: " . __convert(memory_get_usage(true)) . "\n";
try {
for ($i = 0; $i < $v; $i++) {
$spl->pop();
}
} catch (Exception $e) {
}
unset($spl);
echo "\n";
}
示例7: SplDoublyLinkedList
<?php
$dll = new SplDoublyLinkedList();
$dll->push(2);
$dll->push(3);
$dll->push(4);
$dll->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO);
foreach ($dll as $k => $v) {
echo "{$k}=>{$v}\n";
}
$dll->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO);
foreach ($dll as $k => $v) {
echo "{$k}=>{$v}\n";
}
$dll->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_DELETE);
var_dump($dll->count());
foreach ($dll as $k => $v) {
echo "{$k}=>{$v}\n";
}
var_dump($dll->count());
?>
===DONE===
示例8: count
public function count()
{
return -parent::count();
}
示例9: count
/**
* (PHP 5 >= 5.1.0)
* Count elements of an object
*
* @link http://php.net/manual/en/countable.count.php
* @return integer The custom count as an integer.
*/
public function count()
{
return $this->storage->count();
}
示例10: SplDoublyLinkedList
<?php
$list = new SplDoublyLinkedList();
$c = $list->count('foo');
示例11: SplDoublyLinkedList
<?php
$ll = new SplDoublyLinkedList();
$ll->push('1');
$ll->push('2');
$ll->push('3');
try {
$ll->offsetUnset($ll->count() + 1);
var_dump($ll);
} catch (Exception $e) {
echo $e->getMessage();
}
示例12: solve
private function solve($formula)
{
$findSubFormula = false;
$stringStart = 0;
$stringLength = 0;
$stack = new \SplStack();
$subFormulas = [];
for ($i = 0; $i < strlen($formula); $i++) {
$char = $formula[$i];
if ($this->isBracketOpen($char)) {
if ($findSubFormula == false && $stack->count() == 0) {
$stringStart = $i;
}
$stack->push(1);
$findSubFormula = true;
}
if ($findSubFormula) {
$stringLength++;
}
if ($this->isBracketClose($char)) {
$stack->pop();
if ($stack->count() === 0 && $findSubFormula) {
$subFormulas[substr($formula, $stringStart, $stringLength)] = substr($formula, $stringStart, $stringLength);
$findSubFormula = false;
$stringLength = 0;
}
}
}
if (count($subFormulas) > 0) {
foreach ($subFormulas as &$subFormula) {
$temp = trim(substr($subFormula, 1, strlen($subFormula) - 2));
$subFormula = $this->solve($temp);
}
$formula = str_replace(array_keys($subFormulas), array_values($subFormulas), $formula);
}
$elems = new \SplDoublyLinkedList();
array_map(function ($item) use($elems) {
if ($item != ' ') {
$elems->push($item);
}
}, explode(' ', $formula));
while ($elems->count() > 1) {
$maxPriority = 0;
$index = 0;
foreach ($elems as $i => $el) {
if (isset(static::$symbols[$el]) && static::$symbols[$el] > $maxPriority) {
$maxPriority = static::$symbols[$el];
$index = $i;
}
}
$this->process($index, $elems);
}
return $elems->pop();
}
示例13: SplDoublyLinkedList
<?php
$dll = new SplDoublyLinkedList();
$dll->push('Never');
$dll->push('gonna');
$dll->push('give');
// at pos 0, shift everything up
$dll->add(0, 'you');
// Should be the end
$dll->add(4, 'up');
// Somewhere in the middle
$dll->add(2, 'let');
try {
// Key 12 is unaccessible
$dll->add(12, 'down');
} catch (OutOfRangeException $e) {
echo $e->getMessage(), PHP_EOL;
}
foreach ($dll as $key => $val) {
echo $key . '=>' . $val, PHP_EOL;
}
echo "count(): " . $dll->count(), PHP_EOL;
echo "top(): " . $dll->top(), PHP_EOL;
echo "bottom(): " . $dll->bottom(), PHP_EOL;
示例14: count
/**
* Counts the number of tokens in the list.
*
* @return int Returns the number of tokens in the list.
* @link http://www.php.net/manual/en/spldoublylinkedlist.count.php
*/
public function count()
{
return $this->tokens->count();
}