Struct csx64::asm::binary_set::BinarySet[][src]

pub struct BinarySet { /* fields omitted */ }

An appendonly set of auto-overlapping binary slices.

In use, you add binary slices one at a time and it will attempt to create maximum overlapping. Currently, it only guarantees that supersets and subsets will overlap. It’s theoretically possible to do cross-slice overlapping, but this would be complex and expensive.

Slices added to the set are guaranteed to remain in insertion order. Moreover, the collection is appendonly, so once a slice is added it will remain at that index. Iteration is guaranteed to maintain this ordering.

Example

let mut b = BinarySet::new();
b.add([1, 2, 3, 4].as_ref());     // insert first slice (backed by itself)
b.add(vec![2, 3]);                // this one will overlap with previous
assert_eq!(b.bytes(), 6);         // 6 bytes are stored (slices)
assert_eq!(b.backing_bytes(), 4); // using only 4 backing bytes (internal data)

Implementations

impl BinarySet[src]

pub fn new() -> Self[src]

Constructs an empty set.

pub fn add<'a, T>(&mut self, value: T) -> usize where
    T: Into<Cow<'a, [u8]>>, 
[src]

Adds the specified slice to the set, panicing if empty. If an equivalent slice already exists, does nothing, otherwise adds value as a new slice. Returns the index of the pre-existing or new slice.

pub fn clear(&mut self)[src]

Removes all content from the set. This is the only non-appendonly operation, and is just meant to support resource reuse.

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

Gets the number of slices contained in the set.

pub fn is_empty(&self) -> bool[src]

Checks if the set is empty.

pub fn iter(&self) -> Iter<'_>

Notable traits for Iter<'a>

impl<'a> Iterator for Iter<'a> type Item = &'a [u8];
[src]

Iterates over all of the slices contained in the set.

pub fn get(&self, index: usize) -> Option<&[u8]>[src]

Gets the slice at the specified index, or None if out of bounds.

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

Gets the total number of bytes from distinct slices that were added to the set.

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

Gets the total number of bytes backing the stored slices. This is never larger than bytes.

pub fn decompose(self) -> (Vec<Vec<u8>>, Vec<SliceInfo>)[src]

Gets the collection of backing arrays and the collection of slices.

Trait Implementations

impl BinaryRead for BinarySet[src]

impl BinaryWrite for BinarySet[src]

impl Clone for BinarySet[src]

impl Debug for BinarySet[src]

impl Default for BinarySet[src]

Auto Trait Implementations

Blanket Implementations

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

impl<T> Az for T[src]

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

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

impl<T> CheckedAs for T[src]

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

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

impl<T> OverflowingAs for T[src]

impl<T> SaturatingAs for T[src]

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<T> UnwrappedAs for T[src]

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

impl<T> WrappingAs for T[src]