type MyQueue struct {
A []int
}
/** Initialize your data structure here. */
func Constructor() MyQueue {
return MyQueue{
A: make([]int, 0),
}
}
/** Push element x to the back of queue. */
func (this *MyQueue) Push(x int) {
this.A = append(this.A, x)
}
/** Removes the element from in front of queue and returns that element. */
func (this *MyQueue) Pop() int {
x := 0
if len(this.A) >= 1 {
x = this.A[0]
this.A = this.A[1:]
}
return x
}
/** Get the front element. */
func (this *MyQueue) Peek() int {
if len(this.A) >= 1 {
return this.A[0]
}
return 0
}
/** Returns whether the queue is empty. */
func (this *MyQueue) Empty() bool {
return len(this.A) == 0
}
/**
* Your MyQueue object will be instantiated and called as such:
* obj := Constructor();
* obj.Push(x);
* param_2 := obj.Pop();
* param_3 := obj.Peek();
* param_4 := obj.Empty();
*/