Skip to content

Commit

Permalink
drain_filter := extract_if and remove option_result_contains (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankurdubey521 authored Jul 13, 2023
1 parent ade9030 commit c79cae9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@

*.synctex.gz
*.bak

*.csv
9 changes: 6 additions & 3 deletions src/algorithms/bron_kerbosh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ fn bron_kerbosh_aux<F>(
// modified p (p \ neighbourhood(pivot)), modified x
let (mut ip, mut mp, mut mx) = (p.clone(), p.clone(), x.clone());
let pivot = find_pivot(&p, &x, neighbourhoods);
ip.drain_filter(|e| neighbourhoods[pivot].contains(e));
ip.extract_if(|e| neighbourhoods[pivot].contains(e))
.collect::<Vec<usize>>();

// while !mp.is_empty() {
while !ip.is_empty() {
Expand All @@ -124,7 +125,8 @@ fn bron_kerbosh_aux<F>(
// p \ { v }, x U { v }
mp.remove(mp.iter().position(|x| *x == v).unwrap());
ip = mp.clone();
ip.drain_filter(|e| neighbourhoods[pivot].contains(e));
ip.extract_if(|e| neighbourhoods[pivot].contains(e))
.collect::<Vec<usize>>();
mx.push(v);
}
}
Expand All @@ -136,7 +138,8 @@ fn find_pivot(p: &[usize], x: &[usize], neighbourhoods: &[Vec<usize>]) -> usize
*px.iter()
.min_by_key(|&e| {
let mut pp = p.to_vec();
pp.drain_filter(|ee| neighbourhoods[*e].contains(ee));
pp.extract_if(|ee| neighbourhoods[*e].contains(ee))
.collect::<Vec<usize>>();
pp.len()
})
.unwrap()
Expand Down
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#![feature(int_roundings)]
#![feature(iter_collect_into)]
#![feature(drain_filter)]
#![feature(option_result_contains)]
#![feature(hash_drain_filter)]
#![feature(extract_if)]
#![feature(hash_extract_if)]

pub mod aapp;
pub mod algorithms;
Expand Down

0 comments on commit c79cae9

Please sign in to comment.