Crates.io | priority-matrix |
lib.rs | priority-matrix |
version | 0.2.0 |
source | src |
created_at | 2023-02-12 15:21:36.620193 |
updated_at | 2023-04-19 22:10:42.443615 |
description | A matrix that supports per-row, per-column and whole-matrix maximum key queries. |
homepage | https://github.com/jerry73204/priority-matrix |
repository | https://github.com/jerry73204/priority-matrix.git |
max_upload_size | |
id | 783250 |
size | 19,799 |
The Rust crate implements the matrix data structure that supports per-row, per-column and whole-matrix maximum key queries.
The code below is an example to query the key with the maximum weight either in the matrix, in a row or in a column. The complete example can be found in peek.rs.
let matrix: PriorityMatrix<char, &str, i32> = [
('a', "alpha", 0),
('a', "beta", 3),
('b', "alpha", 2),
('b', "beta", 1),
]
.into_iter()
.collect();
// Get the maximum entry
let entry = matrix.peek().unwrap();
assert_eq!(entry.weight, &3);
// Get the maximum entry in a row
let entry = matrix.peek_from_row(&'b').unwrap();
assert_eq!(entry.column, &"alpha");
// Get the maximum entry in a column
let entry = matrix.peek_from_column(&"alpha").unwrap();
assert_eq!(entry.row, &'b');
This project is distributed under MIT license. Please read the license file.