<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## **[SplDoublyLinkedList](https://www.php.net/manual/zh/class.spldoublylinkedlist.php)** >[info] 雙鏈表是一種重要的線性存儲結構,對于雙鏈表中的每個節點,不僅僅存儲自己的信息,還要保存前驅和后繼節點的地址 ``` SplDoublyLinkedList?implements?Iterator?,?ArrayAccess?,?Countable?{ /* 常量 */ const integer IT_MODE_LIFO = 2 ;//列表將以后進先出的順序迭代,就像堆棧一樣。 const integer IT_MODE_FIFO = 0 ; //列表將按先進先出的順序迭代,就像隊列一樣 const integer IT_MODE_DELETE = 1 ; //迭代將刪除迭代的元素 const integer IT_MODE_KEEP = 0 ;//迭代不會刪除迭代的元素。 ????/*?方法?*/ ????public?__construct?(?void?)???? ????public?void?add?(?mixed?$index?,?mixed?$newval?)????//在指定的索引處添加/插入新值 ????public?mixed?bottom?(?void?) //返回雙鏈表的尾部節點 即最后一個 ????public?int?count?(?void?) //雙聯表元素的個數 Countable? ????public?mixed?current?(?void?) //返回當前記錄節點索引的值 超出范圍返回空 Iterator ????public?int?getIteratorMode?(?void?) ?//獲取迭代模式 ????public?bool?isEmpty?(?void?) //檢測雙鏈表是否為空 ????public?mixed?key?(?void?) //當前節點索引 Iterator ????public?void?next?(?void?) //移到下條記錄 超過 Iterator ????public?bool?offsetExists?(?mixed?$index?) //指定index處節點是否存在 ArrayAccess? ????public?mixed?offsetGet?(?mixed?$index?) //獲取指定index處節點值 ArrayAccess? ????public?void?offsetSet?(?mixed?$index?,?mixed?$newval?) //設置指定index處值 ArrayAccess? ????public?void?offsetUnset?(?mixed?$index?) //刪除指定index處節點 ArrayAccess? ????public?mixed?pop?(?void?) //從雙鏈表的尾部彈出元素 并返回該元素 ????public?void?prev?(?void?) //移到上條記錄 ????public?void?push?(?mixed?$value?) //添加元素到雙鏈表的尾部 ????public?void?rewind?(?void?) //將指針指向迭代開始處 Iterator ????public?string?serialize?(?void?) //序列化存儲 ????public?void?setIteratorMode?(?int?$mode?) //設置迭代模式 ????public?mixed?shift?(?void?) //雙鏈表的頭部移除元素 ????public?mixed?top?(?void?) //雙鏈表的頭部節點即第一個 ????public?void?unserialize?(?string?$serialized?) //反序列化 ????public?void?unshift?(?mixed?$value?) //雙鏈表的頭部添加元素 ????public?bool?valid?(?void?) //檢查雙鏈表是否還有節點 Iterator } ``` ## **用法:** ``` <?php $list = new SplDoublyLinkedList(); //添加元素到雙鏈表的尾部 $list->push('a'); $list->push('b'); $list->push('c'); $list->push('d'); //$this->dllist=[a.b.c,d] //移除雙鏈表的尾部的一個元素 $list->pop(); //$this->dllist=[a,b,c] //雙鏈表的頭部添加元素 $list->unshift('1'); $list->unshift('2'); $list->unshift('3'); //$this->dllist=[3,2,1,a,b,c] //移除雙鏈表的頭部的一個元素 $list->shift(); //$this->dllist=[2,1,a,b,c] $list->rewind();//rewind操作用于把節點指針指向Bottom所在的節點 將指針指向迭代開始處 echo 'curren node:'.$list->current()."<br />";//獲取當前節點 2 $list->next();//指針指向下一個節點 $list->next();//指針指向下一個節點 $list->next();//指針指向下一個節點 $list->next();//指針指向下一個節點 echo 'next node:'.$list->current()."<br />";//c $list->prev();//指針指向上一個節點 echo 'next node:'.$list->current()."<br />";//b if($list->current()) echo 'current node is valid<br />'; else echo 'current node is invalid<br />'; if($list->valid())//如果當前節點是有效節點,valid返回true echo "valid list<br />"; else echo "invalid list <br />"; var_dump(array( 'pop' => $list->pop(), 'count' => $list->count(), 'isEmpty' => $list->isEmpty(), 'bottom' => $list->bottom(), 'top' => $list->top() )) //['pop'=>'c','count'=>4,'isEmpty'=>false,'bottom'=>2,top=>'b'] //設置迭代模式 $list->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO); var_dump($list->getIteratorMode());//0 for($list->rewind(); $list->valid(); $list->next()){ echo $list->current().PHP_EOL; } var_dump($a = $list->serialize());//"i:0;:s:1:"2";:s:1:"1";:s:1:"a";:s:1:"b";" print_r($list->unserialize($a));//null? 得到的是不想要的結果還會將$list的結果復制一遍 //用serialize($list)和unserialize($a) 代替 //offsetExists用法 $t = isset($list[0]); var_dump($t);// 輸出: boolean true $t = isset($list[10]); var_dump($t);// 輸出: boolean false //offsetGet用法 var_dump($list[0]);//2 //offsetSet用法 $list[0]='new value'; //offsetUnset用法 unset($list[0]); $list->offsetSet(0,'new one'); $list->offsetUnset(0); var_dump(array( 'offsetExists' => $list->offsetExists(4), 'offsetGet' => $list->offsetGet(0), )); //['offsetExists'=>true,'offsetGet'=>1] var_dump($list); ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看