[−][src]Struct ddo::core::utils::LexBitSet
A totally ordered Bitset wrapper. Useful to implement tie break mechanisms. This wrapper orders the bitsets according to the lexical order of their underlying bits.
Note:
This implementation uses the underlying words representation of the
bitsets to perform several comparisons at once. Hence, using a LexBitSet
should be more efficient than trying to establish the total ordering
yourself with a loop on the 1-bits of the two sets.
Example
let mut a = BitSet::new(5); let mut b = BitSet::new(5); a.set(2, true); // bits 0..2 match for a and b b.set(2, true); a.set(3, false); // a and b diverge on bit 3 b.set(3, true); // and a has a 0 bit in that pos a.set(4, true); // anything that remains after b.set(4, false); // the firs lexicographical difference is ignored assert!(LexBitSet(&a) < LexBitSet(&b));
Trait Implementations
impl<'a> Debug for LexBitSet<'a>
[src]
impl<'_> Eq for LexBitSet<'_>
[src]
Because LexBitSet
defines a total order, it makes sense to consider that
it also defines an equivalence relation. As such, it implements the standard
Eq
and PartialEq
traits.
impl<'_> Ord for LexBitSet<'_>
[src]
The LexBitSet
implements a total order on bitsets. As such, it must
implement the standard trait Ord
.
Note:
This implementation uses the underlying words representation of the
bitsets to perform several comparisons at once. Hence, using a LexBitSet
should be more efficient than trying to establish the total ordering
yourself with a loop on the 1-bits of the two sets.
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'_> PartialEq<LexBitSet<'_>> for LexBitSet<'_>
[src]
Having LexBitSet
to implement PartialEq
means that it at least defines
a partial equivalence relation.
impl<'_> PartialOrd<LexBitSet<'_>> for LexBitSet<'_>
[src]
Because it is a total order, LexBitSet
must also be a partial order.
Hence, it must implement the standard trait PartialOrd
.
Auto Trait Implementations
impl<'a> RefUnwindSafe for LexBitSet<'a>
impl<'a> Send for LexBitSet<'a>
impl<'a> Sync for LexBitSet<'a>
impl<'a> Unpin for LexBitSet<'a>
impl<'a> UnwindSafe for LexBitSet<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,