[−][src]Function matchmaker::da_stb::match_students_to_multiple_categories
pub fn match_students_to_multiple_categories(
students: Vec<Student>,
categories: &Vec<Category>,
rng: &mut impl Rng
) -> MatchResult
Match students to more than one category
Use this function when a single student can be placed simultaniously in more than one category
Example
use matchmaker::{Category, Student}; use matchmaker::da_stb::match_students_to_multiple_categories; use rand::thread_rng; use std::collections::VecDeque; // Create categories let cooking = Category::new("Cooking", 10); let reading = Category::new("Reading", 10); let walking = Category::new("Walking", 5); // Create student Bert // Bert wishes to be placed in category cooking or reading (in that order) let bert = Student::new( "Bert", VecDeque::from(vec![cooking.clone(), reading.clone()]), Vec::new(), ); // Create student Suze // Suze wishes to be placed in category cooking or reading (in that order), // but does not wish to be placed in category walking let suze = Student::new( "Suze", VecDeque::from(vec![cooking.clone(), reading.clone()]), Vec::from([walking.clone()]), ); let mut rng = thread_rng(); let categories = Vec::from([cooking, reading, walking]); let match_result = match_students_to_multiple_categories( Vec::from([bert, suze]), &categories, &mut rng);
The result will be something like this:
Students matched to categories:
Cooking:
- Suze
- Bert
Reading:
- Bert
- Suze
Walking:
- Bert
All students could be placed.