[go: up one dir, main page]

Skip to content

A simple stack based on Slice written in golang

Notifications You must be signed in to change notification settings

Crepu/Stack

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

#Introduction

This is a simple stack based on slice written in golang. According to Go Slices: usage and internals, this design should have good performance. There is also a version implemented via linked node

NewStack(number uint) *stack will return a stack. You should estimate number, the max-number of item in stack. If items number exceeds that estimation, Stack will allocate more space automatically. Len() int will return the item number in stack. Push(value interface{}) will save the item into stack. Pop() (interface{}, error) will pop the top item. If the stack is empty, it will return ErrEmptyStack error, which is also defined in this package. Peek() (interface{}, error) is similar with Pop.

Notice Since all return values are interface{}, you may need to use type assertion.

About

A simple stack based on Slice written in golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%