packages/MC/mc/Group_Bounds.cc
//---------------------------------------------------------------------------//
/*!
 * \brief Get the flattened group index for a particle at a given energy
 *
 * Lower bounds of an energy group are included as part of that group.
 *
 * \param[in] energy       Particle energy
 * \param[out] group_index Group index in multigroup data
 *
 * \return true if found, false if not
 */
\brief Get the flattened group index for a particle at a given energy
Lower bounds of an energy group are included as part of that group.

\param[in] energy       Particle energy
\param[out] group_index Group index in multigroup data

\return true if found, false if not
\ brief Get the flattened group index for a particle at a given energy Lower bounds of an energy group are included as part of that group . \ param [ in ] energy Particle energy \ param [ out ] group_index Group index in multigroup data \ return true if found false if not
bool Group_Bounds::find(const double  energy,
                        int          &group_index) const
{
    REQUIRE(energy >= 0.);
    if ((energy > d_bounds.front()) || (energy < d_bounds.back()))
        return false;
    group_index = std::lower_bound(
        d_bounds.begin(), d_bounds.end(), energy, std::greater<double>())
                  - d_bounds.begin() - 1;
    if (group_index == -1)
        ++group_index;
    CHECK(group_index >= 0);
    CHECK(group_index < d_bounds.size() - 1);
    return true;
}
bool Group_Bounds :: find ( const double energy , int & group_index ) const { REQUIRE ( energy >= 0. ) ; if ( ( energy > d_bounds . front ( ) ) || ( energy < d_bounds . back ( ) ) ) return false ; group_index = std :: lower_bound ( d_bounds . begin ( ) , d_bounds . end ( ) , energy , std :: greater < double > ( ) ) - d_bounds . begin ( ) - 1 ; if ( group_index == -1 ) ++ group_index ; CHECK ( group_index >= 0 ) ; CHECK ( group_index < d_bounds . size ( ) - 1 ) ; return true ; }
\brief Get the flattened group index for a particle at a given energy
 Lower bounds of an energy group are included as part of that group.
\ brief Get the flattened group index for a particle at a given energy Lower bounds of an energy group are included as part of that group .
// Find the group index; use std::greater because it's in descending order