AssignmentBuilder

Struct AssignmentBuilder 

Source
pub struct AssignmentBuilder<X>
where X: Eq + Ord + Hash,
{ /* private fields */ }
Expand description

Intermediate structure for building assignments

  • In particular, this structrure will handle mass discounting
  • There is no constructor for AssignmentBuilder: methods init_assignment or init_assignment_with_capacity of trait Lattice are used
  • X : type of lattice element encoding

Implementations§

Source§

impl<X> AssignmentBuilder<X>
where X: Clone + Eq + Ord + Hash,

Source

pub unsafe fn unsafe_push( &mut self, element: X, weight: f64slx, ) -> Result<bool, String>

Unsafe push weighted element within assignment; weights smaller than ASSIGNMENT_EPSILON are discarded (result in Ok(false))

  • method is unsafe since there is no consistency check that the encoded element comes from the lattice of the builder
  • element: X : encoded element
  • weight: f64slx : weight of the element
  • Output:
    • true if weighted element is inserted
    • false if the weighted element is discarded
    • error if the weight is non finite or negative
Source

pub fn push( &mut self, safe_element: SafeElement<X>, weight: f64slx, ) -> Result<bool, String>

Push weighted element within assignment; weights smaller than ASSIGNMENT_EPSILON are discarded (result in Ok(false))

  • safe_element: SafeElement<X> : element with safe encoding
  • weight: f64slx : weight of the element
  • Output:
    • true if weighted element is inserted
    • false if the weighted element is discarded
    • error if the weight is non finite or negative
Source

pub fn remove( &mut self, safe_element: &SafeElement<X>, ) -> Result<Option<(SafeElement<X>, f64slx)>, String>

Remove element from assignment

  • safe_element: &SafeElement<X> : reference to lement to be removed
  • Output:
    • Some safe element Some(se) if element was found
    • None if element was not found
    • error in case of lattice hash mismatch
Source

pub fn prune<F>(&mut self, pruner: F)
where F: Fn(X, X) -> X,

Prune the assignment in order to reduce its size within acceptable range

  • pruner: F : prunning function
    • two weighted encoded elements (x,wx) and (y,wy) to be prunned will be replaced by (pruner(x,y),wx + wy)
  • F : type of pruner
  • Output: nothing
Source

pub fn scale(&mut self, scaler: f64slx) -> Result<(), String>

Scale the assignment weights

  • scaler: f64slx : scale multiplier
  • Output: nothing or error
Source

pub fn neg_shift(&mut self, neg_shift: f64slx) -> Result<(), String>

Shift the assignment negatively

  • Weighted element (x,w) is replaced by (x,w - neg_shift)
  • neg_shift: f64slx : negative shift
  • Output: nothing or error
Source

pub fn cumul_weight(&self) -> Result<f64slx, String>

Compute the cumulative weight of the assignment

  • Output: the cumulative weight or an error if some weights are non finite or negative
Source

pub fn normalize(&mut self) -> Result<(), String>

Normalize the assignment

  • Output: nothing or error
Source

pub fn map<F>(self, f: F) -> Result<Self, String>
where F: FnMut(f64slx) -> f64slx,

Map the assignment with a closure

  • f: F : a closure
  • F : type of the closure
  • Output: mapped assignment or an error if some mapped weights are non finite or negative
Source

pub fn self_map<F>(&mut self, f: F) -> Result<(), String>
where F: FnMut(f64slx) -> f64slx,

Self-map the assignment with a closure

  • f: F : a closure
  • F : type of the closure
  • Output: nothing or an error if some mapped weights are non finite or negative

Trait Implementations§

Source§

impl<X> Add<()> for AssignmentBuilder<X>
where X: Eq + Ord + Hash + Clone,

Source§

type Output = Assignment<X>

The resulting type after applying the + operator.
Source§

fn add(self, _: ()) -> Self::Output

Performs the + operation. Read more
Source§

impl<X, T> Add<(SafeElement<X>, T)> for AssignmentBuilder<X>
where X: Eq + Ord + Hash + Clone, T: Into<f64slx>,

Source§

type Output = AssignmentBuilder<X>

The resulting type after applying the + operator.
Source§

fn add(self, (x, w): (SafeElement<X>, T)) -> Self::Output

Performs the + operation. Read more
Source§

impl<X> Clone for AssignmentBuilder<X>
where X: Eq + Ord + Hash + Clone,

Source§

fn clone(&self) -> AssignmentBuilder<X>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<X> From<AssignmentBuilder<X>> for Assignment<X>
where X: Eq + Ord + Hash,

Source§

fn from(value: AssignmentBuilder<X>) -> Self

Converts to this type from the input type.
Source§

impl<X> HashedTypeDef for AssignmentBuilder<X>

Source§

