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


PHP SplDoublyLinkedList::push方法代码示例

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


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

示例1: addText

 public function addText(SimpleToken $text, $parent = null)
 {
     if ($parent) {
         $parent->addChild($text->getValue());
     } else {
         parent::push($text->getValue());
     }
 }
开发者ID:phpml,项目名称:phpml,代码行数:8,代码来源:Tree.php

示例2: test

function test(SplDoublyLinkedList $l)
{
    $l->push("a");
    $l->push("b");
    $l->push("c");
    echo "ArrayAccess Unset:", PHP_EOL;
    unset($l[0]);
    var_dump($l[0]);
    echo PHP_EOL;
}
开发者ID:badlamer,项目名称:hhvm,代码行数:10,代码来源:unset_non_array.php

示例3: testPHPUnitCommand

 public function testPHPUnitCommand()
 {
     // need an explicit Traversable
     $skippedPaths = new \SplDoublyLinkedList();
     $skippedPaths->push('a');
     $skippedPaths->push('b');
     // going for 'bang for the buck' here re: test converage
     $task = (new \Robo\Task\ApiGen\ApiGen('apigen'))->config('./apigen.neon')->source('src')->extensions('php')->exclude(array('test', 'tmp'))->skipDocPath($skippedPaths)->charset(array('utf8', 'iso88591'))->internal('no')->php(true)->tree('Y')->debug('n');
     $cmd = 'apigen --config ./apigen.neon --source src --extensions php --exclude test --exclude tmp --skip-doc-path a --skip-doc-path b --charset \'utf8,iso88591\' --internal no --php yes --tree yes --debug no';
     verify($task->getCommand())->equals($cmd);
     $task->run();
     $this->apigen->verifyInvoked('executeCommand', [$cmd]);
 }
开发者ID:jjok,项目名称:Robo,代码行数:13,代码来源:ApiGenTest.php

示例4: resetCreateGlobalVars

function resetCreateGlobalVars()
{
    global $v0, $v1, $v2, $v3, $v4, $v5, $list0, $list1, $list2, $list3, $list4, $list5, $adjacencyList;
    $v0 = new vertex(0);
    $v1 = new vertex(1);
    $v2 = new vertex(2);
    $v3 = new vertex(3);
    $v4 = new vertex(4);
    $v5 = new vertex(5);
    $list0 = new SplDoublyLinkedList();
    $list0->push(array('vertex' => $v1, 'distance' => 3));
    $list0->push(array('vertex' => $v3, 'distance' => 1));
    $list0->rewind();
    $list1 = new SplDoublyLinkedList();
    $list1->push(array('vertex' => $v0, 'distance' => 3));
    $list1->push(array('vertex' => $v2, 'distance' => 7));
    $list1->rewind();
    $list2 = new SplDoublyLinkedList();
    $list2->push(array('vertex' => $v1, 'distance' => 7));
    $list2->push(array('vertex' => $v3, 'distance' => 8));
    $list2->push(array('vertex' => $v4, 'distance' => 12));
    $list2->rewind();
    $list3 = new SplDoublyLinkedList();
    $list3->push(array('vertex' => $v0, 'distance' => 1));
    $list3->push(array('vertex' => $v2, 'distance' => 8));
    $list3->rewind();
    $list4 = new SplDoublyLinkedList();
    $list4->push(array('vertex' => $v2, 'distance' => 12));
    $list4->push(array('vertex' => $v5, 'distance' => 3));
    $list4->rewind();
    $list5 = new SplDoublyLinkedList();
    $list5->push(array('vertex' => $v4, 'distance' => 3));
    $list5->rewind();
    $adjacencyList = array($list0, $list1, $list2, $list3, $list4, $list5);
}
开发者ID:erackson,项目名称:samu,代码行数:35,代码来源:index.php

示例5: decode

 /**
  * Reads a stream and decodes the byte character by character. This method
  * will return the remainder of the stream.
  *
  * @param  string $stream The stream to be decoded.
  * @return string         The remainder of the stream, if any.
  */
 public function decode($stream)
 {
     $stream = str_split($stream);
     $buffer = '';
     $size = count($stream);
     $sizeList = new \SplDoublyLinkedList();
     $bufList = new \SplDoublyLinkedList();
     // read the size of the byte from the stream
     for ($i = 0; $i < count($stream); $i++) {
         $temp = $stream[$i];
         unset($stream[$i]);
         if ($temp === ':') {
             break;
         }
         $sizeList->push($temp);
     }
     $stream = array_values($stream);
     $size = 0;
     foreach ($sizeList as $sl) {
         $size .= $sl;
     }
     // read the length of the byte from the stream
     for ($i = 0; $i < $size; $i++) {
         $bufList->push($stream[$i]);
         unset($stream[$i]);
     }
     // read the byte into the buffer
     foreach ($bufList as $bl) {
         $buffer .= $bl;
     }
     $this->_buffer = $buffer;
     return implode('', array_values($stream));
 }
