Changeset 2496


Ignore:
Timestamp:
Jun 22, 2011, 4:31:25 PM (10 years ago)
Author:
Peter
Message:

benjamini-hochberg: avoid crash when input is empty range. Speed-up when iterator is not random access.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/statistics/utility.h

    r2476 r2496  
    4141#include <algorithm>
    4242#include <cmath>
     43#include <iterator>
    4344#include <stdexcept>
    4445#include <vector>
     
    231232    BOOST_CONCEPT_ASSERT((Mutable_BidirectionalIterator<BidirectionalIterator2>));
    232233    size_t n = std::distance(first, last);
    233     std::advance(result, n);
    234     --result;
    235     std::advance(first, n);
     234    if (!n)
     235      return;
     236    std::advance(result, n-1);
     237    first = last;
    236238    --first;
    237239    size_t rank = n;
Note: See TracChangeset for help on using the changeset viewer.