Enum bellframe::Parity [−][src]
#[repr(u8)] pub enum Parity { Even, Odd, }
Expand description
Data type representing the parity of a Row
. To generate these, you probably want to use
[RowTrait::parity
]. Note that [RowTrait::parity
] always performs a heap allocation and is
linear-time in the [Stage
] of the Row
. If you are using Parity
s as optimisations
within hot code I would recommend computing them upfront on your input Row
s and then
tracking them by hand, probably using the *
operator.
Note that it would be quite cheap for Row
s to track their Parity
all the time, but that
would result in less-than ideal data layouts and doesn’t fit with the ‘only pay for what you
use’ design goal of this library.
Variants
A given Row
requires an even number of swap
s to return to
rounds
. This is also often called in course or positive. The
parity of rounds
on every [Stage
].
A given Row
requires an odd number of swap
s to return to
rounds
. This is also often called out of course or negative.
Implementations
Maps true
to Parity::Even
and false
to Parity::Odd
. On most machines, this
will not actually do anything and be removed by the compiler.
Returns the Parity
of a given number.
Returns the Parity
of a given number.
Returns the Parity
of a given number.
Trait Implementations
‘Multiply’ two Parity
s together (this corresponds to xor/uncarried addition where
Even
is 0
and Odd
is 1
). Also, if you have a Row
r1
with Parity
p1
and
another Row
r2
with Parity
p2
then (r1 * r2).parity()
will always equal p1 * p2
. Thus, this can be used to convert calls to [RowTrait::parity
] into an extremely
cheap (likely single-cycle) update function.
type Output = Self
type Output = Self
The resulting type after applying the *
operator.
Auto Trait Implementations
impl RefUnwindSafe for Parity
impl UnwindSafe for Parity
Blanket Implementations
Mutably borrows from an owned value. Read more