主頁(yè) > 知識(shí)庫(kù) > php 數(shù)據(jù)結(jié)構(gòu)之鏈表隊(duì)列

php 數(shù)據(jù)結(jié)構(gòu)之鏈表隊(duì)列

熱門(mén)標(biāo)簽:安徽移動(dòng)外呼系統(tǒng) 百度地圖標(biāo)注飯店位置怎么 施工地圖標(biāo)注怎么做 百度地圖標(biāo)注名編輯 個(gè)性化地圖標(biāo)注在線 深圳400電話辦理那家好 清遠(yuǎn)陽(yáng)山400電話號(hào)碼如何申請(qǐng) 襄陽(yáng)房產(chǎn)電銷(xiāo)機(jī)器人招商 怎么在高德地圖標(biāo)注行走軌跡

php 鏈表隊(duì)列

實(shí)例代碼:

class Queue{ 
  
  private $last; 
  private $first; 
  private $oldfirst; 
  private static $n=0; 
   
  public function __construct(){ 
    $this->last   = null; 
    $this->first  = null; 
    $this->oldfirst = null; 
  } 
   
  public function push($item){ 
    $this->oldfirst = $this->last; 
    $this->last = new Node(); 
    $this->last->item = $item; 
    $this->last->next = null; 
    if(empty($this->first)){ 
      $this->first = $this->last; 
    }else{ 
      $this->oldfirst->next = $this->last; 
    } 
    self::$n++; 
  } 
   
  public function pop(){ 
    if(self::$n0){ 
      return null; 
    } 
    $item = $this->first->item; 
    $this->first = $this->first->next; 
    self::$n--; 
    return $item; 
  } 
   
} 
 
class Node{ 
  public $item; 
  public $next; 
} 
 
$Queue = new Queue(); 
$Queue->push("a"); 
$Queue->push("b"); 
$Queue->push("c"); 
echo $Queue->pop().PHP_EOL; 
echo $Queue->pop().PHP_EOL; 
echo $Queue->pop().PHP_EOL; 
echo $Queue->pop().PHP_EOL;

如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

您可能感興趣的文章:
  • PHP雙向鏈表定義與用法示例
  • php實(shí)現(xiàn)單鏈表的實(shí)例代碼
  • 淺談PHP鏈表數(shù)據(jù)結(jié)構(gòu)(單鏈表)
  • PHP小教程之實(shí)現(xiàn)雙向鏈表
  • PHP環(huán)形鏈表實(shí)現(xiàn)方法示例
  • PHP中模擬鏈表和鏈表的基本操作示例
  • PHP簡(jiǎn)單實(shí)現(xiàn)循環(huán)鏈表功能示例
  • PHP實(shí)現(xiàn)鏈表的定義與反轉(zhuǎn)功能示例

標(biāo)簽:延邊 南昌 阜陽(yáng) 黑河 駐馬店 欽州 臨夏 中衛(wèi)

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《php 數(shù)據(jù)結(jié)構(gòu)之鏈表隊(duì)列》,本文關(guān)鍵詞  php,數(shù)據(jù)結(jié)構(gòu),之鏈,表,隊(duì)列,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《php 數(shù)據(jù)結(jié)構(gòu)之鏈表隊(duì)列》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于php 數(shù)據(jù)結(jié)構(gòu)之鏈表隊(duì)列的相關(guān)信息資訊供網(wǎng)民參考!
  • 企业400电话

    智能AI客服机器人
    15000

    在线订购

    合计11份范本:公司章程+合伙协议+出资协议+合作协议+股权转让协议+增资扩股协议+股权激励+股东会决议+董事会决议

    推薦文章