Simple Generic Stack implementation in Go using linked list.
The repository is archived because the feature is fully implemented.
go get github.com/sv-tools/gstacks := gstack.New(1, 2, 3, 4)
fmt.Println(s.Len())
fmt.Println(s.Pop())
fmt.Println(s.Pop())
fmt.Println(s.Pop())
fmt.Println(s.Pop())
s.Push(5)
fmt.Println(s.Peek())
// Output: 4
// 4
// 3
// 2
// 1
// 5- minimal supported version of Go is 1.20
- initial implementation
- minimal supported version of Go is 1.23
- added
Itermethod to iterate over the stack and consume all items
s := gstack.New(1, 2, 3, 4)
for v := range s.Iter() {
fmt.Println(v)
}
fmt.Println("len:", s.Len())
// Output: 4
// 3
// 2
// 1
// len: 0- added
IsEmptymethod to check if the stack is empty