[][src]Struct cv::BitArray

#[repr(align(64))]pub struct BitArray<const B: usize> {
    pub bytes: [u8; B],
}

A constant sized array of bits. B defines the number of bytes. This has an alignment of 64 to maximize the efficiency of SIMD operations. It will automatically utilize SIMD at runtime where possible.

Fields

bytes: [u8; B]

Implementations

impl<const B: usize> BitArray<B>[src]

pub fn new(bytes: [u8; B]) -> BitArray<B>[src]

Create a new BitArray.

use bitarray::BitArray;
let array = BitArray::new([0]);
assert_eq!(*array.bytes(), [0]);

pub fn zeros() -> BitArray<B>[src]

Create a new BitArray with all zeros.

use bitarray::BitArray;
let array = BitArray::zeros();
assert_eq!(array, BitArray::new([0]));
assert_eq!(*array, [0]);

pub fn bytes(&self) -> &[u8; B][src]

Retrieve the byte array of a BitArray.

use bitarray::BitArray;
let array = BitArray::new([1, 2]);
assert_eq!(*array, [1, 2]);

pub fn bytes_mut(&mut self) -> &mut [u8; B][src]

Retrieve the mutable byte array of a BitArray.

use bitarray::BitArray;
let mut array = BitArray::new([1, 2]);
array.bytes_mut()[0] = 3;
assert_eq!(*array, [3, 2]);

pub fn weight(&self) -> usize[src]

Compute the hamming weight of the BitArray.

use bitarray::BitArray;
let array = BitArray::new([0xAA; 83]);
assert_eq!(array.weight(), 4 * 83);

pub fn distance(&self, other: &BitArray<B>) -> usize[src]

Compute the hamming distance to another BitArray.

use bitarray::BitArray;

// All the bits are different.
let a = BitArray::new([0xAA; 65]);
let b = BitArray::new([0x55; 65]);
assert_eq!(a.distance(&b), 8 * 65);

// None of the bits are different.
let a = BitArray::new([0xAA; 65]);
let b = BitArray::new([0xAA; 65]);
assert_eq!(a.distance(&b), 0);

Trait Implementations

impl<const B: usize> Clone for BitArray<B>[src]

impl<const B: usize> Debug for BitArray<B>[src]

impl<const B: usize> Deref for BitArray<B>[src]

use bitarray::BitArray;
let mut array = BitArray::new([1, 2]);
assert_eq!(*array, [1, 2]);

type Target = [u8; B]

The resulting type after dereferencing.

impl<const B: usize> DerefMut for BitArray<B>[src]

use bitarray::BitArray;
let mut array = BitArray::zeros();
array[0] = 1;
array[1] = 2;
assert_eq!(*array, [1, 2]);

impl<const B: usize> Eq for BitArray<B>[src]

impl<const B: usize> Hash for BitArray<B>[src]

impl<const B: usize> MetricPoint for BitArray<B>[src]

impl<const B: usize> PartialEq<BitArray<B>> for BitArray<B>[src]

Auto Trait Implementations

impl<const B: usize> RefUnwindSafe for BitArray<B>

impl<const B: usize> Send for BitArray<B>

impl<const B: usize> Sync for BitArray<B>

impl<const B: usize> Unpin for BitArray<B>

impl<const B: usize> UnwindSafe for BitArray<B>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,