Struct boyer_moore_magiclen::character::BMCharacter
source · pub struct BMCharacter { /* private fields */ }
character
only.Expand description
Using Boyer-Moore-MagicLen to search character sub-sequences in any character sequence.
Implementations§
source§impl BMCharacter
impl BMCharacter
sourcepub fn from<T: BMCharacterSearchable>(pattern: T) -> Option<BMCharacter>
pub fn from<T: BMCharacterSearchable>(pattern: T) -> Option<BMCharacter>
Create a BMByte
instance from a pattern (the search needle).
use boyer_moore_magiclen::BMCharacter;
let bmc = BMCharacter::from(vec!['o', 'o', 'c', 'o', 'o']).unwrap();
source§impl BMCharacter
impl BMCharacter
sourcepub fn find_full_all_in<T: BMCharacterSearchable>(&self, text: T) -> Vec<usize>
pub fn find_full_all_in<T: BMCharacterSearchable>(&self, text: T) -> Vec<usize>
Find and return the positions of all matched sub-sequences in any text (the haystack).
use boyer_moore_magiclen::BMCharacter;
let bmc = BMCharacter::from(vec!['o', 'o', 'c', 'o', 'o']).unwrap();
assert_eq!(
vec![1, 4, 7],
bmc.find_full_all_in(vec![
'c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o'
])
);
sourcepub fn find_full_in<T: BMCharacterSearchable>(
&self,
text: T,
limit: usize
) -> Vec<usize>
pub fn find_full_in<T: BMCharacterSearchable>( &self, text: T, limit: usize ) -> Vec<usize>
Find and return the positions of matched sub-sequences in any text (the haystack). If the limit
is set to 0
, all sub-sequences will be found.
use boyer_moore_magiclen::BMCharacter;
let bmc = BMCharacter::from(vec!['o', 'o', 'c', 'o', 'o']).unwrap();
assert_eq!(
vec![1, 4],
bmc.find_full_in(
vec!['c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o'],
2
)
);
source§impl BMCharacter
impl BMCharacter
sourcepub fn rfind_full_all_in<T: BMCharacterSearchable>(&self, text: T) -> Vec<usize>
pub fn rfind_full_all_in<T: BMCharacterSearchable>(&self, text: T) -> Vec<usize>
Find and return the positions of all matched sub-sequences in any text (the haystack) from its tail to its head.
use boyer_moore_magiclen::BMCharacter;
let bmc = BMCharacter::from(vec!['o', 'o', 'c', 'o', 'o']).unwrap();
assert_eq!(
vec![7, 4, 1],
bmc.rfind_full_all_in(vec![
'c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o'
])
);
sourcepub fn rfind_full_in<T: BMCharacterSearchable>(
&self,
text: T,
limit: usize
) -> Vec<usize>
pub fn rfind_full_in<T: BMCharacterSearchable>( &self, text: T, limit: usize ) -> Vec<usize>
Find and return the positions of matched sub-sequences in any text (the haystack) from its tail to its head. If the limit
is set to 0
, all sub-sequences will be found.
use boyer_moore_magiclen::BMCharacter;
let bmc = BMCharacter::from(vec!['o', 'o', 'c', 'o', 'o']).unwrap();
assert_eq!(
vec![7, 4],
bmc.rfind_full_in(
vec!['c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o'],
2
)
);
source§impl BMCharacter
impl BMCharacter
sourcepub fn find_all_in<T: BMCharacterSearchable>(&self, text: T) -> Vec<usize>
pub fn find_all_in<T: BMCharacterSearchable>(&self, text: T) -> Vec<usize>
Find and return the positions of all matched sub-sequences in any text (the haystack) but not including the overlap.
use boyer_moore_magiclen::BMCharacter;
let bmc = BMCharacter::from(vec!['o', 'o', 'c', 'o', 'o']).unwrap();
assert_eq!(
vec![1, 7],
bmc.find_all_in(vec![
'c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o'
])
);
sourcepub fn find_first_in<T: BMCharacterSearchable>(&self, text: T) -> Option<usize>
pub fn find_first_in<T: BMCharacterSearchable>(&self, text: T) -> Option<usize>
Find and return the position of the first matched sub-sequence in any text (the haystack).
use boyer_moore_magiclen::BMCharacter;
let bmc = BMCharacter::from(vec!['o', 'o', 'c', 'o', 'o']).unwrap();
assert_eq!(
Some(1),
bmc.find_first_in(vec![
'c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o'
])
);
sourcepub fn find_in<T: BMCharacterSearchable>(
&self,
text: T,
limit: usize
) -> Vec<usize>
pub fn find_in<T: BMCharacterSearchable>( &self, text: T, limit: usize ) -> Vec<usize>
Find and return the positions of matched sub-sequences in any text (the haystack) but not including the overlap. If the limit
is set to 0
, all sub-sequences will be found.
use boyer_moore_magiclen::BMCharacter;
let bmc = BMCharacter::from(vec!['o', 'o', 'c', 'o', 'o']).unwrap();
assert_eq!(
vec![1],
bmc.find_in(
vec!['c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o'],
1
)
);
source§impl BMCharacter
impl BMCharacter
sourcepub fn rfind_all_in<T: BMCharacterSearchable>(&self, text: T) -> Vec<usize>
pub fn rfind_all_in<T: BMCharacterSearchable>(&self, text: T) -> Vec<usize>
Find and return the positions of all matched sub-sequences in any text (the haystack) but not including the overlap from its tail to its head.
use boyer_moore_magiclen::BMCharacter;
let bmc = BMCharacter::from(vec!['o', 'o', 'c', 'o', 'o']).unwrap();
assert_eq!(
vec![7, 1],
bmc.rfind_all_in(vec![
'c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o'
])
);
sourcepub fn rfind_first_in<T: BMCharacterSearchable>(&self, text: T) -> Option<usize>
pub fn rfind_first_in<T: BMCharacterSearchable>(&self, text: T) -> Option<usize>
Find and return the position of the first matched sub-sequence in any text (the haystack) from its tail to its head.
use boyer_moore_magiclen::BMCharacter;
let bmc = BMCharacter::from(vec!['o', 'o', 'c', 'o', 'o']).unwrap();
assert_eq!(
Some(7),
bmc.rfind_first_in(vec![
'c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o'
])
);
sourcepub fn rfind_in<T: BMCharacterSearchable>(
&self,
text: T,
limit: usize
) -> Vec<usize>
pub fn rfind_in<T: BMCharacterSearchable>( &self, text: T, limit: usize ) -> Vec<usize>
Find and return the positions of matched sub-sequences in any text (the haystack) but not including the overlap from its tail to its head. If the limit
is set to 0
, all sub-sequences will be found.
use boyer_moore_magiclen::BMCharacter;
let bmc = BMCharacter::from(vec!['o', 'o', 'c', 'o', 'o']).unwrap();
assert_eq!(
vec![7],
bmc.rfind_in(
vec!['c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o', 'c', 'o', 'o'],
1
)
);