Last active
October 20, 2019 07:02
-
-
Save P-A-R-U-S/2697b7c0fcbfa6b032908b19edc65a27 to your computer and use it in GitHub Desktop.
Queue in Go/Golang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Helpers | |
type Queue struct { | |
q []int32 | |
} | |
func (q *Queue) push(v int32) { | |
q.q = append(q.q, v) | |
} | |
func (q *Queue) pop() int32 { | |
v := q.q[0] | |
q.q = q.q[1:] | |
return v | |
} | |
func (q *Queue) isEmpty() bool { | |
return len(q.q) == 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment