Skip to content

Commit

Permalink
Add Items() to fork of sheerun/queue
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwardDowling committed Apr 12, 2020
1 parent a40b88f commit 56830d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/EdwardDowling/queue

go 1.14
11 changes: 11 additions & 0 deletions queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,14 @@ func (q *Queue) Remove(elem interface{}) bool {
delete(q.items, id)
return true
}

// Returns a slice of the items in the queue
func (q *Queue) Items() []interface{} {
q.mutex.Lock()
defer q.mutex.Unlock()
ret := []interface{}{}
for _, v := range q.items {
ret = append(ret, v)
}
return ret
}

0 comments on commit 56830d4

Please sign in to comment.