Documentation ¶
Index ¶
- type ArrayQueue
- func (queue *ArrayQueue[T]) Capacity() int
- func (queue *ArrayQueue[T]) Clear()
- func (queue *ArrayQueue[T]) Copy() uc.Copier
- func (queue *ArrayQueue[T]) CutNilValues()
- func (queue *ArrayQueue[T]) Dequeue() (T, error)
- func (queue *ArrayQueue[T]) Enqueue(value T) error
- func (queue *ArrayQueue[T]) GoString() string
- func (queue *ArrayQueue[T]) IsEmpty() bool
- func (queue *ArrayQueue[T]) IsFull() bool
- func (queue *ArrayQueue[T]) Iterator() itf.Iterater[T]
- func (queue *ArrayQueue[T]) Peek() (T, error)
- func (queue *ArrayQueue[T]) Size() int
- func (queue *ArrayQueue[T]) Slice() []T
- type ErrFullQueue
- type IsEmptyObserver
- type LimitedArrayQueue
- func (queue *LimitedArrayQueue[T]) Capacity() int
- func (queue *LimitedArrayQueue[T]) Clear()
- func (queue *LimitedArrayQueue[T]) Copy() uc.Copier
- func (queue *LimitedArrayQueue[T]) CutNilValues()
- func (queue *LimitedArrayQueue[T]) Dequeue() (T, error)
- func (queue *LimitedArrayQueue[T]) Enqueue(value T) error
- func (queue *LimitedArrayQueue[T]) GoString() string
- func (queue *LimitedArrayQueue[T]) IsEmpty() bool
- func (queue *LimitedArrayQueue[T]) IsFull() bool
- func (queue *LimitedArrayQueue[T]) Iterator() itf.Iterater[T]
- func (queue *LimitedArrayQueue[T]) Peek() (T, error)
- func (queue *LimitedArrayQueue[T]) Size() int
- func (queue *LimitedArrayQueue[T]) Slice() []T
- type LimitedLinkedQueue
- func (queue *LimitedLinkedQueue[T]) Capacity() int
- func (queue *LimitedLinkedQueue[T]) Clear()
- func (queue *LimitedLinkedQueue[T]) Copy() uc.Copier
- func (queue *LimitedLinkedQueue[T]) CutNilValues()
- func (queue *LimitedLinkedQueue[T]) Dequeue() (T, error)
- func (queue *LimitedLinkedQueue[T]) Enqueue(value T) error
- func (queue *LimitedLinkedQueue[T]) GoString() string
- func (queue *LimitedLinkedQueue[T]) IsEmpty() bool
- func (queue *LimitedLinkedQueue[T]) IsFull() bool
- func (queue *LimitedLinkedQueue[T]) Iterator() itf.Iterater[T]
- func (queue *LimitedLinkedQueue[T]) Peek() (T, error)
- func (queue *LimitedLinkedQueue[T]) Size() int
- func (queue *LimitedLinkedQueue[T]) Slice() []T
- type LimitedSafeQueue
- func (queue *LimitedSafeQueue[T]) Capacity() int
- func (queue *LimitedSafeQueue[T]) Clear()
- func (queue *LimitedSafeQueue[T]) Copy() uc.Copier
- func (queue *LimitedSafeQueue[T]) CutNilValues()
- func (queue *LimitedSafeQueue[T]) Dequeue() (T, error)
- func (queue *LimitedSafeQueue[T]) Enqueue(value T) error
- func (queue *LimitedSafeQueue[T]) GoString() string
- func (queue *LimitedSafeQueue[T]) IsEmpty() bool
- func (queue *LimitedSafeQueue[T]) IsFull() (isFull bool)
- func (queue *LimitedSafeQueue[T]) Iterator() itf.Iterater[T]
- func (queue *LimitedSafeQueue[T]) Peek() (T, error)
- func (queue *LimitedSafeQueue[T]) Size() int
- func (queue *LimitedSafeQueue[T]) Slice() []T
- type LinkedQueue
- func (queue *LinkedQueue[T]) Capacity() int
- func (queue *LinkedQueue[T]) Clear()
- func (queue *LinkedQueue[T]) Copy() uc.Copier
- func (queue *LinkedQueue[T]) CutNilValues()
- func (queue *LinkedQueue[T]) Dequeue() (T, error)
- func (queue *LinkedQueue[T]) Enqueue(value T) error
- func (queue *LinkedQueue[T]) GoString() string
- func (queue *LinkedQueue[T]) IsEmpty() bool
- func (queue *LinkedQueue[T]) IsFull() bool
- func (queue *LinkedQueue[T]) Iterator() itf.Iterater[T]
- func (queue *LinkedQueue[T]) Peek() (T, error)
- func (queue *LinkedQueue[T]) Size() int
- func (queue *LinkedQueue[T]) Slice() []T
- type QueueNode
- type QueueSafeNode
- type Queuer
- type SafeQueue
- func (queue *SafeQueue[T]) Capacity() int
- func (queue *SafeQueue[T]) Clear()
- func (queue *SafeQueue[T]) Copy() uc.Copier
- func (queue *SafeQueue[T]) CutNilValues()
- func (queue *SafeQueue[T]) Dequeue() (T, error)
- func (queue *SafeQueue[T]) Enqueue(value T) error
- func (queue *SafeQueue[T]) GoString() string
- func (queue *SafeQueue[T]) IsEmpty() bool
- func (queue *SafeQueue[T]) IsFull() bool
- func (queue *SafeQueue[T]) Iterator() itf.Iterater[T]
- func (queue *SafeQueue[T]) ObserveSize(action func(int))
- func (queue *SafeQueue[T]) Peek() (T, error)
- func (queue *SafeQueue[T]) Size() int
- func (queue *SafeQueue[T]) Slice() []T
- type SafeQueuer
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 is a generic type that represents a queue data structure with or without a limited capacity. It is implemented using an array.
func NewArrayQueue ¶
func NewArrayQueue[T any](values ...T) *ArrayQueue[T]
NewArrayQueue is a function that creates and returns a new instance of a ArrayQueue.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the queue.
Returns:
- *ArrayQueue[T]: A pointer to the newly created ArrayQueue.
func (*ArrayQueue[T]) Capacity ¶
func (queue *ArrayQueue[T]) Capacity() int
Capacity is a method of the ArrayQueue type. It is used to return the capacity of the queue.
Returns:
- int: The capacity of the queue, which is always -1 for an ArrayQueue.
func (*ArrayQueue[T]) Clear ¶
func (queue *ArrayQueue[T]) Clear()
Clear is a method of the ArrayQueue type. It is used to remove aCommon the elements from the queue, making it empty.
func (*ArrayQueue[T]) Copy ¶
func (queue *ArrayQueue[T]) Copy() uc.Copier
Copy is a method of the ArrayQueue type. It is used to create a shaCommonow copy of the queue.
Returns:
- itf.Copier: A copy of the queue.
func (*ArrayQueue[T]) CutNilValues ¶
func (queue *ArrayQueue[T]) CutNilValues()
CutNilValues is a method of the ArrayQueue type. It is used to remove aCommon nil values from the queue.
func (*ArrayQueue[T]) Dequeue ¶
func (queue *ArrayQueue[T]) Dequeue() (T, error)
Dequeue is a method of the ArrayQueue type. It is used to remove and return the element at the front of the queue.
Panics with an error of type *ErrEmptyList if the queue is empty.
Returns:
- T: The element at the front of the queue.
func (*ArrayQueue[T]) Enqueue ¶
func (queue *ArrayQueue[T]) Enqueue(value T) error
Enqueue is a method of the ArrayQueue type. It is used to add an element to the end of the queue.
Panics with an error of type *ErrCaCommonFailed if the queue is fuCommon.
Parameters:
- value: The value of type T to be added to the queue.
func (*ArrayQueue[T]) GoString ¶ added in v0.3.8
func (queue *ArrayQueue[T]) GoString() string
GoString implements the fmt.GoStringer interface.
func (*ArrayQueue[T]) IsEmpty ¶
func (queue *ArrayQueue[T]) IsEmpty() bool
IsEmpty is a method of the ArrayQueue type. It is used to check if the queue is empty.
Returns:
- bool: A boolean value that is true if the queue is empty, and false otherwise.
func (*ArrayQueue[T]) IsFull ¶
func (queue *ArrayQueue[T]) IsFull() bool
IsFull is a method of the ArrayQueue type. It is used to check if the queue is full.
Returns:
- bool: A boolean value that is always false for an ArrayQueue.
func (*ArrayQueue[T]) Iterator ¶
func (queue *ArrayQueue[T]) Iterator() itf.Iterater[T]
Iterator is a method of the ArrayQueue type. It is used to return an iterator that can be used to iterate over the elements in the queue.
Returns:
- itf.Iterater[T]: An iterator that can be used to iterate over the elements in the queue.
func (*ArrayQueue[T]) Peek ¶
func (queue *ArrayQueue[T]) Peek() (T, error)
Peek is a method of the ArrayQueue type. It is used to return the element at the front of the queue without removing it.
Panics with an error of type *ErrEmptyList if the queue is empty.
Returns:
- T: The element at the front of the queue.
func (*ArrayQueue[T]) Size ¶
func (queue *ArrayQueue[T]) Size() int
Size is a method of the ArrayQueue type. It is used to return the number of elements in the queue.
Returns:
- int: An integer that represents the number of elements in the queue.
func (*ArrayQueue[T]) Slice ¶
func (queue *ArrayQueue[T]) Slice() []T
Slice is a method of the ArrayQueue type. It is used to return a slice of the elements in the queue.
Returns:
- []T: A slice of the elements in the queue.
type ErrFullQueue ¶
ErrFullQueue is an error type for a full queue.
func NewErrFullQueue ¶ added in v0.2.43
func NewErrFullQueue[T any](queue Queuer[T]) *ErrFullQueue[T]
NewErrFullQueue is a constructor for ErrFullQueue.
Parameters:
- queue: The queue that is full.
Returns:
- *ErrFullQueue: The error.
func (*ErrFullQueue[T]) Error ¶
func (e *ErrFullQueue[T]) Error() string
Error returns the error message: "queue (%T) is full".
Returns:
- string: The error message.
Behaviors:
- If the queue is nil, the error message is "queue is full".
type IsEmptyObserver ¶ added in v0.3.18
type IsEmptyObserver struct {
// contains filtered or unexported fields
}
func NewIsEmptyObserver ¶ added in v0.3.18
func NewIsEmptyObserver(action func(int)) *IsEmptyObserver
func (*IsEmptyObserver) Notify ¶ added in v0.3.18
func (o *IsEmptyObserver) Notify(size int)
type LimitedArrayQueue ¶
type LimitedArrayQueue[T any] struct { // contains filtered or unexported fields }
LimitedArrayQueue is a generic type that represents a queue data structure with or without a limited capacity. It is implemented using an array.
func NewLimitedArrayQueue ¶
func NewLimitedArrayQueue[T any](values ...T) *LimitedArrayQueue[T]
NewLimitedArrayQueue is a function that creates and returns a new instance of a LimitedArrayQueue.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the queue.
Returns:
- *LimitedArrayQueue[T]: A pointer to the newly created LimitedArrayQueue.
func (*LimitedArrayQueue[T]) Capacity ¶
func (queue *LimitedArrayQueue[T]) Capacity() int
Capacity is a method of the LimitedArrayQueue type. It is used to return the maximum number of elements the queue can hold.
Returns:
- optional.Int: An optional integer that represents the maximum number of elements the queue can hold.
func (*LimitedArrayQueue[T]) Clear ¶
func (queue *LimitedArrayQueue[T]) Clear()
Clear is a method of the LimitedArrayQueue type. It is used to remove all the elements from the queue, making it empty.
func (*LimitedArrayQueue[T]) Copy ¶
func (queue *LimitedArrayQueue[T]) Copy() uc.Copier
Copy is a method of the LimitedArrayQueue type. It is used to create a shallow copy of the queue.
Returns:
- itf.Copier: A copy of the queue.
func (*LimitedArrayQueue[T]) CutNilValues ¶
func (queue *LimitedArrayQueue[T]) CutNilValues()
CutNilValues is a method of the LimitedArrayQueue type. It is used to remove all nil values from the queue.
func (*LimitedArrayQueue[T]) Dequeue ¶
func (queue *LimitedArrayQueue[T]) Dequeue() (T, error)
Dequeue is a method of the LimitedArrayQueue type. It is used to remove and return the element at the front of the queue.
Panics with an error of type *ErrCallFailed if the queue is empty.
Returns:
- T: The element at the front of the queue.
func (*LimitedArrayQueue[T]) Enqueue ¶
func (queue *LimitedArrayQueue[T]) Enqueue(value T) error
Enqueue is a method of the LimitedArrayQueue type. It is used to add an element to the end of the queue.
Panics with an error of type *ErrCallFailed if the queue is full.
Parameters:
- value: The value of type T to be added to the queue.
func (*LimitedArrayQueue[T]) GoString ¶ added in v0.3.8
func (queue *LimitedArrayQueue[T]) GoString() string
GoString implements the fmt.GoStringer interface.
func (*LimitedArrayQueue[T]) IsEmpty ¶
func (queue *LimitedArrayQueue[T]) IsEmpty() bool
IsEmpty is a method of the LimitedArrayQueue type. It is used to check if the queue is empty.
Returns:
- bool: A boolean value that is true if the queue is empty, and false otherwise.
func (*LimitedArrayQueue[T]) IsFull ¶
func (queue *LimitedArrayQueue[T]) IsFull() bool
IsFull is a method of the LimitedArrayQueue type. It is used to check if the queue is full.
Returns:
- isFull: A boolean value that is true if the queue is full, and false otherwise.
func (*LimitedArrayQueue[T]) Iterator ¶
func (queue *LimitedArrayQueue[T]) Iterator() itf.Iterater[T]
Iterator is a method of the LimitedArrayQueue type. It is used to return an iterator that can be used to iterate over the elements in the queue.
Returns:
- itf.Iterater[T]: An iterator that can be used to iterate over the elements in the queue.
func (*LimitedArrayQueue[T]) Peek ¶
func (queue *LimitedArrayQueue[T]) Peek() (T, error)
Peek is a method of the LimitedArrayQueue type. It is used to return the element at the front of the queue without removing it.
Panics with an error of type *ErrCallFailed if the queue is empty.
Returns:
- T: The element at the front of the queue.
func (*LimitedArrayQueue[T]) Size ¶
func (queue *LimitedArrayQueue[T]) Size() int
Size is a method of the LimitedArrayQueue type. It is used to return the number of elements in the queue.
Returns:
- int: An integer that represents the number of elements in the queue.
func (*LimitedArrayQueue[T]) Slice ¶
func (queue *LimitedArrayQueue[T]) Slice() []T
Slice is a method of the LimitedArrayQueue type. It is used to return a slice of the elements in the queue.
Returns:
- []T: A slice of the elements in the queue.
type LimitedLinkedQueue ¶
type LimitedLinkedQueue[T any] struct { // contains filtered or unexported fields }
LimitedLinkedQueue is a generic type that represents a queue data structure with or without a limited capacity, implemented using a linked list.
func NewLimitedLinkedQueue ¶
func NewLimitedLinkedQueue[T any](values ...T) *LimitedLinkedQueue[T]
NewLimitedLinkedQueue is a function that creates and returns a new instance of a LimitedLinkedQueue.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the queue.
Returns:
- *LimitedLinkedQueue[T]: A pointer to the newly created LimitedLinkedQueue.
func (*LimitedLinkedQueue[T]) Capacity ¶
func (queue *LimitedLinkedQueue[T]) Capacity() int
func (*LimitedLinkedQueue[T]) Clear ¶
func (queue *LimitedLinkedQueue[T]) Clear()
Clear is a method of the LimitedLinkedQueue type. It is used to remove all elements from the queue.
func (*LimitedLinkedQueue[T]) Copy ¶
func (queue *LimitedLinkedQueue[T]) Copy() uc.Copier
Copy is a method of the LimitedLinkedQueue type. It is used to create a shallow copy of the queue.
Returns:
- itf.Copier: A copy of the queue.
func (*LimitedLinkedQueue[T]) CutNilValues ¶
func (queue *LimitedLinkedQueue[T]) CutNilValues()
CutNilValues is a method of the LimitedLinkedQueue type. It is used to remove all nil values from the queue.
func (*LimitedLinkedQueue[T]) Dequeue ¶
func (queue *LimitedLinkedQueue[T]) Dequeue() (T, error)
Dequeue is a method of the LimitedLinkedQueue type. It is used to remove and return the element at the front of the queue.
Panics with an error of type *ErrCallFailed if the queue is empty.
Returns:
- T: The value of the element at the front of the queue.
func (*LimitedLinkedQueue[T]) Enqueue ¶
func (queue *LimitedLinkedQueue[T]) Enqueue(value T) error
Enqueue is a method of the LimitedLinkedQueue type. It is used to add an element to the end of the queue.
Panics with an error of type *ErrCallFailed if the queue is full.
Parameters:
- value: A pointer to a value of type T, which is the element to be added to the queue.
func (*LimitedLinkedQueue[T]) GoString ¶ added in v0.3.8
func (queue *LimitedLinkedQueue[T]) GoString() string
GoString implements the fmt.GoStringer interface.
func (*LimitedLinkedQueue[T]) IsEmpty ¶
func (queue *LimitedLinkedQueue[T]) IsEmpty() bool
IsEmpty is a method of the LimitedLinkedQueue type. It is used to check if the queue is empty.
Returns:
- bool: A boolean value indicating whether the queue is empty.
func (*LimitedLinkedQueue[T]) IsFull ¶
func (queue *LimitedLinkedQueue[T]) IsFull() bool
IsFull is a method of the LimitedLinkedQueue type. It is used to check if the queue is full.
Returns:
- isFull: A boolean value indicating whether the queue is full.
func (*LimitedLinkedQueue[T]) Iterator ¶
func (queue *LimitedLinkedQueue[T]) Iterator() itf.Iterater[T]
Iterator is a method of the LimitedLinkedQueue type. It is used to return an iterator for the queue.
Returns:
- itf.Iterater[T]: An iterator for the queue.
func (*LimitedLinkedQueue[T]) Peek ¶
func (queue *LimitedLinkedQueue[T]) Peek() (T, error)
Peek is a method of the LimitedLinkedQueue type. It is used to return the element at the front of the queue without removing it.
Panics with an error of type *ErrCallFailed if the queue is empty.
Returns:
- T: The value of the element at the front of the queue.
func (*LimitedLinkedQueue[T]) Size ¶
func (queue *LimitedLinkedQueue[T]) Size() int
Size is a method of the LimitedLinkedQueue type. It is used to return the current number of elements in the queue.
Returns:
- int: An integer representing the current number of elements in the queue.
func (*LimitedLinkedQueue[T]) Slice ¶
func (queue *LimitedLinkedQueue[T]) Slice() []T
Slice is a method of the LimitedLinkedQueue type. It is used to return a slice of the elements in the queue.
Returns:
- []T: A slice of the elements in the queue.
type LimitedSafeQueue ¶
type LimitedSafeQueue[T any] struct { // contains filtered or unexported fields }
LimitedSafeQueue is a generic type that represents a thread-safe queue data structure with or without a limited capacity, implemented using a linked list.
func NewLimitedSafeQueue ¶
func NewLimitedSafeQueue[T any](values ...T) *LimitedSafeQueue[T]
NewLimitedSafeQueue is a function that creates and returns a new instance of a LimitedSafeQueue.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the queue.
Return:
- *LimitedSafeQueue[T]: A pointer to the newly created LimitedSafeQueue.
func (*LimitedSafeQueue[T]) Capacity ¶
func (queue *LimitedSafeQueue[T]) Capacity() int
Capacity is a method of the LimitedSafeQueue type. It is used to return the maximum number of elements the queue can hold.
Returns:
- optional.Int: An optional integer that represents the maximum number of elements the queue can hold.
func (*LimitedSafeQueue[T]) Clear ¶
func (queue *LimitedSafeQueue[T]) Clear()
Clear is a method of the LimitedSafeQueue type. It is used to remove all elements from the queue, making it empty.
func (*LimitedSafeQueue[T]) Copy ¶
func (queue *LimitedSafeQueue[T]) Copy() uc.Copier
Copy is a method of the LimitedSafeQueue type. It is used to create a shallow copy of the queue.
Returns:
- itf.Copier: A copy of the queue.
func (*LimitedSafeQueue[T]) CutNilValues ¶
func (queue *LimitedSafeQueue[T]) CutNilValues()
CutNilValues is a method of the LimitedSafeQueue type. It is used to remove all nil values from the queue.
func (*LimitedSafeQueue[T]) Dequeue ¶
func (queue *LimitedSafeQueue[T]) Dequeue() (T, error)
Dequeue is a method of the LimitedSafeQueue type. It is used to remove and return the element at the front of the queue.
Panics with an error of type *ErrCallFailed if the queue is empty.
Returns:
- T: The value of the element at the front of the queue.
func (*LimitedSafeQueue[T]) Enqueue ¶
func (queue *LimitedSafeQueue[T]) Enqueue(value T) error
Enqueue is a method of the LimitedSafeQueue type. It is used to add an element to the back of the queue.
Panics with an error of type *ErrCallFailed if the queue is fu
Parameters:
- value: The value of type T to be added to the queue.
func (*LimitedSafeQueue[T]) GoString ¶ added in v0.3.8
func (queue *LimitedSafeQueue[T]) GoString() string
GoString implements the fmt.GoStringer interface.
func (*LimitedSafeQueue[T]) IsEmpty ¶
func (queue *LimitedSafeQueue[T]) IsEmpty() bool
IsEmpty is a method of the LimitedSafeQueue type. It is used to check if the queue is empty.
Returns:
- bool: A boolean value that is true if the queue is empty, and false otherwise.
func (*LimitedSafeQueue[T]) IsFull ¶
func (queue *LimitedSafeQueue[T]) IsFull() (isFull bool)
IsFull is a method of the LimitedSafeQueue type. It is used to check if the queue is full, meaning it has reached its maximum capacity and cannot accept any more elements.
Returns:
- isFull: A boolean value that is true if the queue is full, and false otherwise.
func (*LimitedSafeQueue[T]) Iterator ¶
func (queue *LimitedSafeQueue[T]) Iterator() itf.Iterater[T]
Iterator is a method of the LimitedSafeQueue type. It is used to return an iterator that can be used to iterate over the elements in the queue. However, the iterator does not share the queue's thread-safety.
Returns:
- itf.Iterater[T]: An iterator that can be used to iterate over the elements in the queue.
func (*LimitedSafeQueue[T]) Peek ¶
func (queue *LimitedSafeQueue[T]) Peek() (T, error)
Peek is a method of the LimitedSafeQueue type. It is used to return the element at the front of the queue without removing it.
Panics with an error of type *ErrCallFailed if the queue is empty.
Returns:
- T: The value of the element at the front of the queue.
func (*LimitedSafeQueue[T]) Size ¶
func (queue *LimitedSafeQueue[T]) Size() int
Size is a method of the LimitedSafeQueue type. It is used to return the number of elements in the queue.
Returns:
- int: An integer that represents the number of elements in the queue.
func (*LimitedSafeQueue[T]) Slice ¶
func (queue *LimitedSafeQueue[T]) Slice() []T
Slice is a method of the LimitedSafeQueue type. It is used to return a slice of the elements in the queue.
Returns:
- []T: A slice of the elements in the queue.
type LinkedQueue ¶
type LinkedQueue[T any] struct { // contains filtered or unexported fields }
LinkedQueue is a generic type that represents a queue data structure with or without a limited capacity, implemented using a linked list.
func NewLinkedQueue ¶
func NewLinkedQueue[T any](values ...T) *LinkedQueue[T]
NewLinkedQueue is a function that creates and returns a new instance of a LinkedQueue.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the queue.
Returns:
- *LinkedQueue[T]: A pointer to the newly created LinkedQueue.
func (*LinkedQueue[T]) Capacity ¶
func (queue *LinkedQueue[T]) Capacity() int
Capacity is a method of the LinkedQueue type. It is used to return the maximum number of elements that the queue can store.
Returns:
- int: -1
func (*LinkedQueue[T]) Clear ¶
func (queue *LinkedQueue[T]) Clear()
Clear is a method of the LinkedQueue type. It is used to remove aCommon elements from the queue.
func (*LinkedQueue[T]) Copy ¶
func (queue *LinkedQueue[T]) Copy() uc.Copier
Copy is a method of the LinkedQueue type. It is used to create a shaCommonow copy of the queue.
Returns:
- itf.Copier: A copy of the queue.
func (*LinkedQueue[T]) CutNilValues ¶
func (queue *LinkedQueue[T]) CutNilValues()
CutNilValues is a method of the LinkedQueue type. It is used to remove aCommon nil values from the queue.
func (*LinkedQueue[T]) Dequeue ¶
func (queue *LinkedQueue[T]) Dequeue() (T, error)
Dequeue is a method of the LinkedQueue type. It is used to remove and return the element at the front of the queue.
Panics with an error of type *ErrEmptyList if the queue is empty.
Returns:
- T: The value of the element at the front of the queue.
func (*LinkedQueue[T]) Enqueue ¶
func (queue *LinkedQueue[T]) Enqueue(value T) error
Enqueue is a method of the LinkedQueue type. It is used to add an element to the end of the queue.
Panics with an error of type *ErrCaCommonFailed if the queue is fuCommon.
Parameters:
- value: A pointer to a value of type T, which is the element to be added to the queue.
func (*LinkedQueue[T]) GoString ¶ added in v0.3.8
func (queue *LinkedQueue[T]) GoString() string
GoString implements the fmt.GoStringer interface.
func (*LinkedQueue[T]) IsEmpty ¶
func (queue *LinkedQueue[T]) IsEmpty() bool
IsEmpty is a method of the LinkedQueue type. It is used to check if the queue is empty.
Returns:
- bool: A boolean value indicating whether the queue is empty.
func (*LinkedQueue[T]) IsFull ¶
func (queue *LinkedQueue[T]) IsFull() bool
IsFull is a method of the LinkedQueue type. It is used to check if the queue is full.
Returns:
- bool: false
func (*LinkedQueue[T]) Iterator ¶
func (queue *LinkedQueue[T]) Iterator() itf.Iterater[T]
Iterator is a method of the LinkedQueue type. It is used to return an iterator for the queue.
Returns:
- itf.Iterater[T]: An iterator for the queue.
func (*LinkedQueue[T]) Peek ¶
func (queue *LinkedQueue[T]) Peek() (T, error)
Peek is a method of the LinkedQueue type. It is used to return the element at the front of the queue without removing it.
Panics with an error of type *ErrEmptyList if the queue is empty.
Returns:
- T: The value of the element at the front of the queue.
func (*LinkedQueue[T]) Size ¶
func (queue *LinkedQueue[T]) Size() int
Size is a method of the LinkedQueue type. It is used to return the current number of elements in the queue.
Returns:
- int: An integer representing the current number of elements in the queue.
func (*LinkedQueue[T]) Slice ¶
func (queue *LinkedQueue[T]) Slice() []T
Slice is a method of the LinkedQueue type. It is used to return a slice of the elements in the queue.
Returns:
- []T: A slice of the elements in the queue.
type QueueNode ¶
type QueueNode[T any] struct { // Value is the value stored in the node. Value T // contains filtered or unexported fields }
QueueNode represents a node in a linked queue.
func NewQueueNode ¶
NewQueueNode creates a new QueueNode with the given value.
Parameters:
- value: The value to store in the node.
Returns:
- *QueueNode: A pointer to the new node.
type QueueSafeNode ¶
type QueueSafeNode[T any] struct { // Value is the Value stored in the node. Value T // contains filtered or unexported fields }
QueueSafeNode represents a node in a linked queue.
func NewQueueSafeNode ¶
func NewQueueSafeNode[T any](value T) *QueueSafeNode[T]
NewQueueSafeNode creates a new QueueSafeNode with the given value.
Parameters:
- value: The value to store in the node.
Returns:
- *QueueSafeNode: A pointer to the new node.
func (*QueueSafeNode[T]) Next ¶
func (node *QueueSafeNode[T]) Next() *QueueSafeNode[T]
Next returns the next node in the queue.
Returns:
- *QueueSafeNode: The next node in the queue.
func (*QueueSafeNode[T]) SetNext ¶
func (node *QueueSafeNode[T]) SetNext(next *QueueSafeNode[T])
SetNext sets the next node in the queue.
Parameters:
- next: The next node in the queue.
type Queuer ¶
type Queuer[T any] interface { // Enqueue is a method that adds a value of type T to the end of the queue. // If the queue is full, it will panic. // // Parameters: // // - value: The value of type T to add to the queue. Enqueue(value T) error // Dequeue is a method that dequeues an element from the queue and returns it. // If the queue is empty, it will panic. // // Returns: // // - T: The value of type T that was dequeued. Dequeue() (T, error) // Peek is a method that returns the value at the front of the queue without // removing it. // If the queue is empty, it will panic. // // Returns: // // - T: The value of type T at the front of the queue. Peek() (T, error) ListLike.ListLike[T] }
Queuer is an interface that defines methods for a queue data structure.
type SafeQueue ¶
type SafeQueue[T any] struct { // contains filtered or unexported fields }
SafeQueue is a generic type that represents a thread-safe queue data structure with or without a limited capacity, implemented using a linked list.
func NewSafeQueue ¶
NewSafeQueue is a function that creates and returns a new instance of a SafeQueue.
Parameters:
- values: A variadic parameter of type T, which represents the initial values to be stored in the queue.
Return:
- *SafeQueue[T]: A pointer to the newly created SafeQueue.
func (*SafeQueue[T]) Capacity ¶
Capacity is a method of the SafeQueue type. It is used to return the maximum number of elements that the queue can store.
Returns:
- int: -1
func (*SafeQueue[T]) Clear ¶
func (queue *SafeQueue[T]) Clear()
Clear is a method of the SafeQueue type. It is used to remove all elements from the queue, making it empty.
func (*SafeQueue[T]) Copy ¶
Copy is a method of the SafeQueue type. It is used to create a shallow copy of the queue.
Returns:
- itf.Copier: A copy of the queue.
Behaviors:
- Does not copy the observers.
func (*SafeQueue[T]) CutNilValues ¶
func (queue *SafeQueue[T]) CutNilValues()
CutNilValues is a method of the SafeQueue type. It is used to remove all nil values from the queue.
func (*SafeQueue[T]) Dequeue ¶
Dequeue is a method of the SafeQueue type. It is used to remove and return the element at the front of the queue.
Panics with an error of type *ErrCallFailed if the queue is empty.
Returns:
- T: The value of the element at the front of the queue.
func (*SafeQueue[T]) Enqueue ¶
Enqueue is a method of the SafeQueue type. It is used to add an element to the back of the queue.
Panics with an error of type *ErrCallFailed if the queue is fu
Parameters:
- value: The value of type T to be added to the queue.
func (*SafeQueue[T]) IsEmpty ¶
IsEmpty is a method of the SafeQueue type. It is used to check if the queue is empty.
Returns:
- bool: A boolean value that is true if the queue is empty, and false otherwise.
func (*SafeQueue[T]) IsFull ¶
IsFull is a method of the SafeQueue type. It is used to check if the queue is full.
Returns:
- bool: false
func (*SafeQueue[T]) Iterator ¶
Iterator is a method of the SafeQueue type. It is used to return an iterator that can be used to iterate over the elements in the queue. However, the iterator does not share the queue's thread-safety.
Returns:
- itf.Iterater[T]: An iterator that can be used to iterate over the elements in the queue.
func (*SafeQueue[T]) ObserveSize ¶ added in v0.3.18
SetIsEmptyObserver is a method of the SafeQueue type. It is used to set an observer that will be notified when the queue becomes empty or non-empty.
func (*SafeQueue[T]) Peek ¶
Peek is a method of the SafeQueue type. It is used to return the element at the front of the queue without removing it.
Panics with an error of type *ErrCallFailed if the queue is empty.
Returns:
- T: The value of the element at the front of the queue.
type SafeQueuer ¶
type SafeQueuer[T any] interface { // Enqueue is a method that adds a value of type T to the end of the queue. // If the queue is full, it will panic. // // Parameters: // // - value: The value of type T to add to the queue. Enqueue(value T) error // Dequeue is a method that dequeues an element from the queue and returns it. // If the queue is empty, it will panic. // // Returns: // // - T: The value of type T that was dequeued. Dequeue() (T, error) // Peek is a method that returns the value at the front of the queue without // removing it. // If the queue is empty, it will panic. // // Returns: // // - T: The value of type T at the front of the queue. Peek() (T, error) ListLike.ListLike[T] }
Queuer is an interface that defines methods for a queue data structure.