Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Vault
Commits
ccf015ae
Unverified
Commit
ccf015ae
authored
6 years ago
by
Clint Shryock
Browse files
Options
Download
Email Patches
Plain Diff
Make ErrItemNotFound a function so we can insert the key in the error
parent
8c483278
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
helper/queue/priorityqueue.go
+8
-7
helper/queue/priorityqueue.go
with
8 additions
and
7 deletions
+8
-7
helper/queue/priorityqueue.go
+
8
-
7
View file @
ccf015ae
...
...
@@ -2,13 +2,9 @@ package queue
import
(
"container/heap"
"
errors
"
"
fmt
"
)
// ErrNoItemFound is used in Pluck and Find, to indicate a matching item was not
// found
var
ErrNoItemFound
=
errors
.
New
(
"item not found in queue"
)
// PriorityQueue interface defines what a Queue must include, which is satisfying
// heap.Interface, and a few additional methods
// TODO: refactor to be just Queue, or add a generic Queue type that implements
...
...
@@ -31,13 +27,18 @@ type PriorityQueue interface {
// Peek()
// Pluck removes an item from the queue by the given Key. Pluck must fix the
// queue after removal. If no item is removed, returns Err
No
ItemFound
// queue after removal. If no item is removed, returns ErrItem
Not
Found
Pluck
(
string
)
(
*
Item
,
error
)
// Find searches and returns item from the queue, if found. This does not
// remove the item. If no item is found, returns Err
No
ItemFound
// remove the item. If no item is found, returns ErrItem
Not
Found
Find
(
string
)
(
*
Item
,
error
)
// Size reports the number of items in the queue
// Size() int
}
// ErrItemNotFound creates a "not found" error for the given key
func
ErrItemNotFound
(
key
string
)
error
{
return
fmt
.
Errorf
(
"queue item with key (%s) not found"
,
key
)
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment