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

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 refiner contains 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 refiner contains any elements that are not in the partition

Trait Implementations

impl Debug for Partition

fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>

impl<'a> IntoIterator for &'a Partition

type Item = &'a [usize]

type IntoIter = PartitionIter<'a>

fn into_iter(self) -> Self::IntoIter

Derived Implementations

impl Clone for Partition

fn clone(&self) -> Partition

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