Skip to content

Commit

Permalink
Added more examples; releasing v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrpetrin committed Nov 28, 2018
1 parent 2968873 commit b2a8f87
Show file tree
Hide file tree
Showing 4 changed files with 479 additions and 2 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@

# 1.0.0

* First stable release, production ready, certified to use as a FIFO queue or LIFO stack. Mixed Push/Pop/Front/Back is pending more testing and so is not recommended for use in a production setting.


# 1.0.1

* Fixed bug related to spare slices. The bug where the deque was not eliminating reused slices correctly caused it to cache more slices than maxSpareLinks (4), inflating memory unnecessarily. In refill scenarios where some items are pushed and removed from the deque repeatedly, can cause the deque to return 'nil' instead of the actual value if exactly a multiple of 256 + 16 (i.e. 272, 528, 784, etc) is pushed into the deque.
- Commit 1: https://github.com/ef-ds/deque/commit/5cda9cbd756b5001cd8bb5e2b33675d65c61149d
- Commit 2: https://github.com/ef-ds/deque/commit/4de25e4de16dfe904669fe0a4ad3b0d189095fad
- Benchmark tests: [v1.0.0 vs v1.0.1](testdata/release_v1.0.1.md)

* Mixed Push/Pop/Front/Back is pending more testing and so is not recommended for use in production environment.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ We recommend to target only released versions for production use.


## How to Use
As a First-In-First-Out [queue](https://en.wikipedia.org/wiki/Queue_(abstract_data_type)).

```go
package main

Expand Down Expand Up @@ -48,6 +50,40 @@ Output:
5
```


As a Last-In-First-Out [stack](https://en.wikipedia.org/wiki/Stack_(abstract_data_type)).

```go
package main

import (
"fmt"

"github.com/ef-ds/deque"
)

func main() {
d := deque.New()

for i := 1; i <= 5; i++ {
d.PushBack(i)
}
for d.Len() > 0 {
v, _ := d.PopBack()
fmt.Println(v)
}
}
```

Output:
```
5
4
3
2
1
```

Also refer to the [integration](integration_test.go) and [API](api_test.go).


Expand Down
15 changes: 14 additions & 1 deletion doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/ef-ds/deque"
)

func Example() {
func Example_fIFOQueue() {
d := deque.New()

for i := 0; i < 5; i++ {
Expand All @@ -18,3 +18,16 @@ func Example() {
}
// Output: 01234
}

func Example_stack() {
d := deque.New()

for i := 0; i < 5; i++ {
d.PushBack(i)
}
for d.Len() > 0 {
v, _ := d.PopBack()
fmt.Print(v)
}
// Output: 43210
}
Loading

0 comments on commit b2a8f87

Please sign in to comment.