pub struct BitArray { /* private fields */ }Expand description
A simple, fast array of bits, represented compactly by an array of ints internally.
@author Sean Owen
Implementations§
source§impl BitArray
impl BitArray
pub fn new() -> Self
pub fn with_size(size: usize) -> Self
pub fn getSize(&self) -> usize
pub fn getSizeInBytes(&self) -> usize
sourcepub fn getNextSet(&self, from: usize) -> usize
pub fn getNextSet(&self, from: usize) -> usize
@param from first bit to check @return index of first bit that is set, starting from the given index, or size if none are set at or beyond this given index @see #getNextUnset(int)
sourcepub fn getNextUnset(&self, from: usize) -> usize
pub fn getNextUnset(&self, from: usize) -> usize
@param from index to start looking for unset bit @return index of next unset bit, or {@code size} if none are unset until the end @see #getNextSet(int)
sourcepub fn setBulk(&mut self, i: usize, newBits: u32)
pub fn setBulk(&mut self, i: usize, newBits: u32)
Sets a block of 32 bits, starting at bit i.
@param i first bit to set @param newBits the new value of the next 32 bits. Note again that the least-significant bit corresponds to bit i, the next-least-significant to i+1, and so on.
sourcepub fn setRange(&mut self, start: usize, end: usize) -> Result<()>
pub fn setRange(&mut self, start: usize, end: usize) -> Result<()>
Sets a range of bits.
@param start start of range, inclusive. @param end end of range, exclusive
sourcepub fn isRange(&self, start: usize, end: usize, value: bool) -> Result<bool>
pub fn isRange(&self, start: usize, end: usize, value: bool) -> Result<bool>
Efficient method to check if a range of bits is set, or not set.
@param start start of range, inclusive. @param end end of range, exclusive @param value if true, checks that bits in range are set, otherwise checks that they are not set @return true iff all bits are set or not set in range, according to value argument @throws IllegalArgumentException if end is less than start or the range is not contained in the array
pub fn appendBit(&mut self, bit: bool)
sourcepub fn appendBits(&mut self, value: u32, num_bits: usize) -> Result<()>
pub fn appendBits(&mut self, value: u32, num_bits: usize) -> Result<()>
Appends the least-significant bits, from value, in order from most-significant to least-significant. For example, appending 6 bits from 0x000001E will append the bits 0, 1, 1, 1, 1, 0 in that order.
@param value {@code int} containing bits to append @param numBits bits from value to append
pub fn appendBitArray(&mut self, other: BitArray)
pub fn xor(&mut self, other: &BitArray) -> Result<()>
sourcepub fn toBytes(
&self,
bitOffset: usize,
array: &mut [u8],
offset: usize,
numBytes: usize
)
pub fn toBytes( &self, bitOffset: usize, array: &mut [u8], offset: usize, numBytes: usize )
@param bitOffset first bit to start writing @param array array to write into. Bytes are written most-significant byte first. This is the opposite of the internal representation, which is exposed by {@link #getBitArray()} @param offset position in array to start writing @param numBytes how many bytes to write
sourcepub fn getBitArray(&self) -> &[u32]
pub fn getBitArray(&self) -> &[u32]
@return underlying array of ints. The first element holds the first 32 bits, and the least significant bit is bit 0.
Trait Implementations§
source§impl PartialEq<BitArray> for BitArray
impl PartialEq<BitArray> for BitArray
impl Eq for BitArray
impl StructuralEq for BitArray
impl StructuralPartialEq for BitArray
Auto Trait Implementations§
impl RefUnwindSafe for BitArray
impl Send for BitArray
impl Sync for BitArray
impl Unpin for BitArray
impl UnwindSafe for BitArray
Blanket Implementations§
§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere Scheme: ApproxScheme,
§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere Dst: ApproxFrom<Src, Scheme>, Scheme: ApproxScheme,
§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
§impl<T> ConvUtil for T
impl<T> ConvUtil for T
§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, DefaultApprox>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where Self: Sized + ApproxInto<Dst, DefaultApprox>,
§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for Pwhere
R: Read + ReadEndian<P>,
P: Default,
impl<R, P> ReadPrimitive<R> for Pwhere R: Read + ReadEndian<P>, P: Default,
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.