Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrEmpty = errors.New("stack is empty")
ErrEmpty represents the error when trying to pop from an empty stack.
Functions ¶
This section is empty.
Types ¶
type Stack ¶
type Stack[T any] struct { // contains filtered or unexported fields }
Stack is a generic stack data structure that can store any type of value.
func (*Stack[T]) Clear ¶
func (s *Stack[T]) Clear()
Clear removes all elements from the stack, effectively resetting it.
func (*Stack[T]) Peek ¶
Peek returns the top element of the stack without removing it. If the stack is empty, it returns an error.
Click to show internal directories.
Click to hide internal directories.