begin implementing separate metadata parsing
This commit is contained in:
parent
709a2738f9
commit
35c14f09c0
6 changed files with 192 additions and 2 deletions
26
internal/util/queue.go
Normal file
26
internal/util/queue.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package util
|
||||
|
||||
// Enqueue appends an int to the queue
|
||||
func Enqueue(queue []int, element int) []int {
|
||||
queue = append(queue, element)
|
||||
return queue
|
||||
}
|
||||
|
||||
// Dequeue pops the first element of the queue
|
||||
func Dequeue(queue []int) (int, []int) {
|
||||
element := queue[0] // The first element is the one to be dequeued.
|
||||
if len(queue) == 1 {
|
||||
tmp := []int{}
|
||||
return element, tmp
|
||||
}
|
||||
return element, queue[1:] // Slice off the element once it is dequeued.
|
||||
}
|
||||
|
||||
func Tail(queue []int) int {
|
||||
l := len(queue)
|
||||
if l == 0 {
|
||||
return -1
|
||||
} else {
|
||||
return l - 1
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue