Trait malachite_base::num::logic::traits::BitIterable
source · pub trait BitIterable {
type BitIterator: DoubleEndedIterator<Item = bool> + Index<u64>;
// Required method
fn bits(self) -> Self::BitIterator;
}
Expand description
Defines an iterator over a value’s bits.
Required Associated Types§
type BitIterator: DoubleEndedIterator<Item = bool> + Index<u64>
Required Methods§
sourcefn bits(self) -> Self::BitIterator
fn bits(self) -> Self::BitIterator
Returns a double-ended iterator over a number’s bits. When iterating in the forward direction, the iterator ends after the producing the number’s most-significant bit.
Implementations on Foreign Types§
source§impl BitIterable for i8
impl BitIterable for i8
source§fn bits(self) -> PrimitiveSignedBitIterator<u8, i8> ⓘ
fn bits(self) -> PrimitiveSignedBitIterator<u8, i8> ⓘ
Returns a double-ended iterator over the bits of a signed primitive integer.
The forward order is ascending, so that less significant bits appear first. There are no trailing sign bits going forward, or leading sign bits going backward.
If it’s necessary to get a [Vec
] of all the bits, consider using
to_bits_asc
or
to_bits_desc
instead.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
type BitIterator = PrimitiveSignedBitIterator<u8, i8>
source§impl BitIterable for i16
impl BitIterable for i16
source§fn bits(self) -> PrimitiveSignedBitIterator<u16, i16> ⓘ
fn bits(self) -> PrimitiveSignedBitIterator<u16, i16> ⓘ
Returns a double-ended iterator over the bits of a signed primitive integer.
The forward order is ascending, so that less significant bits appear first. There are no trailing sign bits going forward, or leading sign bits going backward.
If it’s necessary to get a [Vec
] of all the bits, consider using
to_bits_asc
or
to_bits_desc
instead.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
type BitIterator = PrimitiveSignedBitIterator<u16, i16>
source§impl BitIterable for i32
impl BitIterable for i32
source§fn bits(self) -> PrimitiveSignedBitIterator<u32, i32> ⓘ
fn bits(self) -> PrimitiveSignedBitIterator<u32, i32> ⓘ
Returns a double-ended iterator over the bits of a signed primitive integer.
The forward order is ascending, so that less significant bits appear first. There are no trailing sign bits going forward, or leading sign bits going backward.
If it’s necessary to get a [Vec
] of all the bits, consider using
to_bits_asc
or
to_bits_desc
instead.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
type BitIterator = PrimitiveSignedBitIterator<u32, i32>
source§impl BitIterable for i64
impl BitIterable for i64
source§fn bits(self) -> PrimitiveSignedBitIterator<u64, i64> ⓘ
fn bits(self) -> PrimitiveSignedBitIterator<u64, i64> ⓘ
Returns a double-ended iterator over the bits of a signed primitive integer.
The forward order is ascending, so that less significant bits appear first. There are no trailing sign bits going forward, or leading sign bits going backward.
If it’s necessary to get a [Vec
] of all the bits, consider using
to_bits_asc
or
to_bits_desc
instead.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
type BitIterator = PrimitiveSignedBitIterator<u64, i64>
source§impl BitIterable for i128
impl BitIterable for i128
source§fn bits(self) -> PrimitiveSignedBitIterator<u128, i128> ⓘ
fn bits(self) -> PrimitiveSignedBitIterator<u128, i128> ⓘ
Returns a double-ended iterator over the bits of a signed primitive integer.
The forward order is ascending, so that less significant bits appear first. There are no trailing sign bits going forward, or leading sign bits going backward.
If it’s necessary to get a [Vec
] of all the bits, consider using
to_bits_asc
or
to_bits_desc
instead.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
type BitIterator = PrimitiveSignedBitIterator<u128, i128>
source§impl BitIterable for isize
impl BitIterable for isize
source§fn bits(self) -> PrimitiveSignedBitIterator<usize, isize> ⓘ
fn bits(self) -> PrimitiveSignedBitIterator<usize, isize> ⓘ
Returns a double-ended iterator over the bits of a signed primitive integer.
The forward order is ascending, so that less significant bits appear first. There are no trailing sign bits going forward, or leading sign bits going backward.
If it’s necessary to get a [Vec
] of all the bits, consider using
to_bits_asc
or
to_bits_desc
instead.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
type BitIterator = PrimitiveSignedBitIterator<usize, isize>
source§impl BitIterable for u8
impl BitIterable for u8
source§fn bits(self) -> PrimitiveUnsignedBitIterator<u8> ⓘ
fn bits(self) -> PrimitiveUnsignedBitIterator<u8> ⓘ
Returns a double-ended iterator over the bits of an unsigned primitive integer.
The forward order is ascending, so that less significant bits appear first. There are no trailing false bits going forward, or leading falses going backward.
If it’s necessary to get a [Vec
] of all the bits, consider using
to_bits_asc
or
to_bits_desc
instead.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
type BitIterator = PrimitiveUnsignedBitIterator<u8>
source§impl BitIterable for u16
impl BitIterable for u16
source§fn bits(self) -> PrimitiveUnsignedBitIterator<u16> ⓘ
fn bits(self) -> PrimitiveUnsignedBitIterator<u16> ⓘ
Returns a double-ended iterator over the bits of an unsigned primitive integer.
The forward order is ascending, so that less significant bits appear first. There are no trailing false bits going forward, or leading falses going backward.
If it’s necessary to get a [Vec
] of all the bits, consider using
to_bits_asc
or
to_bits_desc
instead.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
type BitIterator = PrimitiveUnsignedBitIterator<u16>
source§impl BitIterable for u32
impl BitIterable for u32
source§fn bits(self) -> PrimitiveUnsignedBitIterator<u32> ⓘ
fn bits(self) -> PrimitiveUnsignedBitIterator<u32> ⓘ
Returns a double-ended iterator over the bits of an unsigned primitive integer.
The forward order is ascending, so that less significant bits appear first. There are no trailing false bits going forward, or leading falses going backward.
If it’s necessary to get a [Vec
] of all the bits, consider using
to_bits_asc
or
to_bits_desc
instead.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
type BitIterator = PrimitiveUnsignedBitIterator<u32>
source§impl BitIterable for u64
impl BitIterable for u64
source§fn bits(self) -> PrimitiveUnsignedBitIterator<u64> ⓘ
fn bits(self) -> PrimitiveUnsignedBitIterator<u64> ⓘ
Returns a double-ended iterator over the bits of an unsigned primitive integer.
The forward order is ascending, so that less significant bits appear first. There are no trailing false bits going forward, or leading falses going backward.
If it’s necessary to get a [Vec
] of all the bits, consider using
to_bits_asc
or
to_bits_desc
instead.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
type BitIterator = PrimitiveUnsignedBitIterator<u64>
source§impl BitIterable for u128
impl BitIterable for u128
source§fn bits(self) -> PrimitiveUnsignedBitIterator<u128> ⓘ
fn bits(self) -> PrimitiveUnsignedBitIterator<u128> ⓘ
Returns a double-ended iterator over the bits of an unsigned primitive integer.
The forward order is ascending, so that less significant bits appear first. There are no trailing false bits going forward, or leading falses going backward.
If it’s necessary to get a [Vec
] of all the bits, consider using
to_bits_asc
or
to_bits_desc
instead.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.
type BitIterator = PrimitiveUnsignedBitIterator<u128>
source§impl BitIterable for usize
impl BitIterable for usize
source§fn bits(self) -> PrimitiveUnsignedBitIterator<usize> ⓘ
fn bits(self) -> PrimitiveUnsignedBitIterator<usize> ⓘ
Returns a double-ended iterator over the bits of an unsigned primitive integer.
The forward order is ascending, so that less significant bits appear first. There are no trailing false bits going forward, or leading falses going backward.
If it’s necessary to get a [Vec
] of all the bits, consider using
to_bits_asc
or
to_bits_desc
instead.
§Worst-case complexity
Constant time and additional memory.
§Examples
See here.