Skip to content

Commit 848e998

Browse files
authored
Merge pull request #4 from apatniv/patch-1
Add missing method `Contains` and descriptions
2 parents 3978143 + fe7e785 commit 848e998

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,31 @@ import "github.com/adrianbrad/queue"
5656
```go
5757
// Queue is a generic queue interface, defining the methods that all queues must implement.
5858
type Queue[T comparable] interface {
59+
// Get retrieves and removes the head of the queue.
5960
Get() (T, error)
61+
62+
// Offer inserts the element to the tail of the queue.
6063
Offer(T) error
64+
65+
// Reset sets the queue to its initial state.
6166
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.
6272
Peek() (T, error)
73+
74+
// Size returns the number of elements in the queue.
6375
Size() int
76+
77+
// IsEmpty returns true if the queue is empty.
6478
IsEmpty() bool
79+
80+
// Iterator returns a channel that will be filled with the elements
6581
Iterator() <-chan T
82+
83+
// Clear removes all elements from the queue.
6684
Clear() []T
6785
}
6886
```
@@ -216,4 +234,4 @@ BenchmarkCircularQueue/Offer-12 38328231 37.57 ns/op
216234
BenchmarkPriorityQueue/Peek-12 75156879 15.79 ns/op 0 B/op 0 allocs/op
217235
BenchmarkPriorityQueue/Get_Offer-12 17643837 68.65 ns/op 0 B/op 0 allocs/op
218236
BenchmarkPriorityQueue/Offer-12 20506784 57.43 ns/op 54 B/op 0 allocs/op
219-
```
237+
```

0 commit comments

Comments
 (0)