Documentation
¶
Index ¶
- type Option
- type Queue
- func New[E any](cmp func(E, E) int, ops ...Option[E]) (*Queue[E], error)
- func NewFromMapKeys[K comparable, V any](cmp func(K, K) int, m map[K]V, ops ...Option[K]) (*Queue[K], error)
- func NewFromMapValues[K comparable, V any](cmp func(V, V) int, m map[K]V, ops ...Option[V]) (*Queue[V], error)
- func NewFromSlice[E any](cmp func(E, E) int, slice []E, ops ...Option[E]) (*Queue[E], error)
- func (q *Queue[E]) Clear()
- func (q *Queue[E]) Clone() *Queue[E]
- func (q *Queue[E]) Dequeue() (E, bool)
- func (q *Queue[E]) Enqueue(e E)
- func (q *Queue[E]) IsEmpty() bool
- func (q *Queue[E]) Len() int
- func (q *Queue[E]) MarshalJSON() ([]byte, error)
- func (q *Queue[E]) Peek() (E, bool)
- func (q *Queue[E]) String() string
- func (q *Queue[E]) UnmarshalJSON(data []byte) error
- func (q *Queue[E]) Values() []E
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Queue ¶
type Queue[E any] struct { // contains filtered or unexported fields }
Queue represents a queue based on an array-backed list. This queue implements the FIFO (first-in, first-out) behavior.
func New ¶
New creates and initializes a empty queue. The "cmp" function is used to compare elements for equality. Options can be provided to customize the queue's properties (e.g., thread safety).
func NewFromMapKeys ¶
func NewFromMapKeys[K comparable, V any](cmp func(K, K) int, m map[K]V, ops ...Option[K]) (*Queue[K], error)
NewFromMapKeys creates and initializes a queue from the provided map keys. The "cmp" function is used to compare elements for equality. Options can be provided to customize the queue's properties (e.g., thread safety).
func NewFromMapValues ¶
func NewFromMapValues[K comparable, V any](cmp func(V, V) int, m map[K]V, ops ...Option[V]) (*Queue[V], error)
NewFromMapValues creates and initializes a queue from the provided map values. The "cmp" function is used to compare elements for equality. Options can be provided to customize the queue's properties (e.g., thread safety).
func NewFromSlice ¶
NewFromSlice creates and initializes a queue from the provided slice. The "cmp" function is used to compare elements for equality. Options can be provided to customize the queue's properties (e.g., thread safety).
func (*Queue[E]) Dequeue ¶
Dequeue removes first element of the queue. Returns zero value of element and false if queue is empty.
func (*Queue[E]) Enqueue ¶
func (q *Queue[E]) Enqueue(e E)
Enqueue adds a element to the end of the queue.
func (*Queue[E]) MarshalJSON ¶
MarshalJSON will marshal the queue into a JSON-based representation.
func (*Queue[E]) Peek ¶
Peek returns first element of the queue without remove it. Returns zero value of element and false if queue is empty.
func (*Queue[E]) UnmarshalJSON ¶
UnmarshalJSON will unmarshal a JSON-based representation byte slice into the queue.