Documentation ¶
Overview ¶
Package datastructure contains some data structure. Stack structure contains ArrayStack and LinkedStack.
Package datastructure contains some data structure. Stack structure contains ArrayStack and LinkedStack.
Index ¶
- type ArrayStack
- type LinkedStack
- func (s *LinkedStack[T]) Clear()
- func (s *LinkedStack[T]) Data() []T
- func (s *LinkedStack[T]) IsEmpty() bool
- func (s *LinkedStack[T]) Peak() (*T, error)
- func (s *LinkedStack[T]) Pop() (*T, error)
- func (s *LinkedStack[T]) Print()
- func (s *LinkedStack[T]) Push(value T)
- func (s *LinkedStack[T]) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayStack ¶
type ArrayStack[T any] struct { // contains filtered or unexported fields }
ArrayStack implements stack with slice
func NewArrayStack ¶
func NewArrayStack[T any]() *ArrayStack[T]
NewArrayStack return a empty ArrayStack pointer
func (*ArrayStack[T]) IsEmpty ¶
func (s *ArrayStack[T]) IsEmpty() bool
IsEmpty checks if stack is empty or not
func (*ArrayStack[T]) Peak ¶
func (s *ArrayStack[T]) Peak() (*T, error)
Peak return the top element of stack
func (*ArrayStack[T]) Pop ¶
func (s *ArrayStack[T]) Pop() (*T, error)
Pop delete the top element of stack then return it, if stack is empty, return nil and error
type LinkedStack ¶
type LinkedStack[T any] struct { // contains filtered or unexported fields }
LinkedStack implements stack with link list
func NewLinkedStack ¶
func NewLinkedStack[T any]() *LinkedStack[T]
NewLinkedStack return a empty LinkedStack pointer
func (*LinkedStack[T]) IsEmpty ¶
func (s *LinkedStack[T]) IsEmpty() bool
IsEmpty checks if stack is empty or not
func (*LinkedStack[T]) Peak ¶
func (s *LinkedStack[T]) Peak() (*T, error)
Peak return the top element of stack then return it
func (*LinkedStack[T]) Pop ¶
func (s *LinkedStack[T]) Pop() (*T, error)
Pop delete the top element of stack then return it, if stack is empty, return nil and error