pub struct AssignmentBuilder<X>{ /* private fields */ }Expand description
Intermediate structure for building assignments
- In particular, this structrure will handle mass discounting
- There is no constructor for
AssignmentBuilder: methodsinit_assignmentorinit_assignment_with_capacityof traitLatticeare used X: type of lattice element encoding
Implementations§
Source§impl<X> AssignmentBuilder<X>
impl<X> AssignmentBuilder<X>
Sourcepub unsafe fn unsafe_push(
&mut self,
element: X,
weight: f64slx,
) -> Result<bool, String>
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 elementweight: f64slx: weight of the element- Output:
trueif weighted element is insertedfalseif the weighted element is discarded- error if the weight is non finite or negative
Sourcepub fn push(
&mut self,
safe_element: SafeElement<X>,
weight: f64slx,
) -> Result<bool, String>
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 encodingweight: f64slx: weight of the element- Output:
trueif weighted element is insertedfalseif the weighted element is discarded- error if the weight is non finite or negative
Sourcepub fn remove(
&mut self,
safe_element: &SafeElement<X>,
) -> Result<Option<(SafeElement<X>, f64slx)>, String>
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 Noneif element was not found- error in case of lattice hash mismatch
- Some safe element
Sourcepub fn prune<F>(&mut self, pruner: F)where
F: Fn(X, X) -> X,
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)
- two weighted encoded elements
F: type of pruner- Output: nothing
Sourcepub fn scale(&mut self, scaler: f64slx) -> Result<(), String>
pub fn scale(&mut self, scaler: f64slx) -> Result<(), String>
Scale the assignment weights
scaler: f64slx: scale multiplier- Output: nothing or error
Sourcepub fn neg_shift(&mut self, neg_shift: f64slx) -> Result<(), String>
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
Sourcepub fn cumul_weight(&self) -> Result<f64slx, String>
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
Sourcepub fn normalize(&mut self) -> Result<(), String>
pub fn normalize(&mut self) -> Result<(), String>
Normalize the assignment
- Output: nothing or error
Trait Implementations§
Source§impl<X> Add<()> for AssignmentBuilder<X>
impl<X> Add<()> for AssignmentBuilder<X>
Source§impl<X, T> Add<(SafeElement<X>, T)> for AssignmentBuilder<X>
impl<X, T> Add<(SafeElement<X>, T)> for AssignmentBuilder<X>
Source§type Output = AssignmentBuilder<X>
type Output = AssignmentBuilder<X>
The resulting type after applying the
+ operator.Source§impl<X> Clone for AssignmentBuilder<X>
impl<X> Clone for AssignmentBuilder<X>
Source§fn clone(&self) -> AssignmentBuilder<X>
fn clone(&self) -> AssignmentBuilder<X>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<X> From<AssignmentBuilder<X>> for Assignment<X>
impl<X> From<AssignmentBuilder<X>> for Assignment<X>
Source§fn from(value: AssignmentBuilder<X>) -> Self
fn from(value: AssignmentBuilder<X>) -> Self
Converts to this type from the input type.
Source§impl<X> HashedTypeDef for AssignmentBuilder<X>
impl<X> HashedTypeDef for AssignmentBuilder<X>
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>where
X: UnwindSafe + RefUnwindSafe,
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> HashedTypeMethods for T
impl<T> HashedTypeMethods for T
Source§fn type_hash_native<REF>() -> u128where
Self: HashedTypeDef<REF>,
fn type_hash_native<REF>() -> u128where
Self: HashedTypeDef<REF>,
return native type hash
Source§fn type_hash_le<REF>() -> u128where
Self: HashedTypeDef<REF>,
fn type_hash_le<REF>() -> u128where
Self: HashedTypeDef<REF>,
return little endianess type hash
Source§fn type_hash_be<REF>() -> u128where
Self: HashedTypeDef<REF>,
fn type_hash_be<REF>() -> u128where
Self: HashedTypeDef<REF>,
return big endianess type hash
Source§fn type_uuid<REF>() -> Uuidwhere
Self: HashedTypeDef<REF>,
fn type_uuid<REF>() -> Uuidwhere
Self: HashedTypeDef<REF>,
return uuid derived from type hash
Source§fn type_uuid_hyphenated<REF>() -> Stringwhere
Self: HashedTypeDef<REF>,
fn type_uuid_hyphenated<REF>() -> Stringwhere
Self: HashedTypeDef<REF>,
return uuid hyphenated string
Source§fn self_type_hash_native<REF>(&self) -> u128where
Self: HashedTypeDef<REF>,
fn self_type_hash_native<REF>(&self) -> u128where
Self: HashedTypeDef<REF>,
return native type hash from instance
Source§fn self_type_hash_le<REF>(&self) -> u128where
Self: HashedTypeDef<REF>,
fn self_type_hash_le<REF>(&self) -> u128where
Self: HashedTypeDef<REF>,
return little endianess type hash from instance
Source§fn self_type_hash_be<REF>(&self) -> u128where
Self: HashedTypeDef<REF>,
fn self_type_hash_be<REF>(&self) -> u128where
Self: HashedTypeDef<REF>,
return big endianess type hash from instance
Source§fn self_type_uuid<REF>(&self) -> Uuidwhere
Self: HashedTypeDef<REF>,
fn self_type_uuid<REF>(&self) -> Uuidwhere
Self: HashedTypeDef<REF>,
return type hash-derived uuid from instance
Source§fn self_type_uuid_hyphenated<REF>(&self) -> Stringwhere
Self: HashedTypeDef<REF>,
fn self_type_uuid_hyphenated<REF>(&self) -> Stringwhere
Self: HashedTypeDef<REF>,
return uuid hyphenated string from instance
Source§impl<T> HashedTypeUuid for T
impl<T> HashedTypeUuid for T
Source§fn type_hash_native<REF>() -> u128where
Self: HashedTypeDef<REF>,
fn type_hash_native<REF>() -> u128where
Self: HashedTypeDef<REF>,
👎Deprecated since 0.1.2: please use
HashedTypeMethods traitreturn native type hash
Source§fn type_hash_le<REF>() -> u128where
Self: HashedTypeDef<REF>,
fn type_hash_le<REF>() -> u128where
Self: HashedTypeDef<REF>,
👎Deprecated since 0.1.2: please use
HashedTypeMethods traitreturn little endianess type hash
Source§fn type_hash_be<REF>() -> u128where
Self: HashedTypeDef<REF>,
fn type_hash_be<REF>() -> u128where
Self: HashedTypeDef<REF>,
👎Deprecated since 0.1.2: please use
HashedTypeMethods traitreturn big endianess type hash
Source§fn type_uuid<REF>() -> Uuidwhere
Self: HashedTypeDef<REF>,
fn type_uuid<REF>() -> Uuidwhere
Self: HashedTypeDef<REF>,
👎Deprecated since 0.1.2: please use
HashedTypeMethods traitreturn uuid derived from type hash
Source§fn type_uuid_hyphenated<REF>() -> Stringwhere
Self: HashedTypeDef<REF>,
fn type_uuid_hyphenated<REF>() -> Stringwhere
Self: HashedTypeDef<REF>,
👎Deprecated since 0.1.2: please use
HashedTypeMethods traitreturn uuid hyphenated string
Source§fn self_type_hash_native<REF>(&self) -> u128where
Self: HashedTypeDef<REF>,
fn self_type_hash_native<REF>(&self) -> u128where
Self: HashedTypeDef<REF>,
👎Deprecated since 0.1.2: please use
HashedTypeMethods traitreturn native type hash from instance
Source§fn self_type_hash_le<REF>(&self) -> u128where
Self: HashedTypeDef<REF>,
fn self_type_hash_le<REF>(&self) -> u128where
Self: HashedTypeDef<REF>,
👎Deprecated since 0.1.2: please use
HashedTypeMethods traitreturn little endianess type hash from instance
Source§fn self_type_hash_be<REF>(&self) -> u128where
Self: HashedTypeDef<REF>,
fn self_type_hash_be<REF>(&self) -> u128where
Self: HashedTypeDef<REF>,
👎Deprecated since 0.1.2: please use
HashedTypeMethods traitreturn big endianess type hash from instance
Source§fn self_type_uuid<REF>(&self) -> Uuidwhere
Self: HashedTypeDef<REF>,
fn self_type_uuid<REF>(&self) -> Uuidwhere
Self: HashedTypeDef<REF>,
👎Deprecated since 0.1.2: please use
HashedTypeMethods traitreturn type hash-derived uuid from instance
Source§fn self_type_uuid_hyphenated<REF>(&self) -> Stringwhere
Self: HashedTypeDef<REF>,
fn self_type_uuid_hyphenated<REF>(&self) -> Stringwhere
Self: HashedTypeDef<REF>,
👎Deprecated since 0.1.2: please use
HashedTypeMethods traitreturn uuid hyphenated string from instance
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.