Documentation ¶
Index ¶
- type EnumerableWithIndex
- type Iterator
- type Queue
- func (q *Queue[T]) All(f func(index int, value T) bool) bool
- func (q *Queue[T]) Any(f func(index int, value T) bool) bool
- func (q *Queue[T]) Clear()
- func (q *Queue[T]) Dequeue() (_ T, _ bool)
- func (q *Queue[T]) Each(f func(index int, value T))
- func (q *Queue[T]) Empty() bool
- func (q *Queue[T]) Enqueue(value T)
- func (q *Queue[T]) Filter(f func(index int, value T) bool) *Queue[T]
- func (q *Queue[T]) Find(f func(index int, value T) bool) (index int, value T)
- func (q *Queue[T]) FromJSON(data []byte) error
- func (q *Queue[T]) Full() bool
- func (q *Queue[T]) Iterator() *Iterator[T]
- func (q *Queue[T]) Peek() (_ T, _ bool)
- func (q *Queue[T]) Size() int
- func (q *Queue[T]) String() string
- func (q *Queue[T]) ToJSON() ([]byte, error)
- func (q *Queue[T]) Values() []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnumerableWithIndex ¶
type EnumerableWithIndex[T comparable] interface { // Filter returns a new container containing all elements for which the given function returns a true value. Filter(func(index int, value T) bool) *Queue[T] containers.EnumerableWithIndex[T] }
type Iterator ¶
type Iterator[T any] struct { // contains filtered or unexported fields }
Iterator is the structure used to iterate over a queue.
func (*Iterator[T]) Begin ¶
func (it *Iterator[T]) Begin()
Begin resets the iterator to its initial state.
func (*Iterator[T]) End ¶
func (it *Iterator[T]) End()
End moves the iterator past the last element of the collection.
func (*Iterator[T]) First ¶
If First() returns true, then first element's index and value can be retrieved by Index() and Value(). Modifies the state of the iterator.
func (*Iterator[T]) Last ¶
Last moves the iterator to the last element and returns true if there was a last element in the container. If Last() returns true, then last element's index and value can be retrieved by Index() and Value(). Modifies the state of the iterator.
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
Queue holds the value of sice. Circular queue: The queue is implemented as a ring buffer. The size of the queue is fixed. The queue is full when the end is equal to the start. The queue is empty when the end is equal to the start and the queue is not full. see: https://en.wikipedia.org/wiki/Circular_buffer
func Map ¶
Map invokes the given function once for each element and returns a container containing the values returned by the given function.
func (*Queue[T]) All ¶
All passes each element of the container to the given function and returns true if the function returns true for all elements.
func (*Queue[T]) Any ¶
Any passes each element of the container to the given function and returns true if the function ever returns true for any element.
func (*Queue[T]) Each ¶
Each calls the given function once for each element, passing that element's index and value.
func (*Queue[T]) Enqueue ¶
func (q *Queue[T]) Enqueue(value T)
Enqueue adds a new value to the queue. if the queue is full, it will remove the first element in the front of the queue.
func (*Queue[T]) Filter ¶
Filter returns a new container containing all elements for which the given function returns a true value.
func (*Queue[T]) Find ¶
Find returns the first element of the container for which the given function returns a true value.
func (*Queue[T]) Iterator ¶
Iterator returns a stateful iterator whose elements are key/value pairs.