12 releases
0.2.1 | Feb 9, 2024 |
---|---|
0.2.0 | Oct 9, 2022 |
0.1.9 | Mar 14, 2018 |
0.1.8 | Jan 6, 2018 |
0.1.5 | Dec 29, 2017 |
#352 in Algorithms
147 downloads per month
Used in 3 crates
(2 directly)
18KB
272 lines
spiral
Documentation
Iterators to iterate 2D structures in spiral patterns
Usage
This crate is on crates.io and can be used by adding
spiral
to the dependencies in your project's Cargo.toml
.
[dependencies]
spiral = "0.2"
Examples
use spiral::ChebyshevIterator;
let center_x = 3;
let center_y = 3;
let radius = 4;
let iterator = ChebyshevIterator::new(center_x, center_y, radius);
for (x, y) in iterator {
// Iterates over a 7x7 2D array with `x` & `y`.
}
use spiral::ManhattanIterator;
let center_x = 3;
let center_y = 3;
let radius = 4;
for (x, y) in ManhattanIterator::new(center_x, center_y, radius) {
// Iterates over a 7x7 2D array with `x` & `y`.
}
Dependencies
~150KB