mirror of
https://github.com/fumiama/terasu-cloudflared.git
synced 2026-06-11 21:50:25 +08:00
TUN-528: Move cloudflared into a separate repo
This commit is contained in:
52
vendor/github.com/golang-collections/collections/grid/grid.go
generated
vendored
Normal file
52
vendor/github.com/golang-collections/collections/grid/grid.go
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
package grid
|
||||
|
||||
import (
|
||||
. "github.com/badgerodon/collections"
|
||||
)
|
||||
|
||||
type (
|
||||
Grid struct {
|
||||
values []interface{}
|
||||
cols, rows int
|
||||
}
|
||||
)
|
||||
|
||||
func New(cols, rows int) *Grid {
|
||||
return &Grid{
|
||||
values: make([]interface{}, cols*rows),
|
||||
cols: cols,
|
||||
rows: rows,
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Grid) Do(f func(p Point, value interface{})) {
|
||||
for x := 0; x < this.cols; x++ {
|
||||
for y := 0; y < this.rows; y++ {
|
||||
f(Point{x, y}, this.values[x*this.cols+y])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Grid) Get(p Point) interface{} {
|
||||
if p.X < 0 || p.Y < 0 || p.X >= this.cols || p.Y >= this.rows {
|
||||
return nil
|
||||
}
|
||||
v, _ := this.values[p.X*this.cols+p.Y]
|
||||
return v
|
||||
}
|
||||
|
||||
func (this *Grid) Rows() int {
|
||||
return this.rows
|
||||
}
|
||||
|
||||
func (this *Grid) Cols() int {
|
||||
return this.cols
|
||||
}
|
||||
|
||||
func (this *Grid) Len() int {
|
||||
return this.rows * this.cols
|
||||
}
|
||||
|
||||
func (this *Grid) Set(p Point, v interface{}) {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user