Struct rv::data::Partition [−][src]
pub struct Partition { /* fields omitted */ }
Implementations
Create a Partition
with a given assignment, z
Examples
let z1 = vec![0, 1, 2, 3, 1, 2]; let part = Partition::from_z(z1).unwrap(); assert_eq!(*part.z(), vec![0, 1, 2, 3, 1, 2]); assert_eq!(*part.counts(), vec![1, 2, 2, 1]); // Invalid z because k=4 is empty. All partitions must be occupied. let z2 = vec![0, 1, 2, 3, 1, 5]; assert!(Partition::from_z(z2).is_err());
Remove the item at index ix
Example
let mut part = Partition::from_z(vec![0, 1, 0, 2]).unwrap(); part.remove(1).expect("Could not remove"); assert_eq!(*part.z(), vec![0, 0, 1]); assert_eq!(*part.counts(), vec![2, 1]);
Append a new item assigned to partition zi
Example
let mut part = Partition::from_z(vec![0, 1, 0, 2]).unwrap(); part.append(3).expect("Could not append"); assert_eq!(*part.z(), vec![0, 1, 0, 2, 3]); assert_eq!(*part.counts(), vec![2, 1, 1, 1]);
Returns the number of partitions, k.
Example
let part = Partition::from_z(vec![0, 1, 0, 2]).unwrap(); assert_eq!(part.k(), 3); assert_eq!(*part.counts(), vec![2, 1, 1]);
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Partition
impl UnwindSafe for Partition
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
pub fn vzip(self) -> V