// CountFunc returns the number of cells for which the given function returns
// true.
CountFunc returns the number of cells for which the given function returns
true.
// CountFunc returns the number of cells for which the given function returns // true .
func (gd Grid) CountFunc(fn func(c Cell) bool) int {
	if gd.Ug == nil {
		return 0
	}
	w := gd.Ug.Width
	count := 0
	yimax := gd.Rg.Max.Y * w
	cells := gd.Ug.Cells
	for yi := gd.Rg.Min.Y * w; yi < yimax; yi += w {
		ximax := yi + gd.Rg.Max.X
		for xi := yi + gd.Rg.Min.X; xi < ximax; xi++ {
			c := cells[xi]
			count += bool2int(fn(c))
		}
	}
	return count
}
func ( gd Grid ) CountFunc ( fn func ( c Cell ) bool ) int { if gd . Ug == nil { return 0 } w := gd . Ug . Width count := 0 yimax := gd . Rg . Max . Y * w cells := gd . Ug . Cells for yi := gd . Rg . Min . Y * w ; yi < yimax ; yi += w { ximax := yi + gd . Rg . Max . X for xi := yi + gd . Rg . Min . X ; xi < ximax ; xi ++ { c := cells [ xi ] count += bool2int ( fn ( c ) ) } } return count }
CountFunc returns the number of cells for which the given function returns
true.
CountFunc returns the number of cells for which the given function returns true .