Struct refinery::Partition
[−]
[src]
pub struct Partition {
// some fields omitted
}A partition of a set of usizes. See the crate documentation for more information.
Methods
impl Partition[src]
fn new<I, J>(sets: I, size: usize) -> Partition where I: Iterator<Item=J>, J: Iterator<Item=usize>
Constructs a new Partition.
sets is an iterator over the sets of the partition. The sets must be non-overlapping, and
they must all be subsets of the half-open range [0, size).
Panics
- if any sets overlap
- if any sets contain an element larger than or equal to
size.
fn simple(size: usize) -> Partition
Constructs a new Partition containing only one set (the half-open range [0, size)).
fn iter<'a>(&'a self) -> PartitionIter<'a>
Iterates over the sets in this partition, each of which is realized by a &[usize].
fn refine(&mut self, refiner: &[usize])
Refines the partition with the given set.
Every set s in the partition is replaced by s.intersection(refiner) and
s.difference(refiner).
This function runs in time that is O(n log n) in the size of refiner.
Panics
- if
refinercontains any elements that are not in the partition
fn part(&self, part_idx: usize) -> &[usize]
Returns one part of this partition.
fn num_parts(&self) -> usize
The number of parts in this partition.
fn refine_with_callback<F>(&mut self, refiner: &[usize], split_callback: F) where F: FnMut(&Partition, usize, usize)
Refines the partition with the given set.
Every set s in the partition is replaced by s.intersection(refiner) and
s.difference(refiner). Every time we make such a non-trivial (meaning that both the
intersection and the difference are non-empty) replacement, we call the supplied callback
function with arguments self, original_set_idx and difference_idx.
This function runs in time that is O(n log n) in the size of refiner.
Panics
- if
refinercontains any elements that are not in the partition
Trait Implementations
impl Clone for Partition[src]
fn clone(&self) -> Partition
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0
Performs copy-assignment from source. Read more
impl Debug for Partition[src]
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter.