#iterator #2d #distance #2d-array

spiral

Iterate over a 2D structure in a spiral pattern

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

Download history 10/week @ 2024-07-08 46/week @ 2024-07-29 9/week @ 2024-08-05 10/week @ 2024-08-12 20/week @ 2024-08-19 4/week @ 2024-08-26 7/week @ 2024-09-02 10/week @ 2024-09-09 17/week @ 2024-09-16 11/week @ 2024-09-23 103/week @ 2024-09-30 15/week @ 2024-10-07

147 downloads per month
Used in 3 crates (2 directly)

GPL-3.0 license

18KB
272 lines

spiral

Build Status Crates.io Documentation License: GPL-3.0 Downloads

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