Documentation
¶
Overview ¶
Package shared contains shared code for all lib modules.
Index ¶
- Variables
- func Abs[T Number](i T) T
- func Assert(must bool, message string)
- func Die(err error, message string)
- func DiffLocSets(t *testing.T, expected, actual *gent.Set[Loc])
- func DigitLength(i int) int
- func Hash(s []int) uint64
- func InitLogging()
- func InitNullLogging()
- func InitTestLogging(tb testing.TB)
- func IsDebugEnabled() bool
- func Max[T Number](a, b T) T
- func Min[T Number](a, b T) T
- func Or[T any](o bool, yes, no T) T
- func ParseIntOrDie(s string) int
- func Pow(b, e int) int
- func ReadLinesFromFile(filep string) (lines []string, err error)
- func SetupCPUProfiling(filen string) (callback func())
- func SplitToBlocks(lines []string) [][]string
- func StripPadding(lines []string) []string
- func SubString(s string, length int) string
- func ToColumns(s []string) (left []string, right []string)
- func ToIntTable(s []string) (table [][]int)
- func ToInts(s []string) (nums []int, err error)
- type Board
- func (v *Board) Copy() *Board
- func (v *Board) CountArea() int
- func (v *Board) FindOrDie(c rune) Loc
- func (v *Board) Get(loc Loc) (c rune, ok bool)
- func (v *Board) GetArea() int
- func (v *Board) GetHeight() int
- func (v *Board) GetInt(loc Loc) (i int, ok bool)
- func (v *Board) GetIntOrDie(loc Loc) int
- func (v *Board) GetLines() []string
- func (v *Board) GetOrDie(loc Loc) rune
- func (v *Board) GetWidth() int
- func (v *Board) Iter(cb BoardIterCb)
- func (v *Board) NextTo(loc Loc, c any, includeCorners bool) []Loc
- func (v *Board) Set(loc Loc, c rune)
- type BoardIterCb
- type Direction
- type Link
- type Loc
- type Number
- type Pair
Constants ¶
This section is empty.
Variables ¶
View Source
var ( RealEast = Direction{X: 1, Y: 0} RealSouth = Direction{X: 0, Y: -1} RealWest = Direction{X: -1, Y: 0} RealNorth = Direction{X: 0, Y: 1} RealPrimaryDirections = []Direction{ RealEast, RealSouth, RealWest, RealNorth, } RealSouthEast = Direction{X: 1, Y: -1} RealSouthWest = Direction{X: -1, Y: -1} RealNorthWest = Direction{X: -1, Y: 1} RealNorthEast = Direction{X: 1, Y: 1} RealMiddleDirections = []Direction{ RealSouthEast, RealSouthWest, RealNorthWest, RealNorthEast, } DirNorth = Direction{X: 0, Y: -1} DirEast = Direction{X: 1, Y: 0} DirSouth = Direction{X: 0, Y: 1} DirWest = Direction{X: -1, Y: 0} Directions = []Direction{ DirEast, {X: 1, Y: -1}, DirNorth, {X: -1, Y: -1}, DirWest, {X: -1, Y: 1}, DirSouth, {X: 1, Y: 1}, } )
View Source
var ( // Logger is the logger for the app. Logger *slog.Logger )
Functions ¶
func DigitLength ¶
func InitNullLogging ¶
func InitNullLogging()
func InitTestLogging ¶
InitTestLogging creates an slog logger that writes to t.Log.
func IsDebugEnabled ¶
func IsDebugEnabled() bool
func ParseIntOrDie ¶
func ReadLinesFromFile ¶
func SetupCPUProfiling ¶
func SetupCPUProfiling(filen string) (callback func())
func SplitToBlocks ¶
SplitToBlocks splits lines with empty / blank lines.
func StripPadding ¶
func ToIntTable ¶
Types ¶
type Board ¶
type Board struct {
ReadOnly bool
// contains filtered or unexported fields
}
func (*Board) GetIntOrDie ¶
func (*Board) Iter ¶
func (v *Board) Iter(cb BoardIterCb)
Click to show internal directories.
Click to hide internal directories.