zoukankan      html  css  js  c++  java
  • PHP-SplDoublyLinkedList

    <?php                                                                                                                                                                                                        
    /**
     * @package a doubly linked list test
     * @author  zhaoyingnan<zhaoyn@bbtree.com>
     * @copyright
     * @version
     * @since
     **/
    
    /* SplDoublyLinkedList
     * 方法
     SplDoublyLinkedList implements Iterator , ArrayAccess , Countable
     {
         public __construct ( void )
             public void add ( mixed $index , mixed $newval ) 在指定的索引位置插入值
             public mixed bottom ( void ) 查看开始位置的节点
             public mixed top ( void ) 查看结束位置的节点
             public int count ( void ) 返回所有的元素的数量
             public void rewind ( void ) 倒回迭代器的开始
             public mixed current ( void ) 返回当前节点的信息
             public mixed key ( void ) 返回当前节点的索引
             public void setIteratorMode ( int $mode ) 设置迭代的模式
             public int getIteratorMode ( void ) 返回迭代的模式
             public bool isEmpty ( void ) 检查该双向列表是否是空的
             public void next ( void ) 移动到下一个节点
             public void prev ( void ) 移动到上一个节点
             public bool offsetExists ( mixed $index )
             public mixed offsetGet ( mixed $index )
             public void offsetSet ( mixed $index , mixed $newval )
             public void offsetUnset ( mixed $index )
             public mixed pop ( void ) 从双向列表的末尾弹出一个节点
             public void push ( mixed $value ) 向双向列表的末尾推入一个元素
             public mixed shift ( void ) 从双向列表的头部弹出一个节点
             public void unshift ( mixed $value ) 向双向列表的头部插入一个元素
             public string serialize ( void )
             public void unserialize ( string $serialized )
             public bool valid ( void ) 检查双向列表是否有更多的节点
    }
     */
    $SplDoublyLinkedList = new SplDoublyLinkedList();
    $mysqli = new mysqli('114.55.104.117', 'db_writer', 'ka_32^%*ko', 'db_community');
    if($mysqli->connect_errno)
        exit('Mysql connect error ' . $mysqli->connect_error);
    $query  = "show tables like '%zhs_user_timeline_%'";
    $result = $mysqli->query($query);
    if(!$result)
        exit('error ' . $mysqli->error);
    while($row = $result->fetch_row())
    {
        //list($arData[]) = array_values($row);
        $SplDoublyLinkedList->push($row[0]);    
    }
    $result->close();
    $mysqli->close();
    
    echo count($SplDoublyLinkedList), PHP_EOL;
    $SplDoublyLinkedList->rewind();
    while($SplDoublyLinkedList->valid())
    {
        var_export($SplDoublyLinkedList->shift());
        echo PHP_EOL;
        echo count($SplDoublyLinkedList), PHP_EOL;
        $SplDoublyLinkedList->next();
    }
    echo count($SplDoublyLinkedList);
    ?>
  • 相关阅读:
    LIKE谓词
    [C#网络编程系列]专题一:网络协议简介
    (zz)Sql Server 2005中的架构(Schema)、用户(User)、角色(Role)和登录(Login)(三)
    zz让你成功的九个心理定律
    zz给 VSTO 插件、文档传送参数
    重构笔记
    (zz)Sql Server 2005中的架构(Schema)、用户(User)、角色(Role)和登录(Login)(二)
    zzVSTO 先瘦身再发布:客户端配置文件
    zz将 VSTO 插件部署给所有用户
    (zz)Sql Server 2005中的架构(Schema)、用户(User)、角色(Role)和登录(Login)(一)
  • 原文地址:https://www.cnblogs.com/yingnan/p/5659966.html
Copyright © 2011-2022 走看看