package
Version:
v0.0.0-...-a4a72b7
Opens a new window with list of versions in this module.
Published: Dec 23, 2023
License: MIT
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
type Array[T any] struct {
}
NewStack creates and returns a new stack.
IsEmpty returns true if the stack is empty, false otherwise.
Size returns the number of elements in the stack.
func (s *Array[T]) Peek() T
Peek returns the top element of the stack without removing it.
func (s *Array[T]) Pop() T
Pop removes and returns the top element from the stack.
func (s *Array[T]) Push(value T)
Push adds an element to the top of the stack.
type Node struct {
Val any
Next *Node
}
Node structure
SList is our struct that point to stack with container/list.List library
Empty check our stack has value or not
Length return length of our stack
Peak is return last value that insert into our stack
Pop is return last value that insert into our stack
also it will remove it in our stack
Push add a value into our stack
Stack has jost top of node and with length
isEmpty to check our array is empty or not
len use to return length of our stack
peak return last input value
pop remove last item as first output
push add value to last index
show all value as an interface array
Source Files
¶
Click to show internal directories.
Click to hide internal directories.