Skip to content

Commit

Permalink
Add queue package README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
nchengyeeshen committed Dec 19, 2021
1 parent 1a7d462 commit 04fff3a
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions queue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->

# queue

```go
import "github.com/zyedidia/generic/queue"
```

Package queue provides an implementation of a First In First Out \(FIFO\) queue\. The FIFO queue is implemented using a doubly\-linked list found in the 'list' package\.

## Index

- [type FIFOQueue](<#type-fifoqueue>)
- [func New[T any]() *FIFOQueue[T]](<#func-new>)
- [func (q *FIFOQueue[T]) Dequeue() T](<#func-badrecv-dequeue>)
- [func (q *FIFOQueue[T]) Empty() bool](<#func-badrecv-empty>)
- [func (q *FIFOQueue[T]) Enqueue(value T)](<#func-badrecv-enqueue>)
- [func (q *FIFOQueue[T]) Iter() iter.Iter[T]](<#func-badrecv-iter>)
- [func (q *FIFOQueue[T]) Peek() T](<#func-badrecv-peek>)


## type [FIFOQueue](<https://github.com/nchengyeeshen/generic/blob/master/queue/fifo_queue.go#L12-L14>)

FIFOQueue is a simple First In First Out \(FIFO\) queue\.

```go
type FIFOQueue[T any] struct {
// contains filtered or unexported fields
}
```

### func [New](<https://github.com/nchengyeeshen/generic/blob/master/queue/fifo_queue.go#L17>)

```go
func New[T any]() *FIFOQueue[T]
```

New returns an empty First In First Out \(FIFO\) queue\.

### func \(\*BADRECV\) [Dequeue](<https://github.com/nchengyeeshen/generic/blob/master/queue/fifo_queue.go#L31>)

```go
func (q *FIFOQueue[T]) Dequeue() T
```

Dequeue removes and returns the item at the front of the queue\.

A panic occurs if the queue is Empty\.

### func \(\*BADRECV\) [Empty](<https://github.com/nchengyeeshen/generic/blob/master/queue/fifo_queue.go#L46>)

```go
func (q *FIFOQueue[T]) Empty() bool
```

Empty returns true if the queue is empty\.

### func \(\*BADRECV\) [Enqueue](<https://github.com/nchengyeeshen/generic/blob/master/queue/fifo_queue.go#L24>)

```go
func (q *FIFOQueue[T]) Enqueue(value T)
```

Enqueue inserts 'value' to the end of the queue\.

### func \(\*BADRECV\) [Iter](<https://github.com/nchengyeeshen/generic/blob/master/queue/fifo_queue.go#L52>)

```go
func (q *FIFOQueue[T]) Iter() iter.Iter[T]
```

Iter returns a forward iterator\, returning items starting from the front to the back of the queue\.

### func \(\*BADRECV\) [Peek](<https://github.com/nchengyeeshen/generic/blob/master/queue/fifo_queue.go#L41>)

```go
func (q *FIFOQueue[T]) Peek() T
```

Peek returns the item at the front of the queue without removing it\.

A panic occurs if the queue is Empty\.



Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

0 comments on commit 04fff3a

Please sign in to comment.