Struct csx64::asm::binary_set::BinarySet [−][src]
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]
T: Into<Cow<'a, [u8]>>,
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<'_>ⓘ[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
impl RefUnwindSafe for BinarySet
impl Send for BinarySet
impl Sync for BinarySet
impl Unpin for BinarySet
impl UnwindSafe for BinarySet
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Az for T[src]
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<T> CheckedAs for T[src]
pub fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>, [src]
T: CheckedCast<Dst>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> OverflowingAs for T[src]
pub fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>, [src]
T: OverflowingCast<Dst>,
impl<T> SaturatingAs for T[src]
pub fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>, [src]
T: SaturatingCast<Dst>,
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, 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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> UnwrappedAs for T[src]
pub fn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>, [src]
T: UnwrappedCast<Dst>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> WrappingAs for T[src]
pub fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>, [src]
T: WrappingCast<Dst>,