immutablestack

package module
v0.0.0-...-ca2cfab Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2016 License: MIT Imports: 0 Imported by: 0

README

immutablestack codebeat badge GoDoc GoCover

Immutable stack implementation in Go

wercker status

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Functor

type Functor func(interface{}) interface{}

Functor is a function capable of modifying stack elements.

type ImmutableStack

type ImmutableStack interface {
	// Top returns the top element on the stack.
	Top() interface{}

	// Pop returns the next substack.
	Pop() ImmutableStack

	// Size returns the size of the stack.
	Size() uint64

	// Push pushes a new element onto the stack and returns a new stack.
	Push(interface{}) ImmutableStack

	// ForEach iterates over the stack and applies the iterator function to each
	// substack until it finds the empty one or the iterator returns an error.
	ForEach(Iterator)

	// FMap applies a function to each element on the stack and returns the new
	// stack with results of the function application.
	FMap(f Functor) ImmutableStack
}

ImmutableStack is an abstract immutable LIFO data structure.

func New

func New() ImmutableStack

New returns a new instance of ImmutableStack.

type Iterator

type Iterator func(ImmutableStack) error

Iterator is a function taking a each substack of a given stack. It can return an error to break iteration.

Jump to

Keyboard shortcuts

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