久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php如何實(shí)現(xiàn)鏈表?

      php實(shí)現(xiàn)鏈表的方法:首先定義一個(gè)節(jié)點(diǎn)類,代碼為【function __construct($val=null)】;然后實(shí)現(xiàn)鏈表的實(shí)現(xiàn)類,代碼為【function_construct $this->dummyhead = new Nod】。

      php如何實(shí)現(xiàn)鏈表?

      php實(shí)現(xiàn)鏈表的方法:

      首先定義一個(gè)節(jié)點(diǎn)類

      class Node{     public $val;     public $next;     function __construct($val=null){         $this->val = $val;         $this->next = null;     } }

      鏈表的實(shí)現(xiàn)類

      class MyLinkedList {     public $dummyhead; //定義一個(gè)虛擬的頭結(jié)點(diǎn)     public $size;        function __construct() {         $this->dummyhead = new Node();          $this->size = 0;     }          function get($index) {         if($index < 0 || $index >= $this->size)             return -1;         $cur = $this->dummyhead;         for($i = 0; $i < $index; $i++){             $cur = $cur->next;         }         return $cur->next->val;     }        function addAtHead($val) {         $this->addAtIndex(0,$val);     }           function addAtTail($val) {         $this->addAtIndex($this->size,$val);     }        function addAtIndex($index, $val) {         if($index < 0 || $index > $this->size)             return;         $cur = $this->dummyhead;         for($i = 0; $i < $index; $i++){             $cur = $cur->next;         }         $node = new Node($val);         $node->next = $cur->next;         $cur->next = $node;         $this->size++;     }        function deleteAtIndex($index) {         if($index < 0 || $index >= $this->size)             return;         $cur = $this->dummyhead;         for($i = 0; $i < $index; $i++){             $cur = $cur->next;         }         $cur->next = $cur->next->next;         $this->size--;     } }

      相關(guān)學(xué)習(xí)推薦:PHP編程從入門到精通

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)