package containers
import "git.mstar.dev/mstar/goutils/containers"
Package containers contains implementations of a generic queue and stack
Index ¶
- Variables
- type Queue
- func BuildQueue[T any]() *Queue[T]
- func (q *Queue[T]) IsEmpty() bool
- func (q *Queue[T]) Pop() (*T, error)
- func (q *Queue[T]) Push(elem *T) error
- func (q *Queue[T]) Top() (*T, error)
- type Stack
Variables ¶
Types ¶
type Queue ¶
type Queue[T any] struct { // contains filtered or unexported fields }
func BuildQueue ¶
func (*Queue[T]) IsEmpty ¶
IsEmpty checks if the queue is empty.
func (*Queue[T]) Pop ¶
Pop removes the first element of the queue. It errors out if there is no element or the queue is invalid.
func (*Queue[T]) Push ¶
Push adds a new element to the end of the queue.
func (*Queue[T]) Top ¶
Top returns the first element of the queue without removing it. It errors out if there is no element or the queue is invalid.
type Stack ¶
type Stack[T any] struct { // contains filtered or unexported fields }
func BuildStack ¶
func (*Stack[T]) IsEmpty ¶
IsEmpty checks if the stack is currently empty.
func (*Stack[T]) Pop ¶
Pop removes the first element at the top of the stack and returns it. It errors out if the stack is invalid or empty.
func (*Stack[T]) Push ¶
Push adds a new element to the top of the stack. It errors out if the stack is invalid.
func (*Stack[T]) Top ¶
Top returns the first element at the top of the stack without removing it. It errors out if the stack is empty or invalid.
Source Files ¶
generics.go queues.go stacks.go
- Version
- v1.15.0 (latest)
- Published
- Jun 6, 2025
- Platform
- linux/amd64
- Imports
- 1 packages
- Last checked
- 1 hour ago –
Tools for package owners.