Skip to content

Instantly share code, notes, and snippets.

@P-A-R-U-S
Last active October 20, 2019 07:02
Show Gist options
  • Save P-A-R-U-S/2697b7c0fcbfa6b032908b19edc65a27 to your computer and use it in GitHub Desktop.
Save P-A-R-U-S/2697b7c0fcbfa6b032908b19edc65a27 to your computer and use it in GitHub Desktop.
Queue in Go/Golang
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