Merge branch 'main' of ssh://git.bullercodeworks.com:2200/brian/adventofcode into main
This commit is contained in:
@@ -42,6 +42,39 @@ func StringSliceToCoordByteMap(input []string) CoordByteMap {
|
||||
return ret
|
||||
}
|
||||
|
||||
func (m *CoordByteMap) RowCount() int {
|
||||
return m.BRY - m.TLY
|
||||
}
|
||||
func (m *CoordByteMap) ColCount() int {
|
||||
return m.BRX - m.TLX
|
||||
}
|
||||
func (m *CoordByteMap) GetRow(y int) []byte {
|
||||
var resp []byte
|
||||
for x := m.TLX; x <= m.BRX; x++ {
|
||||
resp = append(resp, m.Get(Coordinate{X: x, Y: y}))
|
||||
}
|
||||
return resp
|
||||
}
|
||||
func (m *CoordByteMap) GetCol(x int) []byte {
|
||||
var resp []byte
|
||||
for y := m.TLY; y <= m.BRY; y++ {
|
||||
resp = append(resp, m.Get(Coordinate{X: x, Y: y}))
|
||||
}
|
||||
return resp
|
||||
}
|
||||
func (m *CoordByteMap) AddRow(row []byte) {
|
||||
y := m.BRY + 1
|
||||
for x := 0; x < len(row); x++ {
|
||||
m.Put(Coordinate{X: x + m.TLX, Y: y}, row[x])
|
||||
}
|
||||
}
|
||||
func (m *CoordByteMap) AddCol(col []byte) {
|
||||
x := m.BRX + 1
|
||||
for y := 0; y < len(col); y++ {
|
||||
m.Put(Coordinate{X: x, Y: y + m.TLY}, col[y])
|
||||
}
|
||||
}
|
||||
|
||||
func (m *CoordByteMap) GetPos(x, y int) byte {
|
||||
return m.Get(Coordinate{X: x, Y: y})
|
||||
}
|
||||
@@ -109,7 +142,8 @@ func (m *CoordByteMap) ToByteSlices() [][]byte {
|
||||
return ret
|
||||
}
|
||||
|
||||
// ContainsCoord returns true if the passed coordinate is in the map
|
||||
// ContainsCoord returns true if the passed coordinate is within the bounds
|
||||
// of the map
|
||||
func (m *CoordByteMap) ContainsCoord(c Coordinate) bool {
|
||||
return c.X >= m.TLX && c.X <= m.BRX &&
|
||||
c.Y >= m.TLY && c.Y <= m.BRY
|
||||
|
Reference in New Issue
Block a user