algods 0.1.0

A collection of data structures and algorithms
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use algods::utils::{BruteCollinearPoints, Point};

fn main() {
    let mut points = Vec::<Point<isize>>::new();
    for x in -1isize..2isize {
        for y in -1isize..2isize {
            points.push(Point::<isize>::init(x, y));
        }
    }
    points.push(Point::<isize>::init(2, 2));
    points.push(Point::<isize>::init(2, -2));
    points.push(Point::<isize>::init(2, 0));
    let mut brute_force = BruteCollinearPoints::<isize>::init(points);
    println!("{:?}", brute_force);
    // finding all segments of at least 4 collinear points (duplicates are possible)
    let segments = brute_force.segments();
    println!("{:#?}", segments);
}