File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -56,13 +56,31 @@ import "github.com/adrianbrad/queue"
56
56
``` go
57
57
// Queue is a generic queue interface, defining the methods that all queues must implement.
58
58
type Queue [T comparable] interface {
59
+ // Get retrieves and removes the head of the queue.
59
60
Get () (T, error )
61
+
62
+ // Offer inserts the element to the tail of the queue.
60
63
Offer (T) error
64
+
65
+ // Reset sets the queue to its initial state.
61
66
Reset ()
67
+
68
+ // Contains returns true if the queue contains the element.
69
+ Contains (T) bool
70
+
71
+ // Peek retrieves but does not remove the head of the queue.
62
72
Peek () (T, error )
73
+
74
+ // Size returns the number of elements in the queue.
63
75
Size () int
76
+
77
+ // IsEmpty returns true if the queue is empty.
64
78
IsEmpty () bool
79
+
80
+ // Iterator returns a channel that will be filled with the elements
65
81
Iterator () <- chan T
82
+
83
+ // Clear removes all elements from the queue.
66
84
Clear () []T
67
85
}
68
86
```
@@ -216,4 +234,4 @@ BenchmarkCircularQueue/Offer-12 38328231 37.57 ns/op
216
234
BenchmarkPriorityQueue/Peek-12 75156879 15.79 ns/op 0 B/op 0 allocs/op
217
235
BenchmarkPriorityQueue/Get_Offer-12 17643837 68.65 ns/op 0 B/op 0 allocs/op
218
236
BenchmarkPriorityQueue/Offer-12 20506784 57.43 ns/op 54 B/op 0 allocs/op
219
- ```
237
+ ```
You can’t perform that action at this time.
0 commit comments