stack

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2020 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package stack provides implementation for Stack data structure https://simple.wikipedia.org/wiki/Stack_(data_structure)

Interface methods Push,Pop, Peek,IsEmpty,Size are the ways to interact with stack data structure. The test file stack_test.go illustrates usage of these methods

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// Push element to the stack
	Push(x interface{})

	// Pop element from the top of the stack
	// If stack is empty, returns nil
	Pop() interface{}

	// Peek check the value of top element
	Peek() interface{}

	// IsEmpty returns true if stack is empty
	IsEmpty() bool

	// Size returns number of elements in the stack
	Size() int
}

Interface implemented by stack, LIFO

type Stack

type Stack struct {
	// contains filtered or unexported fields
}

Implementation of stack.Interface

func (*Stack) IsEmpty

func (st *Stack) IsEmpty() bool

func (*Stack) Peek

func (st *Stack) Peek() interface{}

func (*Stack) Pop

func (st *Stack) Pop() interface{}

func (*Stack) Push

func (st *Stack) Push(elem interface{})

func (*Stack) Size

func (st *Stack) Size() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL