Back to

Package stack

Latest Go to latest

The latest major version is .

Published: Aug 23, 2016 | License: BSD-3-Clause | Module:


Package graph.stack provides an implementation of the Stack abstract-datastructure, basically providing the standard graph.stack operating primitives.

Author: Mark Summerfield, found in the book: "Programming in Go, Creating Applications for the 21st Century"

Author: Christian Bergum Bergersen, added comments to satisfy Golang code convention.


type Stack

type Stack []interface{}

Stack is an array data-structure with the properties of a LIFO queue.

func (Stack) Cap

func (stack Stack) Cap() int

Cap returns the capacity of the graph.stack.

func (Stack) IsEmpty

func (stack Stack) IsEmpty() bool

IsEmpty returns true if graph.stack is empty, false otherwise.

func (Stack) Len

func (stack Stack) Len() int

Len returns the size(length) of the graph.stack.

func (*Stack) Pop

func (stack *Stack) Pop() (interface{}, error)

Pop removes and returns the first(top) element of the graph.stack, or returns an error message if the graph.stack is empty.

func (*Stack) Push

func (stack *Stack) Push(x interface{})

Push puts x on the top of the graph.stack.

func (Stack) Top

func (stack Stack) Top() (interface{}, error)

Top returns the first first(top) element in the graph.stack, or error message if the graph.stack is empty.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier