Skip to content
Package matrix implements iterator for 2D matrix navigation
Go Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
.travis.yml
LICENSE
README.md
nav.go
nav_test.go
onchange.sh

README.md

Build Status codecov Maintainability

matrix - Package implements iterator for matrix navigation

Quick start

Use this package to minimize complexity when navigatin 2D matrix structures. To loop over an matrix from top, left corner to bottom, right

for nav, x, y, inside := NewNavigator(3, 3); inside; x, y, inside = nav.Right() {
	// do something
}

Note that all navigation methods wrap at the edge of the given boundary.

  0 1 2 3 4
-+---------+
0| | | | | |
1| |-|-|-| |
2| |-|>|x| |
3| |x|x|x| |
4| | | | | |
-+---------+
You can’t perform that action at this time.