pub struct BitVec<B = Vec<usize>> { /* private fields */ }Expand description
A bit vector.
Instances can be created using new,
with_value, with the convenience macro
bit_vec!, or with a FromIterator
implementation.
See the module documentation for more details.
Implementations§
Source§impl<B> BitVec<B>
impl<B> BitVec<B>
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of bits in the bit vector.
This method is equivalent to BitLength::len, but it is provided to
reduce ambiguity in method resolution.
Sourcepub unsafe fn from_raw_parts(bits: B, len: usize) -> Self
pub unsafe fn from_raw_parts(bits: B, len: usize) -> Self
§Safety
len must be between 0 (included) and the number of
bits in bits (included).
pub fn into_raw_parts(self) -> (B, usize)
Source§impl BitVec<Vec<usize>>
impl BitVec<Vec<usize>>
Sourcepub fn with_value(len: usize, value: bool) -> Self
pub fn with_value(len: usize, value: bool) -> Self
Creates a new bit vector of length len initialized to value.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new zero-length bit vector of given capacity.
Note that the capacity will be rounded up to a multiple of the word size.
Trait Implementations§
Source§impl<B> AlignHash for BitVec<B>
impl<B> AlignHash for BitVec<B>
Source§fn align_hash(hasher: &mut impl Hasher, offset_of: &mut usize)
fn align_hash(hasher: &mut impl Hasher, offset_of: &mut usize)
hasher assuming to be positioned
at offset_of.Source§fn align_hash_val(&self, hasher: &mut impl Hasher, offset_of: &mut usize)
fn align_hash_val(&self, hasher: &mut impl Hasher, offset_of: &mut usize)
AlignHash::align_hash on a value.Source§impl<B: AsRef<[usize]>> BitCount for BitVec<B>
impl<B: AsRef<[usize]>> BitCount for BitVec<B>
Source§fn count_ones(&self) -> usize
fn count_ones(&self) -> usize
NumBits::num_ones
for constant-time version.Source§fn count_zeros(&self) -> usize
fn count_zeros(&self) -> usize
NumBits::num_zeros
for constant-time version.Source§impl<B> DeserInner for BitVec<B>
impl<B> DeserInner for BitVec<B>
Source§type DeserType<'__epserde_desertype> = BitVec<<B as DeserInner>::DeserType<'__epserde_desertype>>
type DeserType<'__epserde_desertype> = BitVec<<B as DeserInner>::DeserType<'__epserde_desertype>>
DeserType.Source§fn __check_covariance<'__long: '__short, '__short>(
proof: CovariantProof<Self::DeserType<'__long>>,
) -> CovariantProof<Self::DeserType<'__short>>
fn __check_covariance<'__long: '__short, '__short>( proof: CovariantProof<Self::DeserType<'__long>>, ) -> CovariantProof<Self::DeserType<'__short>>
Source§unsafe fn _deser_full_inner(
backend: &mut impl ReadWithPos,
) -> Result<Self, Error>
unsafe fn _deser_full_inner( backend: &mut impl ReadWithPos, ) -> Result<Self, Error>
Source§unsafe fn _deser_eps_inner<'deser_eps_inner_lifetime>(
backend: &mut SliceWithPos<'deser_eps_inner_lifetime>,
) -> Result<Self::DeserType<'deser_eps_inner_lifetime>, Error>
unsafe fn _deser_eps_inner<'deser_eps_inner_lifetime>( backend: &mut SliceWithPos<'deser_eps_inner_lifetime>, ) -> Result<Self::DeserType<'deser_eps_inner_lifetime>, Error>
Source§impl<'de, B> Deserialize<'de> for BitVec<B>where
B: Deserialize<'de>,
impl<'de, B> Deserialize<'de> for BitVec<B>where
B: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Extend<bool> for BitVec<Vec<usize>>
impl Extend<bool> for BitVec<Vec<usize>>
Source§fn extend<T>(&mut self, i: T)where
T: IntoIterator<Item = bool>,
fn extend<T>(&mut self, i: T)where
T: IntoIterator<Item = bool>,
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<'a, W: IntoAtomic> From<AtomicBitVec<&'a [<W as IntoAtomic>::AtomicType]>> for BitVec<&'a [W]>
impl<'a, W: IntoAtomic> From<AtomicBitVec<&'a [<W as IntoAtomic>::AtomicType]>> for BitVec<&'a [W]>
Source§fn from(value: AtomicBitVec<&'a [W::AtomicType]>) -> Self
fn from(value: AtomicBitVec<&'a [W::AtomicType]>) -> Self
Source§impl<'a, W: IntoAtomic> From<AtomicBitVec<&'a mut [<W as IntoAtomic>::AtomicType]>> for BitVec<&'a mut [W]>
impl<'a, W: IntoAtomic> From<AtomicBitVec<&'a mut [<W as IntoAtomic>::AtomicType]>> for BitVec<&'a mut [W]>
Source§fn from(value: AtomicBitVec<&'a mut [W::AtomicType]>) -> Self
fn from(value: AtomicBitVec<&'a mut [W::AtomicType]>) -> Self
Source§impl<W: IntoAtomic> From<AtomicBitVec<Box<[<W as IntoAtomic>::AtomicType]>>> for BitVec<Box<[W]>>
impl<W: IntoAtomic> From<AtomicBitVec<Box<[<W as IntoAtomic>::AtomicType]>>> for BitVec<Box<[W]>>
Source§fn from(value: AtomicBitVec<Box<[W::AtomicType]>>) -> Self
fn from(value: AtomicBitVec<Box<[W::AtomicType]>>) -> Self
Source§impl<W: IntoAtomic> From<AtomicBitVec<Box<[<W as IntoAtomic>::AtomicType]>>> for BitVec<Vec<W>>
impl<W: IntoAtomic> From<AtomicBitVec<Box<[<W as IntoAtomic>::AtomicType]>>> for BitVec<Vec<W>>
Source§fn from(value: AtomicBitVec<Box<[W::AtomicType]>>) -> Self
fn from(value: AtomicBitVec<Box<[W::AtomicType]>>) -> Self
Source§impl<W: IntoAtomic + Copy> From<BitVec<Box<[W]>>> for AtomicBitVec<Box<[W::AtomicType]>>
impl<W: IntoAtomic + Copy> From<BitVec<Box<[W]>>> for AtomicBitVec<Box<[W::AtomicType]>>
Source§impl<W: IntoAtomic> From<BitVec<Vec<W>>> for AtomicBitVec<Box<[W::AtomicType]>>
impl<W: IntoAtomic> From<BitVec<Vec<W>>> for AtomicBitVec<Box<[W::AtomicType]>>
Source§impl<B> MemDbgImpl for BitVec<B>
impl<B> MemDbgImpl for BitVec<B>
fn _mem_dbg_rec_on( &self, _memdbg_writer: &mut impl Write, _memdbg_total_size: usize, _memdbg_max_depth: usize, _memdbg_prefix: &mut String, _memdbg_is_last: bool, _memdbg_flags: DbgFlags, _memdbg_refs: &mut HashSet<usize>, ) -> Result
fn _mem_dbg_depth_on( &self, writer: &mut impl Write, total_size: usize, max_depth: usize, prefix: &mut String, field_name: Option<&str>, is_last: bool, padded_size: usize, flags: DbgFlags, dbg_refs: &mut HashSet<usize>, ) -> Result<(), Error>
Source§fn _mem_dbg_depth_on_impl(
&self,
writer: &mut impl Write,
total_size: usize,
max_depth: usize,
prefix: &mut String,
field_name: Option<&str>,
is_last: bool,
padded_size: usize,
flags: DbgFlags,
dbg_refs: &mut HashSet<usize>,
ref_display: RefDisplay,
) -> Result<(), Error>
fn _mem_dbg_depth_on_impl( &self, writer: &mut impl Write, total_size: usize, max_depth: usize, prefix: &mut String, field_name: Option<&str>, is_last: bool, padded_size: usize, flags: DbgFlags, dbg_refs: &mut HashSet<usize>, ref_display: RefDisplay, ) -> Result<(), Error>
Source§impl<B> MemSize for BitVec<B>
impl<B> MemSize for BitVec<B>
Source§impl<B> SerInner for BitVec<B>
impl<B> SerInner for BitVec<B>
Source§const IS_ZERO_COPY: bool
const IS_ZERO_COPY: bool
ZeroCopy type has this constant set to false
serialization will panic.Source§type SerType = BitVec<<B as SerInner>::SerType>
type SerType = BitVec<<B as SerInner>::SerType>
Self, but
in some cases, as for references to slices,
it is customized.Source§unsafe fn _ser_inner(&self, backend: &mut impl WriteWithNames) -> Result<()>
unsafe fn _ser_inner(&self, backend: &mut impl WriteWithNames) -> Result<()>
Source§impl<'a, W: IntoAtomic> TryFrom<BitVec<&'a [W]>> for AtomicBitVec<&'a [W::AtomicType]>
This conversion may fail if the alignment of W is not the same as
that of W::AtomicType.
impl<'a, W: IntoAtomic> TryFrom<BitVec<&'a [W]>> for AtomicBitVec<&'a [W::AtomicType]>
This conversion may fail if the alignment of W is not the same as
that of W::AtomicType.
Source§impl<'a, W: IntoAtomic> TryFrom<BitVec<&'a mut [W]>> for AtomicBitVec<&'a mut [W::AtomicType]>
This conversion may fail if the alignment of W is not the same as
that of W::AtomicType.
impl<'a, W: IntoAtomic> TryFrom<BitVec<&'a mut [W]>> for AtomicBitVec<&'a mut [W::AtomicType]>
This conversion may fail if the alignment of W is not the same as
that of W::AtomicType.
Source§impl<B> TypeHash for BitVec<B>
impl<B> TypeHash for BitVec<B>
Source§fn type_hash_val(&self, hasher: &mut impl Hasher)
fn type_hash_val(&self, hasher: &mut impl Hasher)
TypeHash::type_hash on a value.impl<B: Copy> Copy for BitVec<B>
impl<B: AsRef<[usize]>> Eq for BitVec<B>
Auto Trait Implementations§
impl<B> Freeze for BitVec<B>where
B: Freeze,
impl<B> RefUnwindSafe for BitVec<B>where
B: RefUnwindSafe,
impl<B> Send for BitVec<B>where
B: Send,
impl<B> Sync for BitVec<B>where
B: Sync,
impl<B> Unpin for BitVec<B>where
B: Unpin,
impl<B> UnsafeUnpin for BitVec<B>where
B: UnsafeUnpin,
impl<B> UnwindSafe for BitVec<B>where
B: UnwindSafe,
Blanket Implementations§
Source§impl<T> AtomicBitVecOps for T
impl<T> AtomicBitVecOps for T
Source§fn get(&self, index: usize, ordering: Ordering) -> bool
fn get(&self, index: usize, ordering: Ordering) -> bool
Source§fn set(&self, index: usize, value: bool, ordering: Ordering)
fn set(&self, index: usize, value: bool, ordering: Ordering)
Source§fn swap(&self, index: usize, value: bool, ordering: Ordering) -> bool
fn swap(&self, index: usize, value: bool, ordering: Ordering) -> bool
Source§unsafe fn get_unchecked(&self, index: usize, ordering: Ordering) -> bool
unsafe fn get_unchecked(&self, index: usize, ordering: Ordering) -> bool
Source§unsafe fn set_unchecked(&self, index: usize, value: bool, ordering: Ordering)
unsafe fn set_unchecked(&self, index: usize, value: bool, ordering: Ordering)
Source§unsafe fn swap_unchecked(
&self,
index: usize,
value: bool,
ordering: Ordering,
) -> bool
unsafe fn swap_unchecked( &self, index: usize, value: bool, ordering: Ordering, ) -> bool
Source§fn par_fill(&mut self, value: bool, ordering: Ordering)
fn par_fill(&mut self, value: bool, ordering: Ordering)
rayon only.Source§fn par_reset(&mut self, ordering: Ordering)
fn par_reset(&mut self, ordering: Ordering)
rayon only.Source§fn par_flip(&mut self, ordering: Ordering)
fn par_flip(&mut self, ordering: Ordering)
rayon only.Source§fn par_count_ones(&self) -> usize
fn par_count_ones(&self) -> usize
rayon only.BitCount::count_ones.Source§fn iter(&self) -> AtomicBitIter<'_, [AtomicUsize]> ⓘ
fn iter(&self) -> AtomicBitIter<'_, [AtomicUsize]> ⓘ
Source§impl<T> BitVecOps for T
impl<T> BitVecOps for T
Source§unsafe fn get_unchecked(&self, index: usize) -> bool
unsafe fn get_unchecked(&self, index: usize) -> bool
Source§fn iter(&self) -> BitIter<'_, [usize]> ⓘ
fn iter(&self) -> BitIter<'_, [usize]> ⓘ
Source§fn iter_ones(&self) -> OnesIter<'_, [usize]> ⓘ
fn iter_ones(&self) -> OnesIter<'_, [usize]> ⓘ
Source§fn iter_zeros(&self) -> ZerosIter<'_, [usize]> ⓘ
fn iter_zeros(&self) -> ZerosIter<'_, [usize]> ⓘ
Source§fn par_count_ones(&self) -> usize
fn par_count_ones(&self) -> usize
rayon only.BitCount::count_ones.Source§impl<T> BitVecOpsMut for T
impl<T> BitVecOpsMut for T
Source§unsafe fn set_unchecked(&mut self, index: usize, value: bool)
unsafe fn set_unchecked(&mut self, index: usize, value: bool)
Source§fn par_fill(&mut self, value: bool)
fn par_fill(&mut self, value: bool)
rayon only.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, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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 moreSource§impl<T> MemDbg for Twhere
T: MemDbgImpl,
impl<T> MemDbg for Twhere
T: MemDbgImpl,
Source§fn mem_dbg(&self, flags: DbgFlags) -> Result<(), Error>
fn mem_dbg(&self, flags: DbgFlags) -> Result<(), Error>
std only.Source§fn mem_dbg_on(
&self,
writer: &mut impl Write,
flags: DbgFlags,
) -> Result<(), Error>
fn mem_dbg_on( &self, writer: &mut impl Write, flags: DbgFlags, ) -> Result<(), Error>
core::fmt::Write debug info about the structure memory
usage, expanding all levels of nested structures.Source§fn mem_dbg_depth(&self, max_depth: usize, flags: DbgFlags) -> Result<(), Error>
fn mem_dbg_depth(&self, max_depth: usize, flags: DbgFlags) -> Result<(), Error>
std only.mem_dbg, but expanding only up to max_depth
levels of nested structures.Source§fn mem_dbg_depth_on(
&self,
writer: &mut impl Write,
max_depth: usize,
flags: DbgFlags,
) -> Result<(), Error>
fn mem_dbg_depth_on( &self, writer: &mut impl Write, max_depth: usize, flags: DbgFlags, ) -> Result<(), Error>
core::fmt::Write debug info about the structure memory
usage as mem_dbg_on, but expanding only up to
max_depth levels of nested structures.