示例#1
0
 void cg_get_ranges(RangeSet& ranges, std::vector<long>& gids)
 {
   index right = 0, left = 0;
   while(true)
   {
     right = cg_get_right_border(left, (gids.size() - left) / 2, gids);
     ranges.push_back(Range(gids[left], gids[right]));
     if (right == gids.size() - 1)
       break;
     else
       left = right + 1;
   }
 }
示例#2
0
/**
 * Determine all contiguous ranges found in a given vector of gids
 * and add the ranges to the given RangeSet.
 *
 * \param ranges A reference to the RangeSet to add to
 * \param gids The std::vector<long> of gids
 *
 * \note We do not store the indices into the given range, but
 * instead we store the actual gids. This allows us to use CG
 * generated indices as indices into the ranges spanned by the
 * RangeSet. Index translation is done in cg_create_masks().
 */
void
cg_get_ranges( RangeSet& ranges, std::vector< long >& gids )
{
  index right, left = 0;
  while ( true )
  {
    // Determine the right border of the contiguous range starting
    // at left. The initial step is set to half the length of the
    // interval between left and the end of gids.
    right = cg_get_right_border( left, ( gids.size() - left ) / 2, gids );
    ranges.push_back( Range( gids[ left ], gids[ right ] ) );
    if ( right == gids.size() - 1 ) // We're at the end of gids and stop
      break;
    else
      left = right + 1; // The new left border is one after the old right
  }
}