开发者ID:dsmithhayes,项目名称:bencode,代码行数:40,代码来源:Byte.php

示例6: decode

 /**
  * @todo make recursive
  * 
  * Reads a stream character for character until the suffix ('e') is found
  * and returns the remainder of the string.
  *
  * @param string $stream Reads the stream into the buffer.
  *
  * @throws Bencode\Exceptions\IntegerException
  */
 public function decode($stream)
 {
     $flag = false;
     $stream = str_split($stream);
     $buffer = '';
     $size = count($stream);
     $stack = new \SplDoublyLinkedList();
     for ($i = 0; $i < $size - 1; $i++) {
         if ($flag) {
             if (is_numeric($stream[$i]) || $stream[$i] === '-') {
                 $stack->push($stream[$i]);
             }
         }
         if ($stream[$i] === 'i') {
             $flag = true;
         }
         if ($stream[$i] === 'e') {
             $flag = false;
             unset($stream[$i]);
             break;
         }
         unset($stream[$i]);
     }
     foreach ($stack as $s) {
         $buffer .= $s;
     }
     $this->_buffer = $buffer;
     return implode('', array_values($stream));
 }
开发者ID:dsmithhayes,项目名称:bencode,代码行数:39,代码来源:Integer.php

示例7: SplDoublyLinkedList

 function __construct()
 {
     $this->listClients = new SplDoublyLinkedList();
     //=========================load file===============================//
     $read = new ReadCsv();
     $lisClient = $read->get2DArrayFromCsv('files/clientes.csv', ',');
     foreach ($lisClient as $row => $data) {
         $listProductByClient = new SplDoublyLinkedList();
         $contLines = 0;
         $codeProduct = 0;
         foreach ($data as $rowL => $dataL) {
             if ($rowL > 1 && $dataL != "") {
                 if ($contLines == 0) {
                     $codeProduct = $dataL;
                     $contLines++;
                 } else {
                     $listProdCliente = new ListaProductosPorCliente();
                     $listProdCliente->setIdProducto($codeProduct);
                     $listProdCliente->setProducto($dataL);
                     $listProductByClient->push($listProdCliente);
                     $contLines--;
                 }
             }
         }
         $client1 = new Clientes();
         $client1->setName($data[0]);
         $client1->setId($data[1]);
         $client1->setListPruductByClient($listProductByClient);
         $this->listClients->push($client1);
     }
     //=========================//load file=============================//
     $this->listClients->serialize();
     //$this->loadFile();
 }
开发者ID:asandi01,项目名称:phpLitsTest,代码行数:34,代码来源:ListaClientes.php

示例8: get_result

function get_result($t, $ladders, $snakes)
{
    fill_graph($t, $ladders);
    fill_graph($t, $snakes);
    $len = count($t);
    $vertices = array();
    for ($k = 0; $k < $len; $k++) {
        $vertices[$k] = new vertex($k);
    }
    $adjacencyList = array();
    for ($u = 0; $u < $len; $u++) {
        $list = new SplDoublyLinkedList();
        for ($v = 0; $v < $len; $v++) {
            if ($t[$u][$v] != 0) {
                $list->push(array('vertex' => $vertices[$v], 'distance' => $t[$u][$v]));
            }
        }
        $list->rewind();
        $adjacencyList[] = $list;
    }
    calcShortestPaths($vertices[0], $adjacencyList);
    $path = end($vertices)->path;
    $result = $p = 0;
    for ($n = 0; $n < count($path); $n++) {
        $p++;
        if (@$path[$n + 1] - $path[$n] != 1) {
            $result = $result + ceil(($p - 1) / 6);
            $p = 0;
        }
    }
    //echo "[" . implode(', ', $path) . "]\n\n";
    return $result;
}
开发者ID:eltonoliver,项目名称:Algorithms,代码行数:33,代码来源:snakes_and_ladders.php

示例9: appendListener

 /**
  * Appends the new listener to the list of item listeners.
  *
  * @param Opf_EventListener $listener The listener.
  */
 public function appendListener(Opf_EventListener $listener)
 {
     if ($this->_listeners === null) {
         $this->_listeners = new SplDoublyLinkedList();
     }
     $this->_listeners->push($listener);
 }
开发者ID:OPL,项目名称:Open-Power-Forms,代码行数:12,代码来源:Item.php

