New Shared Library

This commit is contained in:
2021-12-16 21:11:39 +00:00
parent 1a2247044a
commit 6111f86a04
24 changed files with 559 additions and 392 deletions
+33
View File
@@ -0,0 +1,33 @@
package shared
type Stack struct {
head *Node
}
func (s *Stack) Push(item string) {
if s.head == nil {
s.head = &Node{
Value: item,
Next: nil,
}
} else {
s.head = &Node{
Value: item,
Next: s.head,
}
}
}
func (s *Stack) Pop() string {
node := s.Peek()
s.head = node.Next
return node.Value
}
func (s *Stack) Peek() (node *Node) {
node = s.head
if node == nil {
node = &Node{}
}
return
}