regex_literal/
correlation.rs1#![allow(unused)]
2use core::result::Result;
3use crate::delimited::*;
4use rayon::prelude::*;
5
6
7pub fn par_matching_indices(res:&[Regex],target:&str) -> Result<Vec<u16>,String> {
9 let data_length = res.len();
10 let max_index = u16::MAX as usize;
11 if data_length == 0 {
12 Err("Unable to do matching by an empty ReSequence struct".to_string())
13 }
14 else if max_index < data_length - 1 {
15 Err("Unable to do matching as this XRegex data contains more than 2^16 regex structs".to_string())
16 }else {
17 let index_iter = res.par_iter().enumerate()
20 .filter(|&(i,regex_ref)| regex_ref.is_match(target))
21 .map(|(i,_)| i as u16);
22 let indices: Vec<u16> = index_iter.collect();
23 Ok(indices)
24 }
25
26
27}