Skip to content

Commit d119134

Browse files
author
Tony Lambiris
committed
Add getMatch() function
1 parent 6e3f41b commit d119134

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

queue/queue.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,25 @@ func (items *items) getUntil(checker func(item interface{}) bool) []interface{}
145145
return returnItems
146146
}
147147

148+
func (items *items) getMatch(checker func(item interface{}) bool) []interface{} {
149+
length := len(*items)
150+
151+
if len(*items) == 0 {
152+
// returning nil here actually wraps that nil in a list
153+
// of interfaces... thanks go
154+
return []interface{}{}
155+
}
156+
157+
returnItems := make([]interface{}, 0, length)
158+
for _, item := range *items {
159+
if !checker(item) {
160+
returnItems = append(returnItems, item)
161+
}
162+
}
163+
164+
return returnItems
165+
}
166+
148167
type sema struct {
149168
ready chan bool
150169
response *sync.WaitGroup

0 commit comments

Comments
 (0)