const TYPE_HASH_NATIVE: u128 = 47_772_005_739_513_253_640_004_655_473_980_371_520u128

native hash computation
Source§

const TYPE_HASH_LE: u128 = _

hash encoded to little endianess
Source§

const TYPE_HASH_BE: u128 = _

hash encoded to big endianess
Source§

const UUID: Uuid = _

hash encoded to Uuid

Auto Trait Implementations§

§

impl<X> Freeze for AssignmentBuilder<X>

§

impl<X> RefUnwindSafe for AssignmentBuilder<X>
where X: RefUnwindSafe,

§

impl<X> Send for AssignmentBuilder<X>
where X: Send,

§

impl<X> Sync for AssignmentBuilder<X>
where X: Sync,

§

impl<X> Unpin for AssignmentBuilder<X>
where X: Unpin,

§

impl<X> UnwindSafe for AssignmentBuilder<X>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, O> FromSlx<T> for O
where T: SlxInto<O>,

Source§

fn from_slx(slx: T) -> O

Convert slx data into original data Read more
Source§

impl<T> HashedTypeMethods for T

Source§

fn type_hash_native<REF>() -> u128
where Self: HashedTypeDef<REF>,

return native type hash
Source§

fn type_hash_le<REF>() -> u128
where Self: HashedTypeDef<REF>,

return little endianess type hash
Source§

fn type_hash_be<REF>() -> u128
where Self: HashedTypeDef<REF>,

return big endianess type hash
Source§

fn type_uuid<REF>() -> Uuid
where Self: HashedTypeDef<REF>,

return uuid derived from type hash
Source§

fn type_uuid_hyphenated<REF>() -> String
where Self: HashedTypeDef<REF>,

return uuid hyphenated string
Source§

fn self_type_hash_native<REF>(&self) -> u128
where Self: HashedTypeDef<REF>,

return native type hash from instance
Source§

fn self_type_hash_le<REF>(&self) -> u128
where Self: HashedTypeDef<REF>,

return little endianess type hash from instance
Source§

fn self_type_hash_be<REF>(&self) -> u128
where Self: HashedTypeDef<REF>,

return big endianess type hash from instance
Source§

fn self_type_uuid<REF>(&self) -> Uuid
where Self: HashedTypeDef<REF>,

return type hash-derived uuid from instance
Source§

fn self_type_uuid_hyphenated<REF>(&self) -> String
where Self: HashedTypeDef<REF>,

return uuid hyphenated string from instance
Source§

impl<T> HashedTypeUuid for T

Source§

fn type_hash_native<REF>() -> u128
where Self: HashedTypeDef<REF>,

👎Deprecated since 0.1.2: please use HashedTypeMethods trait
return native type hash
Source§

fn type_hash_le<REF>() -> u128
where Self: HashedTypeDef<REF>,

👎Deprecated since 0.1.2: please use HashedTypeMethods trait
return little endianess type hash
Source§

fn type_hash_be<REF>() -> u128
where Self: HashedTypeDef<REF>,

👎Deprecated since 0.1.2: please use HashedTypeMethods trait
return big endianess type hash
Source§

fn type_uuid<REF>() -> Uuid
where Self: HashedTypeDef<REF>,

👎Deprecated since 0.1.2: please use HashedTypeMethods trait
return uuid derived from type hash
Source§

fn type_uuid_hyphenated<REF>() -> String
where Self: HashedTypeDef<REF>,

👎Deprecated since 0.1.2: please use HashedTypeMethods trait
return uuid hyphenated string
Source§

fn self_type_hash_native<REF>(&self) -> u128
where Self: HashedTypeDef<REF>,

👎Deprecated since 0.1.2: please use HashedTypeMethods trait
return native type hash from instance
Source§

fn self_type_hash_le<REF>(&self) -> u128
where Self: HashedTypeDef<REF>,

👎Deprecated since 0.1.2: please use HashedTypeMethods trait
return little endianess type hash from instance
Source§

fn self_type_hash_be<REF>(&self) -> u128
where Self: HashedTypeDef<REF>,

👎Deprecated since 0.1.2: please use HashedTypeMethods trait
return big endianess type hash from instance
Source§

fn self_type_uuid<REF>(&self) -> Uuid
where Self: HashedTypeDef<REF>,

👎Deprecated since 0.1.2: please use HashedTypeMethods trait
return type hash-derived uuid from instance
Source§

fn self_type_uuid_hyphenated<REF>(&self) -> String
where Self: HashedTypeDef<REF>,

👎Deprecated since 0.1.2: please use HashedTypeMethods trait
return uuid hyphenated string from instance
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, O> IntoSlx<T> for O
where T: SlxFrom<O>,

Source§

fn slx(self) -> T

Convert original data into slx data Read more
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V