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, bool)
- func (q *ArrayQueue[T]) Enqueue(item T) bool
- func (q *ArrayQueue[T]) Front() T
- func (q *ArrayQueue[T]) IsEmpty() bool
- func (q *ArrayQueue[T]) IsFull() 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]) Print()
- func (q *CircularQueue[T]) Size() int
- type LinkedQueue
- func (q *LinkedQueue[T]) Back() (*T, error)
- func (q *LinkedQueue[T]) Clear()
- func (q *LinkedQueue[T]) Contain(value T) bool
- 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
- type PriorityQueue
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](capacity int) *ArrayQueue[T]
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 ¶ added in v2.0.4
func (q *ArrayQueue[T]) Dequeue() (T, bool)
DeQueue remove head element of queue and return it, if queue is empty, return nil and error
func (*ArrayQueue[T]) Enqueue ¶ added in v2.0.4
func (q *ArrayQueue[T]) Enqueue(item T) bool
EnQueue put element into queue
func (*ArrayQueue[T]) IsEmpty ¶
func (q *ArrayQueue[T]) IsEmpty() bool
IsEmpty checks if queue is empty or not
func (*ArrayQueue[T]) IsFull ¶ added in v2.0.8
func (q *ArrayQueue[T]) IsFull() bool
IsFull checks if queue is full or not
func (*ArrayQueue[T]) Size ¶
func (q *ArrayQueue[T]) Size() int
Size return number of elements in queue
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 capacity - 1
func NewCircularQueue ¶
func NewCircularQueue[T any](capacity 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]) Data ¶
func (q *CircularQueue[T]) Data() []T
Data return slice of queue data
func (*CircularQueue[T]) Dequeue ¶ added in v2.0.8
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 ¶ added in v2.0.8
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]) Size ¶ added in v2.0.8
func (q *CircularQueue[T]) Size() int
Size return number of elements in circular 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]) Contain ¶ added in v2.0.8
func (q *LinkedQueue[T]) Contain(value T) bool
Contain checks if the value is in queue or not
func (*LinkedQueue[T]) Dequeue ¶ added in v2.0.8
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 ¶ added in v2.0.8
func (q *LinkedQueue[T]) Enqueue(value T)
Enqueue put 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
type PriorityQueue ¶ added in v2.0.6
type PriorityQueue[T any] struct { // contains filtered or unexported fields }
PriorityQueue is a priority queue implemented by binary heap tree type T should implements Compare function in lancetconstraints.Comparator interface.
func NewPriorityQueue ¶ added in v2.0.6
func NewPriorityQueue[T any](capacity int, comparator lancetconstraints.Comparator) *PriorityQueue[T]
NewPriorityQueue return a pointer of PriorityQueue param `comparator` is used to compare values in the queue
func (*PriorityQueue[T]) Data ¶ added in v2.0.6
func (q *PriorityQueue[T]) Data() []T
Data return a slice of queue data
func (*PriorityQueue[T]) Dequeue ¶ added in v2.0.6
func (q *PriorityQueue[T]) Dequeue() (T, bool)
Dequeue delete and return max value in queue
func (*PriorityQueue[T]) Enqueue ¶ added in v2.0.6
func (q *PriorityQueue[T]) Enqueue(val T) error
Enqueue insert value into queue
func (*PriorityQueue[T]) IsEmpty ¶ added in v2.0.6
func (q *PriorityQueue[T]) IsEmpty() bool
IsEmpty checks if the queue is empty or not
func (*PriorityQueue[T]) IsFull ¶ added in v2.0.6
func (q *PriorityQueue[T]) IsFull() bool
IsFull checks if the queue capacity is full or not
func (*PriorityQueue[T]) Size ¶ added in v2.0.8
func (q *PriorityQueue[T]) Size() int
Size get number of items in the queue