pub trait Segment: Sized {
    // Required methods
    fn remove(&mut self, args: ArgsType);
    fn split(&mut self, pos: usize, args: ArgsType) -> Self;
    fn modify(&mut self, new_flag: IdentType, args: ArgsType);

    // Provided methods
    fn shrink_to_left(&mut self, pos: usize, args: ArgsType) { ... }
    fn shrink_to_right(&mut self, pos: usize, args: ArgsType) { ... }
    fn split_and_remove_middle(
        &mut self,
        pos_left: usize,
        pos_right: usize,
        args: ArgsType
    ) -> Self { ... }
    fn modify_left(
        &mut self,
        pos: usize,
        new_flag: IdentType,
        args: ArgsType
    ) -> Self { ... }
    fn modify_right(
        &mut self,
        pos: usize,
        new_flag: IdentType,
        args: ArgsType
    ) -> Self { ... }
    fn modify_middle(
        &mut self,
        pos_left: usize,
        pos_right: usize,
        new_flag: IdentType,
        args: ArgsType
    ) -> (Self, Self) { ... }
}
Expand description

维护一段相同权限的地址区间的线段

Required Methods§

source

fn remove(&mut self, args: ArgsType)

删除这段区间

source

fn split(&mut self, pos: usize, args: ArgsType) -> Self

拆分这段区间。self 结构变成左半边,返回右半边

注意pos 参数为绝对位置而非相对位置

source

fn modify(&mut self, new_flag: IdentType, args: ArgsType)

修改区间的属性

Provided Methods§

source

fn shrink_to_left(&mut self, pos: usize, args: ArgsType)

按 pos 拆分区间,只保留左半边

注意pos 参数为绝对位置而非相对位置

source

fn shrink_to_right(&mut self, pos: usize, args: ArgsType)

按 pos 拆分区间,只保留右半边

注意pos 参数为绝对位置而非相对位置

source

fn split_and_remove_middle( &mut self, pos_left: usize, pos_right: usize, args: ArgsType ) -> Self

按 pos_left 和 pos_right 把区间拆成三段,默认不检查 pos_left <= pos_right。 然后 self 结构变成左半边区间,删除中间的区间,返回右半边区间

注意pos 参数为绝对位置而非相对位置

source

fn modify_left(&mut self, pos: usize, new_flag: IdentType, args: ArgsType) -> Self

按 pos 拆分区间,并将左半边区间的属性修改为 new_flag。 self 结构变成左半边,返回右半边

注意pos 参数为绝对位置而非相对位置

source

fn modify_right(&mut self, pos: usize, new_flag: IdentType, args: ArgsType) -> Self

按 pos 拆分区间,并将右半边区间的属性修改为 new_flag。 self 结构变成左半边,返回右半边

注意pos 参数为绝对位置而非相对位置

source

fn modify_middle( &mut self, pos_left: usize, pos_right: usize, new_flag: IdentType, args: ArgsType ) -> (Self, Self)

按 pos_left 和 pos_right 把区间拆成三段,默认不检查 pos_left <= pos_right, 然后修改中间一段的属性。 self 结构变成左半边,返回中间和右半边

注意pos 参数为绝对位置而非相对位置

Implementors§