src/iterate.rs

branch
dev
changeset 31
50a77e4efcbb
parent 5
59dc4c5883f4
child 38
8aaa22fcd302
equal deleted inserted replaced
30:9f2214c961cb 31:50a77e4efcbb
124 /// [module documentation][self]. 124 /// [module documentation][self].
125 fn if_verbose<V, E : Error>(&self, calc_objective : impl FnMut() -> V) -> Step<V, E>; 125 fn if_verbose<V, E : Error>(&self, calc_objective : impl FnMut() -> V) -> Step<V, E>;
126 126
127 /// Returns the current iteration count. 127 /// Returns the current iteration count.
128 fn iteration(&self) -> usize; 128 fn iteration(&self) -> usize;
129
130 /// Indicates whether the iterator is quiet
131 fn is_quiet(&self) -> bool;
129 } 132 }
130 133
131 /// Result of a step of an [`AlgIterator`] 134 /// Result of a step of an [`AlgIterator`]
132 #[derive(Debug, Serialize)] 135 #[derive(Debug, Serialize)]
133 pub enum Step<V, Fail : Error = std::convert::Infallible> { 136 pub enum Step<V, Fail : Error = std::convert::Infallible> {
465 /// Whether the iteration is verbose, i.e., results should be displayed. 468 /// Whether the iteration is verbose, i.e., results should be displayed.
466 /// Requires `calc` to be `true`. 469 /// Requires `calc` to be `true`.
467 verbose : bool, 470 verbose : bool,
468 /// Whether results should be calculated. 471 /// Whether results should be calculated.
469 calc : bool, 472 calc : bool,
473 /// Indicates whether the iteration is quiet
474 quiet : bool,
470 } 475 }
471 476
472 /// [`AlgIteratorFactory`] for [`BasicAlgIterator`] 477 /// [`AlgIteratorFactory`] for [`BasicAlgIterator`]
473 #[derive(Clone,Debug)] 478 #[derive(Clone,Debug)]
474 pub struct BasicAlgIteratorFactory<V> { 479 pub struct BasicAlgIteratorFactory<V> {
583 588
584 #[inline] 589 #[inline]
585 fn state(&self) -> BasicState { 590 fn state(&self) -> BasicState {
586 let iter = self.iter; 591 let iter = self.iter;
587 let verbose = self.options.verbose_iter.is_verbose(iter); 592 let verbose = self.options.verbose_iter.is_verbose(iter);
588 BasicState{ 593 BasicState {
589 iter : iter, 594 iter : iter,
590 verbose : verbose, 595 verbose : verbose,
591 calc : verbose, 596 calc : verbose,
597 quiet : self.options.quiet
592 } 598 }
593 } 599 }
594 } 600 }
595 601
596 impl AlgIteratorState for BasicState { 602 impl AlgIteratorState for BasicState {
603 } 609 }
604 } 610 }
605 611
606 #[inline] 612 #[inline]
607 fn iteration(&self) -> usize { 613 fn iteration(&self) -> usize {
608 return self.iter; 614 self.iter
615 }
616
617 #[inline]
618 fn is_quiet(&self) -> bool {
619 self.quiet
609 } 620 }
610 } 621 }
611 622
612 // 623 //
613 // Stall detecting iteration function. 624 // Stall detecting iteration function.

mercurial