内容简介:来源:
package datastructure
import (
"errors"
)
type Queue struct {
list []int
}
func NewQueue() *Queue {
list := make([]int, 0)
return &Queue{list}
}
func (q *Queue) Enqueue(val int) {
q.list = append(q.list, val)
}
func (q *Queue) Dequeue() int {
if q.Len() == 0 {
panic(errors.New("queue is empty"))
}
val := q.list[0]
q.list = q.list[1:]
return val
}
func (q *Queue) Len() int {
return len(q.list)
}
来源: leetcode刷题记录
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Practical Vim, Second Edition
Drew Neil / The Pragmatic Bookshelf / 2015-10-31 / USD 29.00
Vim is a fast and efficient text editor that will make you a faster and more efficient developer. It’s available on almost every OS, and if you master the techniques in this book, you’ll never need an......一起来看看 《Practical Vim, Second Edition》 这本书的介绍吧!