You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,27 +101,27 @@ dq.PopFront() // Pops from the top, returns 1
101
101
102
102
### Listeners
103
103
104
-
You can attach the listeners `OnEmpty` and `OnFull` to be invoked when the dequeue is empty or full respectively
104
+
You can attach listeners `onEmpty` and `onFull` to be invoked when the dequeue is empty or full respectively
105
105
106
106
```go
107
107
dq:= blocking_dequeue.NewBlockingDequeue[int]()
108
108
109
-
dq.IsEmpty = func() {
109
+
dq.SetOnEmpty(func() {
110
110
fmt.Println("Dequeue is now empty")
111
-
}
111
+
})
112
112
113
113
dq.PushBack(1)
114
-
dq.PopFront() // "Dequeue is now empty" is printed as IsEmpty listener is invoked
114
+
dq.PopFront() // "Dequeue is now empty" is printed as onEmpty listener is invoked
115
115
116
116
// Dequeue can only be full if it has a positive capacity
117
117
dq.SetCapacity(2)
118
118
119
-
dq.IsFull = func() {
119
+
dq.SetOnFull(func() {
120
120
fmt.Println("Dequeue is now full")
121
-
}
121
+
})
122
122
123
123
dq.PushBack(1)
124
-
dq.PushBack(2) // "Dequeue is now full" is printed as IsFull listener is invoked
124
+
dq.PushBack(2) // "Dequeue is now full" is printed as onFull listener is invoked
125
125
```
126
126
127
127
## API Documentation
@@ -136,10 +136,10 @@ The dequeue itself exposes the following methods:
136
136
-`Capacity`, `SetCapacity`, `IsFull`
137
137
-`Size`, `IsEmpty`
138
138
139
-
It also supports the listeners (see example above):
139
+
It also supports setting the listeners (see example above):
140
140
141
-
-`IsEmpty`
142
-
-`IsFull`
141
+
-`SetOnEmpty`
142
+
-`SetOnFull`
143
143
144
144
The detailed documentation can be found at the related [go packages page](https://pkg.go.dev/github.com/AmrSaber/go-blocking-dequeue).
145
145
@@ -174,7 +174,7 @@ ch <- 1
174
174
<- ch
175
175
```
176
176
177
-
That is unless you need access the other provided methods and listeners, such as `Peek` variations, `Size`, `IsFull`, `OnEmpty`, `OnFull`, and so on...
177
+
That is unless you need access the other provided methods and listeners, such as `Peek` variations, `Size`, `IsFull`, `onEmpty`, `onFull`, and so on...
0 commit comments