Documentation ¶
Index ¶
- type ArrayQueue
- func (q *ArrayQueue[T]) Back() T
- func (q *ArrayQueue[T]) Clear()
- func (q *ArrayQueue[T]) Contain(value T) bool
- func (q *ArrayQueue[T]) Data() []T
- func (q *ArrayQueue[T]) DeQueue() (*T, error)
- func (q *ArrayQueue[T]) EnQueue(value T)
- func (q *ArrayQueue[T]) Front() T
- func (q *ArrayQueue[T]) IsEmpty() bool
- func (q *ArrayQueue[T]) Print()
- func (q *ArrayQueue[T]) Size() int
- type CircularQueue
- func (q *CircularQueue[T]) Back() T
- func (q *CircularQueue[T]) Clear()
- func (q *CircularQueue[T]) Contain(value T) bool
- func (q *CircularQueue[T]) Data() []T
- func (q *CircularQueue[T]) DeQueue() (*T, error)
- func (q *CircularQueue[T]) EnQueue(value T) error
- func (q *CircularQueue[T]) Front() T
- func (q *CircularQueue[T]) IsEmpty() bool
- func (q *CircularQueue[T]) IsFull() bool
- func (q *CircularQueue[T]) Length() int
- func (q *CircularQueue[T]) Print()
- type LinkedQueue
- func (q *LinkedQueue[T]) Back() (*T, error)
- func (q *LinkedQueue[T]) Clear()
- func (q *LinkedQueue[T]) Data() []T
- func (q *LinkedQueue[T]) DeQueue() (*T, error)
- func (q *LinkedQueue[T]) EnQueue(value T)
- func (q *LinkedQueue[T]) Front() (*T, error)
- func (q *LinkedQueue[T]) IsEmpty() bool
- func (q *LinkedQueue[T]) Print()
- func (q *LinkedQueue[T]) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayQueue ¶
type ArrayQueue[T any] struct { // contains filtered or unexported fields }
ArrayQueue implements queue with slice
func NewArrayQueue ¶
func NewArrayQueue[T any](values ...T) *ArrayQueue[T]
NewArrayQueue return a empty ArrayQueue pointer
func (*ArrayQueue[T]) Contain ¶
func (q *ArrayQueue[T]) Contain(value T) bool
Contain checks if the value is in queue or not
func (*ArrayQueue[T]) DeQueue ¶
func (q *ArrayQueue[T]) DeQueue() (*T, error)
DeQueue remove head element of queue and return it, if queue is empty, return nil and error
func (*ArrayQueue[T]) EnQueue ¶
func (q *ArrayQueue[T]) EnQueue(value T)
EnQueue put element into queue
func (*ArrayQueue[T]) IsEmpty ¶
func (q *ArrayQueue[T]) IsEmpty() bool
IsEmpty checks if queue is empty or not
type CircularQueue ¶
type CircularQueue[T any] struct { // contains filtered or unexported fields }
CircularQueue implements circular queue with slice, last index of CircularQueue don't contain value, so acturl capacity is size - 1
func NewCircularQueue ¶
func NewCircularQueue[T any](size int) *CircularQueue[T]
NewCircularQueue return a empty CircularQueue pointer
func (*CircularQueue[T]) Contain ¶
func (q *CircularQueue[T]) Contain(value T) bool
Contain checks if the value is in queue or not
func (*CircularQueue[T]) DeQueue ¶
func (q *CircularQueue[T]) DeQueue() (*T, error)
DeQueue remove head element of queue and return it, if queue is empty, return nil and error
func (*CircularQueue[T]) EnQueue ¶
func (q *CircularQueue[T]) EnQueue(value T) error
EnQueue put element into queue
func (*CircularQueue[T]) Front ¶
func (q *CircularQueue[T]) Front() T
Front return front value of queue
func (*CircularQueue[T]) IsEmpty ¶
func (q *CircularQueue[T]) IsEmpty() bool
IsEmpty checks if queue is empty or not
func (*CircularQueue[T]) IsFull ¶
func (q *CircularQueue[T]) IsFull() bool
IsFull checks if queue is full or not
func (*CircularQueue[T]) Length ¶
func (q *CircularQueue[T]) Length() int
Length return current data length of queue
type LinkedQueue ¶
type LinkedQueue[T any] struct { // contains filtered or unexported fields }
LinkedQueue implements queue with link list
func NewLinkedQueue ¶
func NewLinkedQueue[T any]() *LinkedQueue[T]
NewLinkedQueue return a empty LinkedQueue pointer
func (*LinkedQueue[T]) Back ¶
func (q *LinkedQueue[T]) Back() (*T, error)
Back return back value of queue
func (*LinkedQueue[T]) DeQueue ¶
func (q *LinkedQueue[T]) DeQueue() (*T, error)
DeQueue delete head element of queue then return it, if queue is empty, return nil and error
func (*LinkedQueue[T]) EnQueue ¶
func (q *LinkedQueue[T]) EnQueue(value T)
EnQueue add element into queue
func (*LinkedQueue[T]) Front ¶
func (q *LinkedQueue[T]) Front() (*T, error)
Front return front value of queue
func (*LinkedQueue[T]) IsEmpty ¶
func (q *LinkedQueue[T]) IsEmpty() bool
IsEmpty checks if queue is empty or not