No description
Find a file
2020-05-31 13:00:32 +00:00
src Update documentation 2020-05-31 13:00:32 +00:00
.gitignore Initial 2018-12-18 15:29:33 -05:00
Cargo.toml Update documentation 2020-05-31 13:00:32 +00:00
LICENSE Initial commit 2018-12-18 15:19:39 -05:00
README.md Update documentation 2020-05-31 13:00:32 +00:00

Support an Open Source Developer! ♥️

Become a patron

Half Matrix

A Half Matrix implementation. Also called a triangular matrix. Like a normal matrix, but you only store half of it.

Used to define relations between two elements of the same set.

This can be used to represent graphs (an edge between point A and B). It can also be used to represent associations (group A should have physical collisions enabled with group A and group B).

Usage

Cargo.toml:

[dependencies]
half_matrix = "*"

Code:

// 3x3
//
//  012
// 2oxo
// 1xx
// 0o

let mut m = HalfMatrix::new(3);
m.enable(2, 0);
m.enable(2, 2);
m.enable(0, 0);

assert!(m.contains(2,0));
assert!(m.contains(2,2));
assert!(m.contains(0,0));

assert!(!m.contains(1,0));
assert!(!m.contains(1,1));
assert!(!m.contains(2,1));