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
The Lane package provides implementations of generic `Queue`, `PriorityQueue`, `Stack`, and `Deque` data structures. It was designed with simplicity, performance, and concurrent usage in mind.
9
+
The Lane package provides implementations of generic `Queue`, `PriorityQueue`, `Stack`, and `Deque` data structures. Its design focuses on simplicity, performance, and concurrent usage.
10
10
11
11
<!-- toc -->
12
12
@@ -15,14 +15,14 @@ The Lane package provides implementations of generic `Queue`, `PriorityQueue`, `
15
15
-[Using `v2` releases](#using-v2-releases)
16
16
-[Using `v1` releases](#using-v1-releases)
17
17
-[Usage/Examples](#usageexamples)
18
-
-[Priority Queue](#priority-queue)
18
+
-[Priority queue](#priority-queue)
19
19
-[Example](#example)
20
20
-[Deque](#deque)
21
-
-[Deque Example](#deque-example)
21
+
-[Deque example](#deque-example)
22
22
-[Queue](#queue)
23
-
-[Queue Example](#queue-example)
23
+
-[Queue example](#queue-example)
24
24
-[Stack](#stack)
25
-
-[Stack Example](#stack-example)
25
+
-[Stack example](#stack-example)
26
26
-[Performance](#performance)
27
27
-[Documentation](#documentation)
28
28
-[License](#license)
@@ -31,7 +31,7 @@ The Lane package provides implementations of generic `Queue`, `PriorityQueue`, `
31
31
32
32
Using this package requires a working Go environment. [See the install instructions for Go](http://golang.org/doc/install.html).
33
33
34
-
Go Modules are required when using this package. [See the go blog guide on using Go Modules](https://blog.golang.org/using-go-modules).
34
+
This package requires a modern version of Go supporting modules: [see the go blog guide on using Go Modules](https://blog.golang.org/using-go-modules).
35
35
36
36
### Using `v2` releases
37
37
@@ -63,32 +63,31 @@ import (
63
63
64
64
## Usage/Examples
65
65
66
-
### Priority Queue
66
+
### Priority queue
67
67
68
-
`PriorityQueue`is a _heap priority queue_ data structure implementation. It can be either maximum (descending) or minimum (ascending) oriented (ordered). Every operation on a `PriorityQueue`are synchronized and goroutine-safe. It performs `Push` and `Pop` operations in `O(log N)` time.
68
+
`PriorityQueue`implements a _heap priority queue_ data structure. It can be either max (descending) or min (ascending) ordered. Every operation on a `PriorityQueue`is goroutine-safe. It performs `Push` and `Pop` operations in *O(log N)* time.
Deque is a _head-tail linked list data_ structure implementation. It is built upon a doubly-linked list container, and every operation on a `Deque`are performed in `O(1)` time complexity. Every operation on a `Deque`is synchronized and goroutine-safe.
103
+
Deque implements a _head-tail linked list data_ structure. Built upon a doublylinked list container, every operation performed on a `Deque`happen in *O(1)* time complexity. Every operation on a `Deque`are goroutine-safe.
105
104
106
-
Deques can optionally be instantiated with a limited capacity using the dedicated `NewBoundDeque` constructor, whereby the return value of the `Append` and `Prepend`return false if the Deque was full and the item was not added.
105
+
Users have the option to instantiate Deques with a limited capacity using the dedicated `NewBoundDeque` constructor. When a bound Deque is full, the `Append` and `Prepend`operations fail.
`Queue` is a **FIFO** (_First In First Out_) data structure implementation. It is built upon a `Deque` container and focuses its API on core functionalities: `Enqueue`, `Dequeue`, `Head`. Every operation's time complexity is O(1). Every operation on a `Queue` is synchronized and goroutine-safe.
149
+
`Queue` is a **FIFO** (_First In First Out_) data structure implementation. Built upon a `Deque` container, it focuses its API on the following core functionalities: `Enqueue`, `Dequeue`, `Head`. Every operation on a Queue has a time complexity of *O(1)*. Every operation on a `Queue` is goroutine-safe.
151
150
152
-
#### Queue Example
151
+
#### Queue example
153
152
154
153
```go
155
-
// Create a new queue and pretend we're handling starbucks
156
-
// clients
157
-
queue:= lane.NewQueue[string]()
154
+
// Create a new queue and pretend to handle Starbucks clients
155
+
queue:=NewQueue[string]()
158
156
159
-
//Let's add the incoming clients to the queue
157
+
//Add the incoming clients to the queue
160
158
queue.Enqueue("grumpyClient")
161
159
queue.Enqueue("happyClient")
162
160
queue.Enqueue("ecstaticClient")
163
161
164
162
fmt.Println(queue.Head()) // grumpyClient
165
163
166
-
//Let's handle the clients asynchronously
164
+
//Handle the clients asynchronously
167
165
for {
168
166
client, ok:= queue.Dequeue()
169
167
if !ok {
@@ -176,21 +174,22 @@ for {
176
174
177
175
### Stack
178
176
179
-
`Stack`is a **LIFO** ( _Last in first out_ ) data structure implementation. It is built upon a `Deque` container and focuses its API on core functionalities: `Push`, `Pop`, `Head`. Every operation time complexity is O(1). Every operation on a `Stack` is synchronized and goroutine-safe.
177
+
`Stack`implements a **Last In First Out**data structure. Built upon a `Deque` container, its API focuses on the following core functionalities: `Push`, `Pop`, `Head`. Every operation on a Stack has a time complexity of *O(1)*. Every operation on a `Stack` is goroutine-safe.
0 commit comments