Documentation ¶
Overview ¶
Package stack provides a basic implementation of a stack using a linked list.
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 implements the Stacker interface, and represents the stack data structure as a linked list, containing a pointer to the first Frame as a head and the size of the stack. It also contain a mutex to lock and unlock the access to the stack at I/O operations.
func NewStack ¶
func NewStack() *Stack
NewStack returns a blank stack, where head is nil and size is 0.
func (*Stack) Peek ¶
func (s *Stack) Peek() interface{}
Peek returns the element on top of the stack.
func (*Stack) Pop ¶
Pop removes and returns the element on top of the stack, updating its head to the next Frame. If the stack was empty, it returns false.
type Stacker ¶
type Stacker interface { // Push an element into a Stack Push(element interface{}) // Pop the topmost element of a stack Pop() (interface{}, bool) // Size returns the size of the Stack Size() int // Peek returns the topmost element of the Stack Peek() interface{} // Flush flushes a Stack Flush() }
Stacker represents an interface that contains all the required methods to implement a Stack that can be used in piladb.