Documentation
¶
Index ¶
- type Queue
- func (this *Queue[T]) Dequeue() T
- func (this *Queue[T]) Enqueue(items ...T) int
- func (this *Queue[T]) Every(callback func(index int, value T) bool) bool
- func (this *Queue[T]) Filter(callback func(index int, value T) bool) *Queue[T]
- func (this *Queue[T]) Find(callback func(index int, value T) bool) T
- func (this *Queue[T]) FindIndex(callback func(index int, value T) bool) int
- func (this *Queue[T]) ForEach(callback func(index int, value T) error) *Queue[T]
- func (this *Queue[T]) Get(index int) T
- func (this *Queue[T]) Includes(item T) bool
- func (this *Queue[T]) IndexOf(item T) int
- func (this *Queue[T]) Join(sep string) string
- func (this *Queue[T]) LastIndexOf(item T) int
- func (this *Queue[T]) Map(callback func(index int, value T) T) *Queue[T]
- func (this *Queue[T]) Set(index int, value T)
- func (this *Queue[T]) Size() int
- func (this *Queue[T]) Slice(start, end int) *Queue[T]
- func (this *Queue[T]) Some(callback func(index int, value T) bool) bool
- func (this *Queue[T]) Splice(start, count int, items ...T) *Queue[T]
- func (this *Queue[T]) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Queue ¶
func (*Queue[T]) Dequeue ¶
func (this *Queue[T]) Dequeue() T
Dequeue: Remove an element from the start of the Queue, and return it.
func (*Queue[T]) Every ¶
Every: Takes in a callback function that acts as an evaluator for each element. Returns a boolean. Returns `true` if all the callback on all elements returns true. Returns `false` on encountering an element that the callback evaluates as false. Stops and exits method.
func (*Queue[T]) Filter ¶
Filter: Takes in a Filter function that evaluates whether true or false on each item of the stack. Returns a new Queue of filtered items.
func (*Queue[T]) Find ¶
Find: Takes in a callback function that acts as an evaluator for each element. Returns the item if the callback function evaluates to true, zero-value of the Type otherwise
func (*Queue[T]) FindIndex ¶
FindIndex: Takes in a callback function that acts as an evaluator for each element. Returns the index (position) of the first element that evaluates to true. Returns -1 if no element passes evaluation.
func (*Queue[T]) ForEach ¶
ForEach: Takes in a Callback function to run for each element in the Queue. Returns nil always.
func (*Queue[T]) Includes ¶
Includes: Find whether the Queue contains an item. Returns true if found, false if not found
func (*Queue[T]) IndexOf ¶
IndexOf: Returns the index of the first matching item in the Queue. If not found returns -1
func (*Queue[T]) Join ¶
Join: Takes in a Separator string, joins the elements of the stack into a single string and returns it
func (*Queue[T]) LastIndexOf ¶
LastIndexOf: Returns the index of the last matching item in the Queue. If not found returns -1
func (*Queue[T]) Map ¶
Map: Modifies the elements of the stack with a mapping function that applies to each element. Returns a pointer to a new Slice.
func (*Queue[T]) Some ¶
Some: Takes in a callback function that acts as an evaluator for each element. Returns a boolean. Returns `true` on encountering an element that the callback evaluates as true. Stops and exits method. Returns `false` if the callback returns false on all the elements.
func (*Queue[T]) Splice ¶
Splice: Mutates original Queue by removing elements starting at index. Takes three parameters total. Two parameters: `start` and `count` mutates the original Queue by removing items from a start index upto `count` number of items. The third is an optional variadic parameters that takes items of the same type as the Queue that it will be inserted at the index of removal. Returns the removed items as a new Queue