use std::collections::{
    BTreeMap,
    HashSet,
};

fn main() {
    let v = vec![1, 3, 5];
    println!("For each print:");
    for x in &v {
        println!("{}", x);
    }

    println!("Enumerate for each print:");
    for (i, x) in v.iter().enumerate() {
        println!("{} -> {}", i, x);
    }

    println!("Pop print:");
    let mut v2 = vec![2, 4, 6];
    while let Some(x) = v2.pop() {
        println!("{}", x);
    }

    println!("Map:");
    let v3: Vec<i32> = (0..3).collect();
    let v4 = v3.iter().map(|&x| x * 2).collect::<Vec<_>>();
    println!("{:?} -> {:?}", v3, v4);

    println!("To Set:");
    let v5 = vec![1, 2, 3, 4];
    let v_s: HashSet<usize> = v5.into_iter().collect();
    println!("{:?}", v_s);

    println!("To Map:");
    let v = (0..5).collect::<Vec<i32>>();
    let m = v.iter().map(|i| (*i, i * 10)).collect::<BTreeMap<i32, i32>>();
    println!("{:?}", m);

    println!("HashSet Union:");
    let s_u_1 = vec![1, 2, 3].into_iter().collect::<HashSet<usize>>();
    let s_u_2 = vec![4, 5, 6].into_iter().collect::<HashSet<usize>>();
    println!("{:?}", s_u_1.union(&s_u_2));

    println!("HashSet Difference:");
    let s_d_1 = vec![1, 2, 3].into_iter().collect::<HashSet<usize>>();
    let s_d_2 = vec![2, 3, 4].into_iter().collect::<HashSet<usize>>();
    println!("{:?}", s_d_1.difference(&s_d_2));

    println!("HashSet Intersection:");
    let s_i_1 = vec![1, 2, 3].into_iter().collect::<HashSet<usize>>();
    let s_i_2 = vec![2, 3, 4].into_iter().collect::<HashSet<usize>>();
    println!("{:?}", s_i_1.intersection(&s_i_2));

    println!("HashSet Symmetric Difference:");
    let s_sd_1 = vec![1, 2, 3].into_iter().collect::<HashSet<usize>>();
    let s_sd_2 = vec![2, 3, 4].into_iter().collect::<HashSet<usize>>();
    println!("{:?}", s_sd_1.symmetric_difference(&s_sd_2));
}

