stack

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Copyright © 2021 Unknown <applicant@airwallex.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var ErrStackEmpty = errors.New("stack: is empty")

ErrStackEmpty

Functions

This section is empty.

Types

type Stack

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

Stack is

func NewStack

func NewStack() *Stack

NewStack is the factory method to instantiate a new Stack

func (*Stack) Pop

func (s *Stack) Pop() (f float64, err error)

Pop pops a value from the end of the stack and returns it. If the stack is empty it will raise an error

func (*Stack) Print

func (s *Stack) Print(output io.Writer)

Print is a helper method to print the current stack in human readable format with a maximum of 10 decimal places to the provided io.Writer interface.

func (*Stack) Push

func (s *Stack) Push(f ...float64)

Push pushes a float64 to the end of the stack

func (*Stack) PushString

func (s *Stack) PushString(str ...string) (err error)

Push pushes a string to the end of the stack

func (*Stack) Reset

func (s *Stack) Reset()

Reset resets the stack to an empty slice of float64 values

func (*Stack) Size

func (s *Stack) Size() int

Size returns the length of the current stack

func (*Stack) String

func (s *Stack) String() string

String writes the output of the print function to a buffer and returns a serialized string

Jump to

Keyboard shortcuts

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