Skip to content

tiny-go/stack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stack

GoDoc License Build Status Report Card GoCover

Simple Golang stack implemented through a linked list

Installation

go get -u github.com/tiny-go/stack

Usage

package main

import (
	"fmt"

	"github.com/tiny-go/stack"
)

func main() {
	var a, b, c = 1, 2, 3

	// init stack
	stk := new(stack.Stack[int])

	// push elements
	stk.Push(a)
	stk.Push(b)
	stk.Push(c)

	// get top element
	fmt.Println(stk.Top()) // 3 true
	fmt.Println(stk.Len()) // 3


	// pop elements
	fmt.Println(stk.Pop()) // 3 true
	fmt.Println(stk.Pop()) // 2 true
	fmt.Println(stk.Pop()) // 1 true
	fmt.Println(stk.Pop()) // 0 false
}

About

simple Golang stack implementation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages