當前位置: 首頁>>代碼示例>>C++>>正文


C++ Interval::start方法代碼示例

本文整理匯總了C++中Interval::start方法的典型用法代碼示例。如果您正苦於以下問題:C++ Interval::start方法的具體用法?C++ Interval::start怎麽用?C++ Interval::start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Interval的用法示例。


在下文中一共展示了Interval::start方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: split

// Split this interval at pos and return the rest. Pos must be a location
// that ensures both shorter intervals are nonempty. If keep_uses is set,Uses
// exactly at the end of the first interval will stay with the first part.
Interval* Interval::split(unsigned pos, bool keep_uses) {
  assert(pos > start() && pos < end()); // both parts will be non-empty
  auto leader = this->leader();
  Interval* child = smart_new<Interval>(leader);
  child->next = next;
  next = child;
  // advance r1 to the first range we want in child; maybe split a range.
  auto r1 = ranges.begin(), r2 = ranges.end();
  while (r1->end <= pos) r1++;
  if (pos > r1->start) { // split r at pos
    child->ranges.push_back({pos, r1->end});
    r1->end = pos;
    r1++;
  }
  child->ranges.insert(child->ranges.end(), r1, r2);
  ranges.erase(r1, r2);
  // advance u1 to the first use position in child, then copy u1..end to child.
  auto u1 = uses.begin(), u2 = uses.end();
  if (keep_uses) {
    while (u1 != u2 && u1->pos <= end()) u1++;
  } else {
    while (u1 != u2 && u1->pos < child->start()) u1++;
  }
  child->uses.insert(child->uses.end(), u1, u2);
  uses.erase(u1, u2);
  return child;
}
開發者ID:CodeKong,項目名稱:hhvm,代碼行數:30,代碼來源:vasm-xls.cpp

示例2: bisectionMethod

void bisectionMethod(Interval const &interval, double const &eps) {
	double left = interval.start();
	double right = interval.end();
	double middle = (right + left) / 2;

	int n = 0;

	while (abs(left - right) > 2 * eps) {
		if (FuncClass::func(left) * FuncClass::func(middle) > 0)
			left = middle;
		else
			right = middle;
		middle = (right + left) / 2;
		
		n++;
	}

	cout << "Bisection method\n";
	cout << "Step: " << n << "\n";
	cout << "Approximated solution: " << middle << "\n";
	cout << "Discrepansy module: " << abs(FuncClass::func(middle)) << "\n\n";
}
開發者ID:anlunHW,項目名稱:calcMethods,代碼行數:22,代碼來源:main.cpp

示例3: addInterval

// Note: this is considerably more efficient in the case where intervals are added
// smallest first.
void IntervalList::addInterval(Interval interval)
{
  if(m_list.size() == 0)
  {
    m_list.append(interval);
    return;
  }
  
  bool added = false;
  QList<int> deleteList;

  for(int i = m_list.size() - 1; i >= 0 ; i--)
  {
    // if new interval is completely higher than this interval
    if(interval.start() > m_list.at(i).end() + 1)
    {
      // add new interval as a seperate interval
      m_list.append(interval);
      added = true;
      break;
    }
    // else if the new interval can be merged with this interval
    else if(m_list.at(i).canMerge(interval))
    {
      // for each interval in the list before and including this one
      for(int j = i; j >= 0; j--)
      {
        // if it can be merged into the new interval
        if(m_list.at(j).canMerge(interval))
        {
          // do it
          interval.merge(m_list.at(j));
          // then add its index to the list of intervals to be deleted
          deleteList.append(j);
        }
        // else if it cant, there is no need to continue checking whether 
        // any other intervals can alse be merged
        else
        {
          break;
        }
      }
      // insert the new large interval in the correct place
      m_list.insert(i+1, interval);
      added = true;
      break;
    }
  }
  // if deleteList has any elements, delete intervals at those indices
  if(deleteList.size() > 0)
  {
    qSort(deleteList);
      
    for(int i = deleteList.size() - 1; i >=0 ; i--)
    {
      m_list.removeAt(deleteList[i]);
    }
  }
  // if still not assigned, add to the beginning 
  if(!added)
  {
    m_list.insert(0, interval);
  }
}
開發者ID:trnielsen,項目名稱:mantid,代碼行數:66,代碼來源:MantidWSIndexDialog.cpp

示例4: calcStabilityForRowC

    bool Solver::calcStabilityForRowC()
    {
        m_stabilityRowC.resize(m_width, Interval());
        for(size_t j=0; j < m_width; j++)
        {
            Interval vals;

            if(m_variableType[j] == VariableMain)
            {
                size_t basisi;
                for(basisi=0; basisi < m_height; basisi++)
                {
                    if(m_columnBasis[basisi] == j)
                        break;
                }

                // basis variable
                if(basisi != m_height)
                {
                    // we can't change basis variables without changing rowD
                    vals.setStart(0);
                    vals.setEnd(0);

                    /*
                    for(size_t jj=0; jj < m_width; jj++)
                    {
                        if(checkEquals(m_rowD[jj], 0.0) ||
                           checkEquals(m_matrixA[basisi][jj], 0.0))
                            continue;

                        double deltac = m_rowD[jj] / m_matrixA[basisi][jj];

                        if(m_funcType == OptimizeToMin)
                            deltac = -deltac;

                        if(deltac < 0)
                        {
                            if(deltac > vals.start())
                                 vals.setStart(deltac);
                        }
                        else if(deltac > 0)
                        {
                            if(deltac < vals.end())
                                 vals.setEnd(deltac);
                        }
                    }*/
                }
                else // free variable
                {
                    double deltac = m_rowD[j];

                    if(m_funcType == OptimizeToMax)
                        deltac = -deltac;

                    if(deltac > 0)
                        vals.setEnd(deltac);
                    else if(deltac < 0)
                        vals.setStart(deltac);
                    else
                    {
                        vals.setStart(deltac);
                        vals.setEnd(deltac);
                    }
                }

                vals.setStart(m_rowC[j] + vals.start());
                vals.setEnd(m_rowC[j] + vals.end());
            }

            m_stabilityRowC[j] = vals;
        }

        return true;
    }
開發者ID:rtsisyk,項目名稱:simplexsolver,代碼行數:74,代碼來源:simplexmethod.cpp

示例5: check_interval

void check_interval(const Interval& actual, const Interval& truth) {
  BOOST_CHECK_EQUAL(actual.chr(), truth.chr());
  BOOST_CHECK_EQUAL(actual.start(), truth.start());
  BOOST_CHECK_EQUAL(actual.stop(), truth.stop());
}
開發者ID:lbergelson,項目名稱:gamgee,代碼行數:5,代碼來源:interval_test.cpp

示例6: get_sequence

string ReferenceMap::get_sequence(const Interval& interval, const bool reverse_strand) const {
  const auto& seq = this->at(interval.chr());
  auto result = seq.substr(interval.start()-1, interval.size());
  return reverse_strand ? utils::complement(result) : result;
}
開發者ID:broadinstitute,項目名稱:gamgee,代碼行數:5,代碼來源:reference_map.cpp


注:本文中的Interval::start方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。