Skip to content

Commit 8798950

Browse files
committed
update readme
1 parent c03b3d5 commit 8798950

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,27 +101,27 @@ dq.PopFront() // Pops from the top, returns 1
101101

102102
### Listeners
103103

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
105105

106106
```go
107107
dq := blocking_dequeue.NewBlockingDequeue[int]()
108108

109-
dq.IsEmpty = func() {
109+
dq.SetOnEmpty(func() {
110110
fmt.Println("Dequeue is now empty")
111-
}
111+
})
112112

113113
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
115115

116116
// Dequeue can only be full if it has a positive capacity
117117
dq.SetCapacity(2)
118118

119-
dq.IsFull = func() {
119+
dq.SetOnFull(func() {
120120
fmt.Println("Dequeue is now full")
121-
}
121+
})
122122

123123
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
125125
```
126126

127127
## API Documentation
@@ -136,10 +136,10 @@ The dequeue itself exposes the following methods:
136136
- `Capacity`, `SetCapacity`, `IsFull`
137137
- `Size`, `IsEmpty`
138138

139-
It also supports the listeners (see example above):
139+
It also supports setting the listeners (see example above):
140140

141-
- `IsEmpty`
142-
- `IsFull`
141+
- `SetOnEmpty`
142+
- `SetOnFull`
143143

144144
The detailed documentation can be found at the related [go packages page](https://pkg.go.dev/github.com/AmrSaber/go-blocking-dequeue).
145145

@@ -174,7 +174,7 @@ ch <- 1
174174
<- ch
175175
```
176176

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...
178178

179179
## Benchmarking
180180

0 commit comments

Comments
 (0)