Crates.io | spiral |
lib.rs | spiral |
version | 0.2.1 |
source | src |
created_at | 2017-12-21 20:18:09.009821 |
updated_at | 2024-02-09 21:02:14.042061 |
description | Iterate over a 2D structure in a spiral pattern |
homepage | https://github.com/tversteeg/spiral |
repository | https://github.com/tversteeg/spiral.git |
max_upload_size | |
id | 43885 |
size | 55,938 |
Iterators to iterate 2D structures in spiral patterns
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"
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`.
}