[−][src]Struct gf::support::bitvec::BitVec
Growable bit vector.
Total order
Bit vectors have total order implemented as shortlex order: if two vectors differ in length, the shorter one is less; otherwise, two vectors of equal length compare lexicographically (or, equivalently, as unsigned integers).
Implementations
impl BitVec
[src]
pub fn new() -> Self
[src]
Create an empty vector.
pub fn new_all_zeros(bit_len: usize) -> Self
[src]
Create an all-zero vector of given length.
pub fn new_concat<I>(parts: I) -> Self where
I: IntoIterator<Item = BitVec>,
[src]
I: IntoIterator<Item = BitVec>,
Create a vector as a concatenation of some parts.
pub fn with_capacity(bit_capacity: usize) -> Self
[src]
Create an empty vector with preallocated capacity.
pub fn from_byte_slice(slice: &[u8], endianness: Endianness) -> Self
[src]
Create a vector from bytes with given endianness.
Example
assert_eq!(BitVec::from_byte_slice(&[0x12, 0x34], Endianness::Little), 0x3412u16.into()); assert_eq!(BitVec::from_byte_slice(&[0x12, 0x34], Endianness::Big), 0x1234u16.into());
pub fn from_byte_slice_prefix(
slice: &[u8],
endianness: Endianness,
bit_len: usize
) -> Self
[src]
slice: &[u8],
endianness: Endianness,
bit_len: usize
) -> Self
Create a vector from a bit prefix of bytes with given endianness.
Errors
- Panics if the slice is shorter than the prefix length.
pub fn from_str(src: &str) -> Self
[src]
Convert a string slice to a little endian bit vector of its UTF-8 bytes.
pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseBitVecError>
[src]
Convert a string slice in a given base to a bit vector.
The resulting vector will have no leading zero bits, meaning that it can be empty if the input is zero.
Errors
- Panics if
radix
is not in the range from 2 to 36.
Example
assert_eq!(BitVec::from_str_radix("C001a1D3", 16), Ok(BitVec::from(0xC001_A1D3u32))); assert_eq!(BitVec::from_str_radix("011010001", 2), Ok(BitVec::from(0xD1u8))); assert_eq!(BitVec::from_str_radix("0", 10), Ok(BitVec::new()));
pub fn is_empty(&self) -> bool
[src]
Return whether the vector is empty.
pub fn len(&self) -> usize
[src]
Return bit length of the vector.
pub fn is_all_zeros(&self) -> bool
[src]
Check whether the vector has no set bits, i.e. is either empty or has zero value.
pub fn get(&self, bit_index: usize) -> bool
[src]
pub fn get_slice<R: RangeBounds<usize>>(&self, bit_range: R) -> BitSlice<'_>
[src]
pub fn set(&mut self, bit_index: usize, value: bool)
[src]
pub fn push(&mut self, value: bool)
[src]
Push a bit at the end of the vector.
pub fn append(&mut self, src: &Self)
[src]
Append a vector at the end of this one.
pub fn as_bit_slice(&self) -> BitSlice<'_>
[src]
Borrow the vector as an immutable bit slice.
pub fn as_byte_slice(&self) -> &[u8]
[src]
Borrow the vector as an immutable byte slice in little endian order.
The slice may have extra zero bits at the end, padding it up to a whole byte.
pub fn to_byte_vec(&self, endianness: Endianness) -> Cow<'_, [u8]>
[src]
Convert the vector to a byte vector with given endianness.
The vector may have extra zero bits at the end, padding it up to a whole byte.
pub fn as_str(&self) -> Result<&str, Utf8Error>
[src]
Borrow the vector as a string slice.
pub fn cast_into<T: CastFromBitVec>(self) -> Result<T, CastFromBitVecError>
[src]
Cast the vector into an integer type.
pub fn resize(&mut self, new_bit_len: usize, signedness: Signedness)
[src]
Truncate or extend the vector in place using given signedness.
pub fn resized(&self, new_bit_len: usize, signedness: Signedness) -> Self
[src]
Return a truncated or extended vector using given signedness.
pub fn truncate(&mut self, min_bit_len: usize, signedness: Signedness)
[src]
Remove duplicate leading bits in place using given signedness, stopping
when length becomes less than or equal to min_bit_len
.
The resulting vector will be empty if the original vector had only zero bits.
pub fn limbs<'a>(&'a self) -> impl Iterator<Item = u128> + 'a
[src]
Return an iterator over the 128-bit limbs of the vector in little endian order.
Unused bits in the most significant limb are always zero.
pub fn limbs_rev<'a>(&'a self) -> impl Iterator<Item = u128> + 'a
[src]
Return an iterator over the 128-bit limbs of the vector in big endian order.
Unused bits in the most significant limb are always zero.
pub fn from_big_int(src: &BigInt, len: usize) -> Self
[src]
Convert from num_bigint::BigInt
, resizing to the given number of bits.
pub fn from_big_uint(src: &BigUint, len: usize) -> Self
[src]
Convert from num_bigint::BigUint
, resizing to the giving number of
bits.
pub fn from_big_uint_shortest(src: &BigUint) -> Self
[src]
Convert from num_bigint::BigUint
, using the minimum possible number of
bits.
This method returns an empty vector when src
is zero.
pub fn to_big_int(&self) -> BigInt
[src]
Convert to num_bigint::BigInt
, treating the value as signed.
pub fn to_big_uint(&self) -> BigUint
[src]
Convert to num_bigint::BigUint
, treating the value as unsigned.
Trait Implementations
impl Binary for BitVec
[src]
impl BitSeq for BitVec
[src]
fn bit_len(&self) -> usize
[src]
fn get_bit(&self, bit_index: usize) -> bool
[src]
fn lsb(&self) -> Option<bool>
[src]
fn msb(&self) -> Option<bool>
[src]
impl BitSeqMut for BitVec
[src]
impl Clone for BitVec
[src]
impl ConstSpaceState<BitVec, FlatLattice<BitVec>> for ConcreteSpaceState
[src]
fn load(
&mut self,
span: SpaceSpan<BitVec>
) -> (FlatLattice<BitVec>, FlatLattice<BitVec>)
[src]
&mut self,
span: SpaceSpan<BitVec>
) -> (FlatLattice<BitVec>, FlatLattice<BitVec>)
fn load_result(&mut self, span: SpaceSpan<A>) -> Result<V, V>
[src]
impl ConstSpaceState<BitVec, FlatLattice<Expr>> for SymbolicSpaceState
[src]
fn load(
&mut self,
span: SpaceSpan<BitVec>
) -> (FlatLattice<Expr>, FlatLattice<Expr>)
[src]
&mut self,
span: SpaceSpan<BitVec>
) -> (FlatLattice<Expr>, FlatLattice<Expr>)
fn load_result(&mut self, span: SpaceSpan<A>) -> Result<V, V>
[src]
impl Debug for BitVec
[src]
impl Default for BitVec
[src]
impl Display for BitVec
[src]
impl Eq for BitVec
[src]
impl Extend<bool> for BitVec
[src]
fn extend<I: IntoIterator<Item = bool>>(&mut self, iter: I)
[src]
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl Extend<u128> for BitVec
[src]
fn extend<I: IntoIterator<Item = u128>>(&mut self, iter: I)
[src]
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl Extend<u16> for BitVec
[src]
fn extend<I: IntoIterator<Item = u16>>(&mut self, iter: I)
[src]
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl Extend<u32> for BitVec
[src]
fn extend<I: IntoIterator<Item = u32>>(&mut self, iter: I)
[src]
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl Extend<u64> for BitVec
[src]
fn extend<I: IntoIterator<Item = u64>>(&mut self, iter: I)
[src]
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl Extend<u8> for BitVec
[src]
fn extend<I: IntoIterator<Item = u8>>(&mut self, iter: I)
[src]
fn extend_one(&mut self, item: A)
[src]
fn extend_reserve(&mut self, additional: usize)
[src]
impl<'a> From<BitSlice<'a>> for BitVec
[src]
impl From<bool> for BitVec
[src]
impl From<i128> for BitVec
[src]
impl From<i16> for BitVec
[src]
impl From<i32> for BitVec
[src]
impl From<i64> for BitVec
[src]
impl From<i8> for BitVec
[src]
impl From<u128> for BitVec
[src]
impl From<u16> for BitVec
[src]
impl From<u32> for BitVec
[src]
impl From<u64> for BitVec
[src]
impl From<u8> for BitVec
[src]
impl FromIterator<bool> for BitVec
[src]
fn from_iter<I: IntoIterator<Item = bool>>(iter: I) -> Self
[src]
impl FromIterator<u128> for BitVec
[src]
fn from_iter<I: IntoIterator<Item = u128>>(iter: I) -> Self
[src]
impl FromIterator<u16> for BitVec
[src]
fn from_iter<I: IntoIterator<Item = u16>>(iter: I) -> Self
[src]
impl FromIterator<u32> for BitVec
[src]
fn from_iter<I: IntoIterator<Item = u32>>(iter: I) -> Self
[src]
impl FromIterator<u64> for BitVec
[src]
fn from_iter<I: IntoIterator<Item = u64>>(iter: I) -> Self
[src]
impl FromIterator<u8> for BitVec
[src]
fn from_iter<I: IntoIterator<Item = u8>>(iter: I) -> Self
[src]
impl Hash for BitVec
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Index<usize> for BitVec
[src]
type Output = bool
The returned type after indexing.
fn index(&self, index: usize) -> &Self::Output
[src]
impl LowerHex for BitVec
[src]
impl Ord for BitVec
[src]
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<BitVec> for BitVec
[src]
impl PartialOrd<BitVec> for BitVec
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl SpaceState<BitVec, FlatLattice<BitVec>> for ConcreteSpaceState
[src]
fn store(
&mut self,
span: SpaceSpan<BitVec>,
value: FlatLattice<BitVec>
) -> (Option<()>, FlatLattice<BitVec>)
[src]
&mut self,
span: SpaceSpan<BitVec>,
value: FlatLattice<BitVec>
) -> (Option<()>, FlatLattice<BitVec>)
fn store_result(
&mut self,
span: SpaceSpan<A>,
value: V
) -> Result<Option<()>, V>
[src]
&mut self,
span: SpaceSpan<A>,
value: V
) -> Result<Option<()>, V>
impl SpaceState<BitVec, FlatLattice<Expr>> for SymbolicSpaceState
[src]
fn store(
&mut self,
span: SpaceSpan<BitVec>,
value: FlatLattice<Expr>
) -> (Option<()>, FlatLattice<Expr>)
[src]
&mut self,
span: SpaceSpan<BitVec>,
value: FlatLattice<Expr>
) -> (Option<()>, FlatLattice<Expr>)
fn store_result(
&mut self,
span: SpaceSpan<A>,
value: V
) -> Result<Option<()>, V>
[src]
&mut self,
span: SpaceSpan<A>,
value: V
) -> Result<Option<()>, V>
impl ToBigInt for BitVec
[src]
impl ToBigUint for BitVec
[src]
fn to_biguint(&self) -> Option<BigUint>
[src]
impl TryFrom<BitVec> for bool
[src]
type Error = TryFromBitVecError
The type returned in the event of a conversion error.
fn try_from(src: BitVec) -> Result<Self, Self::Error>
[src]
impl TryFrom<BitVec> for i8
[src]
type Error = TryFromBitVecError
The type returned in the event of a conversion error.
fn try_from(src: BitVec) -> Result<Self, Self::Error>
[src]
impl TryFrom<BitVec> for u128
[src]
type Error = TryFromBitVecError
The type returned in the event of a conversion error.
fn try_from(src: BitVec) -> Result<Self, Self::Error>
[src]
impl TryFrom<BitVec> for i16
[src]
type Error = TryFromBitVecError
The type returned in the event of a conversion error.
fn try_from(src: BitVec) -> Result<Self, Self::Error>
[src]
impl TryFrom<BitVec> for i32
[src]
type Error = TryFromBitVecError
The type returned in the event of a conversion error.
fn try_from(src: BitVec) -> Result<Self, Self::Error>
[src]
impl TryFrom<BitVec> for i64
[src]
type Error = TryFromBitVecError
The type returned in the event of a conversion error.
fn try_from(src: BitVec) -> Result<Self, Self::Error>
[src]
impl TryFrom<BitVec> for i128
[src]
type Error = TryFromBitVecError
The type returned in the event of a conversion error.
fn try_from(src: BitVec) -> Result<Self, Self::Error>
[src]
impl TryFrom<BitVec> for u8
[src]
type Error = TryFromBitVecError
The type returned in the event of a conversion error.
fn try_from(src: BitVec) -> Result<Self, Self::Error>
[src]
impl TryFrom<BitVec> for u16
[src]
type Error = TryFromBitVecError
The type returned in the event of a conversion error.
fn try_from(src: BitVec) -> Result<Self, Self::Error>
[src]
impl TryFrom<BitVec> for u32
[src]
type Error = TryFromBitVecError
The type returned in the event of a conversion error.
fn try_from(src: BitVec) -> Result<Self, Self::Error>
[src]
impl TryFrom<BitVec> for u64
[src]
type Error = TryFromBitVecError
The type returned in the event of a conversion error.
fn try_from(src: BitVec) -> Result<Self, Self::Error>
[src]
impl UpperHex for BitVec
[src]
Auto Trait Implementations
impl RefUnwindSafe for BitVec
impl Send for BitVec
impl Sync for BitVec
impl Unpin for BitVec
impl UnwindSafe for BitVec
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,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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.
pub 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>,