Skip to content

Latest commit

 

History

History
35 lines (25 loc) · 732 Bytes

points.md

File metadata and controls

35 lines (25 loc) · 732 Bytes

Points

RTree is able to store points represented by tuples. We can also store arrays in it.

use rstar::RTree;

fn main() {
    let mut tree = RTree::new();

    tree.insert([0, 0]);
    tree.insert([1, 2]);
    tree.insert([8, 5]);

    for point in &tree {
        println!("{:?}", point);
    }
}

Output:

[8, 5]
[1, 2]
[0, 0]

Arrays are useful when the length of points is more than 9, which is more than the length implemented for tuples. However, the length of arrays must be fixed, so we cannot store vec![...], which has variable length.

➡️ Next: Lines

📘 Back: Table of contents