pub struct BMCharacter { /* private fields */ }
Available on crate feature character only.
Expand description

Using Boyer-Moore-MagicLen to search character sub-sequences in any character sequence.

Implementations§

source§

impl BMCharacter

source

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

source

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'
    ])
);
source

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

source

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'
    ])
);
source

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

source

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'
    ])
);
source

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'
    ])
);
source

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

source

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'
    ])
);
source

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'
    ])
);
source

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
    )
);

Trait Implementations§

source§

impl Debug for BMCharacter

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.