<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] ## golang-鏈表實現 <details> <summary>main.go </summary> ``` type QueLink struct { val int exist bool next *QueLink } type MyCircularQueue struct { size int hasSize int first *QueLink last *QueLink cur *QueLink } func Constructor(k int) MyCircularQueue { root := &QueLink{} first := &QueLink{} for i := 0; i < k; i++ { if i == 0 { root.next = &QueLink{} first = root root = root.next } else if i == k-1 { root.next = first } else { root.next = &QueLink{} root = root.next } } return MyCircularQueue{ size: k, hasSize: 0, first: first, last: first, cur: first, } } func (this *MyCircularQueue) EnQueue(value int) bool { if this.IsFull() { return false } this.cur.val = value this.cur.exist = true if this.IsEmpty() { this.first = this.cur } this.last = this.cur this.cur = this.cur.next this.hasSize++ return true } func (this *MyCircularQueue) DeQueue() bool { if this.IsEmpty() { return false } this.first.exist = false this.first = this.first.next this.hasSize-- return true } func (this *MyCircularQueue) Front() int { if this.IsEmpty() { return -1 } return this.first.val } func (this *MyCircularQueue) Rear() int { if this.IsEmpty() { return -1 } return this.last.val } func (this *MyCircularQueue) IsEmpty() bool { if this.hasSize == 0 { return true } return false } func (this *MyCircularQueue) IsFull() bool { if this.hasSize == this.size { return true } return false } ``` </details> <br /> ## golang-鏈表實現 <details> <summary> main.go</summary> ``` type MyCircularQueue struct { size int hasSize int cur int last int first int list []int } func Constructor(k int) MyCircularQueue { return MyCircularQueue{ size: k, hasSize: 0, list: make([]int, k), first: 0, last: 0, cur: 0, } } func (this *MyCircularQueue) EnQueue(value int) bool { if this.IsFull() { return false } this.list[this.cur] = value this.last = this.cur this.cur++ if this.cur >= this.size { this.cur = 0 } this.hasSize++ return true } func (this *MyCircularQueue) DeQueue() bool { if this.IsEmpty() { return false } this.first++ if this.first >= this.size { this.first = 0 } this.hasSize-- return true } func (this *MyCircularQueue) Front() int { if this.IsEmpty() { return -1 } return this.list[this.first] } func (this *MyCircularQueue) Rear() int { if this.IsEmpty() { return -1 } return this.list[this.last] } func (this *MyCircularQueue) IsEmpty() bool { if this.hasSize == 0 { return true } return false } func (this *MyCircularQueue) IsFull() bool { if this.hasSize == this.size { return true } return false } ``` </details> <br />
                  <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>

                              哎呀哎呀视频在线观看