util

package
v0.0.0-...-0fe8321 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolToInt

func BoolToInt(b bool) int

BoolToInt converts a bool to an int

func MaxInt

func MaxInt(a, b int) int

MaxInt returns the larger of two integers

func MinInt

func MinInt(a, b int) int

MinInt returns the smaller of two integers

func ParseIntList

func ParseIntList(line string, sep string) ([]int, error)

func ReadFileAsByteChunks

func ReadFileAsByteChunks(fileName string) [][]byte

ReadFileAsByteChunks reads a file and returns a slice of byte slices

func ReadFileAsBytes

func ReadFileAsBytes(fileName string) []byte

ReadFileAsBytes reads a file and returns a slice of bytes

func ReadFileAsLines

func ReadFileAsLines(fileName string) []string

ReadFileAsLines reads a file line by line and returns a slice of strings

func ReadFileAsRuneMatrix

func ReadFileAsRuneMatrix(fileName string) [][]rune

ReadFileAsRuneMatrix reads a file and returns a matrix of strings Returns as [x][y] where x is the column (horizontal) and y is the row (vertical)

func SliceContainsRune

func SliceContainsRune(s []rune, r rune) bool

SliceContainsRune returns true if a rune is in a slice of runes

func SliceContainsString

func SliceContainsString(s []string, str string) bool

SliceContainsString returns true if a string is in a slice of strings

func SlicePop

func SlicePop[T any](s *[]T) (T, error)

SlicePop removes the last element from an *[]T and returns it

func StringToInt

func StringToInt(line string) (int, error)

StringToInt converts a string to an int wrapper for strconv.Atoi for standardization / readability

func StringToIntArray

func StringToIntArray(line string) ([]int, error)

StringToIntArray converts a string to an array of ints wrapper for strconv.Atoi for standardization / readability

Types

type Segment

type Segment struct {
	Start, End int
}

type SegmentList

type SegmentList []Segment

func (*SegmentList) Lowest

func (segList *SegmentList) Lowest() int

func (*SegmentList) Merge

func (segList *SegmentList) Merge()

func (*SegmentList) Sort

func (segList *SegmentList) Sort()

type Stack

type Stack[T any] struct {
	// contains filtered or unexported fields
}

Stack is a generic stack implementation

func (*Stack[T]) GetStackString

func (s *Stack[T]) GetStackString() string

GetStack returns the stack as a string

func (*Stack[T]) IsEmpty

func (s *Stack[T]) IsEmpty() bool

func (*Stack[T]) Len

func (s *Stack[T]) Len() int

Len returns the length of the stack

func (*Stack[T]) Peek

func (s *Stack[T]) Peek() T

Peek returns the top item on the stack without removing it from the stack

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() T

Pop removes an item from the stack

func (*Stack[T]) Push

func (s *Stack[T]) Push(r T)

Push adds an item to the stack

func (*Stack[T]) Reverse

func (s *Stack[T]) Reverse()

Reverse reverses the order of the stack

Jump to

Keyboard shortcuts

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