示例10: createTransitionsList

 /**
  * @param $vertex
  * @return \SplDoublyLinkedList
  */
 public function createTransitionsList($vertex)
 {
     $list = new \SplDoublyLinkedList();
     $list->setIteratorMode(\SplDoublyLinkedList::IT_MODE_FIFO | \SplDoublyLinkedList::IT_MODE_KEEP);
     $list->push($vertex);
     return $list;
 }
开发者ID:ne0h12,项目名称:word-transformer,代码行数:11,代码来源:BreadthFirstSearchAlgorithm.php

示例11: resolve

 public function resolve($obj)
 {
     $result = new \SplDoublyLinkedList();
     foreach ($obj as $value) {
         $result->push($value);
     }
     return $result;
 }
开发者ID:honzabrecka,项目名称:transit-php,代码行数:8,代码来源:ListHandler.php

示例12: prepareQueueForFutureVisits

 /**
  * @param VisitAction $futureVisitAction
  * @param Expression $lastVisitedExpression
  * @return \SplDoublyLinkedList
  */
 protected function prepareQueueForFutureVisits(VisitAction $futureVisitAction = null, Expression $lastVisitedExpression)
 {
     $stackForExpressions = new \SplDoublyLinkedList();
     if ($lastVisitedExpression instanceof ExpressionIterable) {
         foreach ($lastVisitedExpression as $futureVisit) {
             $stackForExpressions->push($futureVisit);
         }
     } else {
         if ($lastVisitedExpression instanceof ExpressionAggregate) {
             $futureVisit = $lastVisitedExpression->getExpression();
             $stackForExpressions->push($futureVisit);
         }
     }
     if ($futureVisitAction instanceof VisitAction) {
         $stackForExpressions->push($futureVisitAction);
     }
     return $stackForExpressions;
 }
开发者ID:helstern,项目名称:nomsky-lib,代码行数:23,代码来源:DepthFirstStackBasedWalker.php

示例13: tokenize

 /**
  * {@inheritdoc}
  */
 public function tokenize($userAgent)
 {
     $iterator = new \SplDoublyLinkedList();
     $iterator->setIteratorMode(\SplDoublyLinkedList::IT_MODE_FIFO);
     foreach ($this->getTokens($userAgent) as $position => $token) {
         $token = trim($token);
         $iterator->push(new Node($token, $position, $this->resolveType($token)));
     }
     return $iterator;
 }
开发者ID:zientalak,项目名称:devicedetector,代码行数:13,代码来源:UserAgentTokenizer.php

示例14: mergeSets

 /**
  * {@inheritdoc}
  */
 public function mergeSets($x, $y)
 {
     $setx = $this->findSet($x);
     $sety = $this->findSet($y);
     if ($setx === Null || $sety === Null) {
         return;
     }
     // create a new linked list from both sets
     $setxy = new SplDoublyLinkedList();
     foreach ($this->_sets[$x] as $e) {
         $setxy->push($e);
     }
     foreach ($this->_sets[$y] as $e) {
         $setxy->push($e);
     }
     unset($this->_sets[$x]);
     unset($this->_sets[$y]);
     $this->_sets[$x] = $setxy;
 }
开发者ID:robologo3000,项目名称:disjointed-php,代码行数:22,代码来源:DisjointedLinkedLists.php

示例15: test

function test(SplDoublyLinkedList $l)
{
    $l->push("a");
    $l->push("b");
    $l->push("c");
    echo "Foreach:", PHP_EOL;
    foreach ($l as $key => $val) {
        echo $key, '=>', $val, PHP_EOL;
    }
    echo PHP_EOL;
    echo "ArrayAccess:", PHP_EOL;
    var_dump($l[0]);
    var_dump($l[1]);
    var_dump($l[2]);
    echo PHP_EOL;
    echo "ArrayAccess Set:", PHP_EOL;
    $l[2] = "two";
    var_dump($l[2]);
    try {
        $l[3] = "five";
        // 3 would be the next element
    } catch (OutOfRangeException $e) {
        echo "OutOfRangeException caught", PHP_EOL;
    }
    echo PHP_EOL;
    echo "ArrayAccess Exists:", PHP_EOL;
    var_dump(isset($l[0]), isset($l[2]), isset($l[3]));
    // true, true, false
    echo PHP_EOL;
    echo "ArrayAccess Unset:", PHP_EOL;
    unset($l[0]);
    var_dump($l->offsetGet(0));
    echo PHP_EOL;
    echo "Foreach:", PHP_EOL;
    foreach ($l as $key => $val) {
        echo $key, '=>', $val, PHP_EOL;
    }
    echo PHP_EOL;
}
开发者ID:badlamer,项目名称:hhvm,代码行数:39,代码来源:DoublyLinkedList_it_mode.php


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