aocutils

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseNum

func ParseNum(s string) (int, error)

Returns a number which was parsed from the given string. Uses strconv.Atoi. If the number cannot be parsed, returns an error.

func ParseNumOrPanic

func ParseNumOrPanic(s string) int

Returns a number which was parsed from the given string or panics if it fails. Uses strconv.Atoi.

func ReadFileBlocks

func ReadFileBlocks(filename string) ([][]string, error)

ReadFileLines reads the lines of the specified split on two newlines, that is in two blocks separated by two newlines and returns each block as a slice as part of another slice contains all the blocks. If the file does not exist or the scanner returns an error, it returns an error.

func ReadFileLines

func ReadFileLines(name string) ([]string, error)

ReadFileLines reads the lines of the specified split on newlines and returns as a `[]string`. If the file does not exist or the scanner returns an error, it returns an error.

Types

type StringStack

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

A stack to store strings only. For a general stack, or other general data structure use other packages like https://github.com/zyedidia/generic

func NewPopulatedStringStack

func NewPopulatedStringStack(values []string) *StringStack

Returns a new string stack initialized with the values provided. The values are pushed onto the stack from the starting of the values till the end.

func NewStringStack

func NewStringStack() *StringStack

Returns a new initialized string stack. Push and Pop can work right away.

func (*StringStack) IsEmpty

func (s *StringStack) IsEmpty() bool

Returns whether the stack is empty or not

func (*StringStack) Len

func (s *StringStack) Len() int

Returns the length of the stack

func (*StringStack) Peek

func (s *StringStack) Peek() (string, error)

Returns the top string from the stack but does not remove it. It returns an error if the stack is empty.

func (*StringStack) Pop

func (s *StringStack) Pop() (string, error)

Remove the top string from the stack and return it. It returns an error if the stack is empty.

func (*StringStack) Push

func (s *StringStack) Push(value string)

Push a string onto the stack

func (*StringStack) String

func (s *StringStack) String() string

Implements Stringer

Jump to

Keyboard shortcuts

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