Skip to content

Latest commit

 

History

History
13 lines (10 loc) · 527 Bytes

File metadata and controls

13 lines (10 loc) · 527 Bytes

Stack

This package provides a generic stack data structure for Go, supporting any type.

Features

  • Generic: Works with any type (Stack[T any]).
  • Push: Add an element to the top of the stack.
  • Pop: Remove and return the top element (returns zero value and false if empty).
  • Peek: View the top element without removing it.
  • PeekNthElement: View the n-th element from the top without removing it.
  • IsEmpty: Check if the stack is empty.
  • Size: Get the number of elements in the stack.