Struct Subset
pub struct Subset { /* private fields */ }Expand description
Represents a multi-subset of a string, that is a subset where elements can be included multiple times. This is represented as each element of the string having a “count” which is the number of times that element is included in the set.
Internally, this is stored as a list of “segments” with a length and a count.
Implementations§
§impl Subset
impl Subset
pub fn delete_from_string(&self, s: &str) -> String
pub fn delete_from_string(&self, s: &str) -> String
Mostly for testing.
pub fn delete_from<N>(&self, s: &Node<N>) -> Node<N>where
N: NodeInfo,
pub fn delete_from<N>(&self, s: &Node<N>) -> Node<N>where
N: NodeInfo,
Builds a version of s with all the elements in this Subset deleted from it.
pub fn len_after_delete(&self) -> usize
pub fn len_after_delete(&self) -> usize
The length of the resulting sequence after deleting this subset. A
convenience alias for self.count(CountMatcher::Zero) to reduce
thinking about what that means in the cases where the length after
delete is what you want to know.
self.delete_from_string(s).len() = self.len(s.len())
pub fn count(&self, matcher: CountMatcher) -> usize
pub fn count(&self, matcher: CountMatcher) -> usize
Count the total length of all the segments matching matcher.
pub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Determine whether the subset is empty. In this case deleting it would do nothing.
pub fn union(&self, other: &Subset) -> Subset
pub fn union(&self, other: &Subset) -> Subset
Compute the union of two subsets. The count of an element in the result is the sum of the counts in the inputs.
pub fn subtract(&self, other: &Subset) -> Subset
pub fn subtract(&self, other: &Subset) -> Subset
Compute the difference of two subsets. The count of an element in the result is the subtraction of the counts of other from self.
pub fn bitxor(&self, other: &Subset) -> Subset
pub fn bitxor(&self, other: &Subset) -> Subset
Compute the bitwise xor of two subsets, useful as a reversible difference. The count of an element in the result is the bitwise xor of the counts of the inputs. Unchanged segments will be 0.
This works like set symmetric difference when all counts are 0 or 1 but it extends nicely to the case of larger counts.
pub fn transform_expand(&self, other: &Subset) -> Subset
pub fn transform_expand(&self, other: &Subset) -> Subset
Transform through coordinate transform represented by other. The equation satisfied is as follows:
s1 = other.delete_from_string(s0)
s2 = self.delete_from_string(s1)
element in self.transform_expand(other).delete_from_string(s0) if (not in s1) or in s2
pub fn transform_union(&self, other: &Subset) -> Subset
pub fn transform_union(&self, other: &Subset) -> Subset
The same as taking transform_expand and then unioning with other.
pub fn transform_shrink(&self, other: &Subset) -> Subset
pub fn transform_shrink(&self, other: &Subset) -> Subset
Transform subset through other coordinate transform, shrinking. The following equation is satisfied:
C = A.transform_expand(B)
B.transform_shrink(C).delete_from_string(C.delete_from_string(s)) = A.delete_from_string(B.delete_from_string(s))
pub fn range_iter(&self, matcher: CountMatcher) -> RangeIter<'_> ⓘ
pub fn range_iter(&self, matcher: CountMatcher) -> RangeIter<'_> ⓘ
Return an iterator over the ranges with a count matching the matcher.
These will often be easier to work with than raw segments.
pub fn complement_iter(&self) -> RangeIter<'_> ⓘ
pub fn complement_iter(&self) -> RangeIter<'_> ⓘ
Convenience alias for self.range_iter(CountMatcher::Zero).
Semantically iterates the ranges of the complement of this Subset.
pub fn zip<'a>(&'a self, other: &'a Subset) -> ZipIter<'a> ⓘ
pub fn zip<'a>(&'a self, other: &'a Subset) -> ZipIter<'a> ⓘ
Return an iterator over ZipSegments where each ZipSegment contains
the count for both self and other in that range. The two Subsets
must have the same total length.
Each returned ZipSegment will differ in at least one count.
pub fn complement(&self) -> Subset
pub fn complement(&self) -> Subset
Find the complement of this Subset. Every 0-count element will have a count of 1 and every non-zero element will have a count of 0.
pub fn mapper(&self, matcher: CountMatcher) -> Mapper<'_>
pub fn mapper(&self, matcher: CountMatcher) -> Mapper<'_>
Return a Mapper that can be use to map coordinates in the document to coordinates
in this Subset, but only in non-decreasing order for performance reasons.
Trait Implementations§
§impl<'de> Deserialize<'de> for Subset
impl<'de> Deserialize<'de> for Subset
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Subset, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Subset, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Serialize for Subset
impl Serialize for Subset
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Subset
impl StructuralPartialEq for Subset
Auto Trait Implementations§
impl Freeze for Subset
impl RefUnwindSafe for Subset
impl Send for Subset
impl Sync for Subset
impl Unpin for Subset
impl UnsafeUnpin for Subset
impl UnwindSafe for Subset
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more