Documentation
¶
Overview ¶
Package stack aims to provide a fast, simple, thread safe, and generic golang stack library to the public. It uses as few linking libraries as possible, and the ones it does are common standard libraries for a smaller code footprint and greater performance.
Each Stack is generically compatible, meaning that any data can be added and retrieved to/from a Stack. Locks are also used on Stack objects when modifying the Stack through using the Pop or Push methods, so that Stack objects are thread safe.
Package stack aims to provide a fast, simple, thread safe, and generic golang stack library to the public. It uses as few linking libraries as possible, and the ones it does are common standard libraries for a smaller code footprint and greater performance. Each Stack is generically compatible, meaning that any data can be added and retrieved to/from a Stack. Locks are also used on Stack objects when modifying the Stack through using the Pop or Push methods, so that Stack objects are thread safe.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack stores the lock and data members of the stack.
func NewStack ¶
func NewStack() *Stack
NewStack is the constructor method that initializes a new, empty stack and returns it.
func (*Stack) Drain ¶
func (s *Stack) Drain()
Drain removes all elements that are currently in the stack.
func (*Stack) Peek ¶
Peek looks at, but does not remove, the top element of the stack. It returns an error if the stack is empty, or the value of the top element if it isn't.
func (*Stack) Pop ¶
Pop attempts to remove a value from the top of the stack. It will return an error if the stack is empty, or the value of the top element if it isn't.
