当前位置: 首页>>代码示例>>C++>>正文


C++ set::rbegin方法代码示例

本文整理汇总了C++中std::set::rbegin方法的典型用法代码示例。如果您正苦于以下问题:C++ set::rbegin方法的具体用法?C++ set::rbegin怎么用?C++ set::rbegin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::set的用法示例。


在下文中一共展示了set::rbegin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: xpt

  double operator[](double x) const {
    assert(!curve_.empty());

    AbstractCurvePoint xpt(x);

    if (xpt <= *curve_.begin()) {
      return static_cast<double>(*curve_.begin());
    }

    if (xpt >= *curve_.rbegin()) {
      return static_cast<double>(*curve_.rbegin());
    }

    auto it_max = curve_.upper_bound(xpt);

    assert(!((*it_max) <= xpt));
    assert(xpt != (*it_max));
    assert(xpt < (*it_max));

    auto it_min = std::prev(it_max, 1);

    assert(!((*it_min) > xpt));
    assert((*it_min) <= xpt);

    assert((*it_min) < (*it_max));
    assert((*it_min) != (*it_max));

    if (xpt == (*it_min)) {
      return static_cast<double>(*it_min);
    }

    return (*it_min).interpolate(*it_max, x);
  }
开发者ID:LebedevRI,项目名称:chrysaor,代码行数:33,代码来源:AbstractCurve.hpp

示例2: findNearestAllowedAngle

Float_t findNearestAllowedAngle(std::set<Float_t>& angles,
                                const Float_t ang) {
   // find closest allowed angle
   std::set<Float_t>::const_iterator
      hiang = angles.lower_bound(ang),
      loang = hiang;
   if (loang!=angles.begin()) {
      --loang;
   }
#ifdef DEBUG
      Printf("loang=%p, hiang=%p, end=%p",
             (void*)&(*loang), (void*)&(*hiang), (void*)&(*angles.end()));
#endif
   if ( (loang==angles.end()) || (hiang==angles.end()) ) {
      // too big; take the largest one
      return *(angles.rbegin());
   } else {
      // round to the nearest angle (round up if halfway)
#ifdef DEBUG
      Printf("loang=%g, hiang=%g, ang=%g",
             *loang, *hiang, ang);
#endif
      if ( TMath::Abs(*loang - ang) < TMath::Abs(*hiang - ang) ) {
         return *loang;
      } else {
         return *hiang;
      }
   }
}
开发者ID:jetatar,项目名称:snowShovel,代码行数:29,代码来源:buildFakeAngTree.C

示例3: deleteRows

void DebtsTableModel::deleteRows(const std::set<int>& rows)
{
	for (std::set<int>::const_reverse_iterator iter=rows.rbegin(); iter!=rows.rend(); ++iter)
	{
		mCostSplitter->removeDebt(*iter);
	}
}
开发者ID:christiana,项目名称:blackbook,代码行数:7,代码来源:bbDebtsTableModel.cpp

示例4: output

void output(int oo)
{
	if (oo != *pos.rbegin())
		printf("%d ", oo);
	else
		printf("%d", oo);
}
开发者ID:lonelam,项目名称:LearnC,代码行数:7,代码来源:源.cpp

示例5: newStorageWithRemovedRows

Storage newStorageWithRemovedRows(const Storage& origSto,
        const std::set<int>& rowsToRemove) {
    Storage sto(1000);
    auto labels = origSto.getColumnLabels();
    auto numOrigColumns = origSto.getColumnLabels().getSize() - 1;

    // Remove in reverse order so it's easier to keep track of indices.
     for (auto it = rowsToRemove.rbegin(); it != rowsToRemove.rend(); ++it) {
         labels.remove(*it);
     }
    sto.setColumnLabels(labels);

    double time;
    for (int itime = 0; itime < origSto.getSize(); ++itime) {
        SimTK::Vector rowData(numOrigColumns);
        origSto.getData(itime, numOrigColumns, rowData);

        SimTK::Vector newRowData(numOrigColumns - (int)rowsToRemove.size());
        int iNew = 0;
        for (int iOrig = 0; iOrig < numOrigColumns; ++iOrig) {
            if (rowsToRemove.count(iOrig) == 0) {
                newRowData[iNew] = rowData[iOrig];
                ++iNew;
            }
        }

        origSto.getTime(itime, time);
        sto.append(time, newRowData);
    }
    return sto;
}
开发者ID:cpizzolato,项目名称:opensim-core,代码行数:31,代码来源:testStatesTrajectory.cpp

示例6: merge

void merge( std::set<T>& bigger, const std::set<U>& smaller )
{
    // invariant: largest element of smaller is smaller than the smallest element of bigger
    for( auto iter = smaller.rbegin() ; iter != smaller.rend() ; ++iter )
        bigger.emplace_hint( bigger.begin(), *iter ) ;
        // http://en.cppreference.com/w/cpp/container/set/emplace_hint

}
开发者ID:CCJY,项目名称:coliru,代码行数:8,代码来源:main.cpp

示例7: add

void DoubleList::add(const std::set<int>& sSelPos) // adds elements from the specified indexes
{
    switch (m_eSelectionMode)
    {
    case SINGLE_UNSORTABLE:
        for (set<int>::const_reverse_iterator it = sSelPos.rbegin(), end = sSelPos.rend(); it != end; ++it) // the last must be processed first, so removal of elements doesn't change the row number for the remaining ones
        {
            int nRow (*it);
            int nIndex (m_listPainter.m_vAvailable[nRow]);
            vector<int>::iterator it1 (lower_bound(m_listPainter.m_vSel.begin(), m_listPainter.m_vSel.end(), nIndex));
            m_listPainter.m_vSel.insert(it1, nIndex);
            m_listPainter.m_vAvailable.erase(m_listPainter.m_vAvailable.begin() + nRow);
        }
        break;

    case SINGLE_SORTABLE:
        for (set<int>::const_iterator it = sSelPos.begin(), end = sSelPos.end(); it != end; ++it)
        {
            int nRow (*it);
            int nIndex (m_listPainter.m_vAvailable[nRow]);
            m_listPainter.m_vSel.push_back(nIndex);
        }
        for (set<int>::const_reverse_iterator it = sSelPos.rbegin(), end = sSelPos.rend(); it != end; ++it)
        {
            int nRow (*it);
            m_listPainter.m_vAvailable.erase(m_listPainter.m_vAvailable.begin() + nRow);
        }
        break;

    case MULTIPLE:
        for (set<int>::const_iterator it = sSelPos.begin(), end = sSelPos.end(); it != end; ++it)
        {
            int nRow (*it);
            //int nIndex (m_listPainter.m_vAvailable[nRow]);
            //m_listPainter.getSel_().push_back(nIndex);
            m_listPainter.m_vSel.push_back(nRow);
        }
        break;

    default:
        CB_ASSERT(false);
    }

    adjustOnDataChanged();
}
开发者ID:miracle2k,项目名称:mp3diags,代码行数:45,代码来源:DoubleList.cpp

示例8: setLevelsFromValues

//--------------------------------------------------------------------------------------------------
/// This method sets all the levels to the user defined domain values, 
/// overriding any previous max and min range settings.
//--------------------------------------------------------------------------------------------------
void ScalarMapperRangeBased::setLevelsFromValues(const std::set<double>& levelValues)
{
    CVF_ASSERT(!m_userDefinedLevelValues.empty());

    m_userDefinedLevelValues = levelValues;
    m_rangeMax = (*levelValues.rbegin());
    m_rangeMin = (*levelValues.begin());
    updateSortedLevels();
}
开发者ID:atgeirr,项目名称:ResInsight,代码行数:13,代码来源:cvfScalarMapperRangeBased.cpp

示例9: main

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	for (int i = 1; i <= m; i++) {
		scanf("%d%d", &o[i].op, &o[i].r);
		o[i].t = i;
	}
	for (int i = m; i >= 1; i--) {
		add(n - o[i].r + 1);
		if (sum(n - o[i].r) == 0) {
			s[++tot] = o[i];
		}
	}
	std::reverse(s + 1, s + tot + 1);
	s[0].r = n;
	s[0].t = 0;
	for (int i = n; i > s[1].r; i--) {
		answer[i] = a[i];
	}
	for (int i = s[1].r; i >= 1; i--) {
		set.insert(std::make_pair(a[i], i));
	}
	for (int i = 2, tmp = n; i <= tot; i++) {
		int length = s[i - 1].r - s[i].r, t = 0;
		for (int j = 1; j <= length; j++)
			if (s[i - 1].op == 1) {
				auto it = --set.end();
				b[++t] = *it;
				set.erase(it);
			} else if (s[i - 1].op == 2) {
				auto it = set.begin();
				b[++t] = *it;
				set.erase(it);
			}
		for (int j = s[i - 1].r, z = 0; j > s[i].r; j--) {
			answer[j] = b[++z].first;
		}
	}
	if (s[tot].op == 1) {
		int p = 0;
		for (auto it = set.begin(); it != set.end(); it++) {
			answer[++p] = it -> first;
		}
	} else {
		int p = 0;
		for (auto it = set.rbegin(); it != set.rend(); it++) {
			answer[++p] = it -> first;
		}
	}
	for (int i = 1; i <= n; i++) {
		printf("%d%c", answer[i], " \n"[i == n]);
	}
	return 0;
}
开发者ID:PrayStarJirachi,项目名称:Exercise-Code,代码行数:54,代码来源:C.cpp

示例10: COException

void VectorBase<scalar,index,SizeAtCompileTime>::blockFromVector(const VectorBase& vec,const std::set<index>& indices)
{
	if( *indices.rbegin() >= vec.size() )
	{
		throw COException("Index out of range in Vector blocking!");
	}
	this->resize(indices.size());
	index i = 0;
	for ( const auto& s : indices ){
		this->operator[](i) = vec[s];
		++ i;
	}
}
开发者ID:GuoSongtao,项目名称:COptdev,代码行数:13,代码来源:VectorImpl.hpp

示例11: primeNumber

/** n**2 + a*n + b */
int primeNumber(int a, int b, const std::set<long>& primes)
{
	int i = 0;
	while (true)
	{
		long n = i*i+a*i+b;
		if((*primes.rbegin())<n)
			return -1;
		if(primes.find(n)==primes.end())
			break;
		++ i;
	}
	return i+1;
}
开发者ID:fromradio,项目名称:ProjectEuler,代码行数:15,代码来源:quadratic_prime.cpp

示例12: main

int main(){

    //insert O(log N) per element or O(1) am per element for _sorted_ elements
    //For a total of O(N log N)  or O(N) for sorted inputs
    int key;
    for(key = 0; key < 10; key++){
        myset.insert(key);
    }

    //find O(log N)
    it = myset.find(3);

    //removes 3 in O(1) am post-find time
    myset.erase(it);
    //removes 4 from the set  O(log N) time
    myset.erase(4);

    //iterate the set in forward order O(1) am / O(log N)
    //for a total of O(N) total
    //Note that begin() returns an iterator to the first element
    //whereas that end() returns to a dummy element after the last element
    for(it = myset.begin(); it != myset.end(); it++){
        std::cout << *it << " " ;
    }
    std::cout << std::endl;

    //iterate the set in reverse order )O(1) am / O(log N)
    //for a total of O(N) total
    //Note that rbegin() returns an iterator to the last element
    //whereas that end() returns to a dummy element before the first element
    for(rit = myset.rbegin(); rit != myset.rend(); rit++){
        std::cout << *rit << " " ;
    }
    std::cout << std::endl;

    //Find the first element greater than or equal to the current element in O(log N) time
    //In this case it returns 6
    it = myset.lower_bound(6);
    std::cout << *it << std::endl;
    
    //Find the first element greater than the current element in O(log N) time
    //In this case it returns 7
    it = myset.upper_bound(6);
    std::cout << *it << std::endl;
    
    // Empties the set O(N) time
    myset.clear();

}
开发者ID:smileKitten,项目名称:hackpack,代码行数:49,代码来源:set.cpp

示例13: erase_values

/**
   Erase from a list of wcstring values at specified indexes 
*/
static void erase_values(wcstring_list_t &list, const std::vector<long> &indexes) 
{
    // Make a set of indexes.
    // This both sorts them into ascending order and removes duplicates.
    const std::set<long> indexes_set(indexes.begin(), indexes.end());
    
    // Now walk the set backwards, so we encounter larger indexes first, and remove elements at the given (1-based) indexes.
    std::set<long>::const_reverse_iterator iter;
    for (iter = indexes_set.rbegin(); iter != indexes_set.rend(); iter++) {
        long val = *iter;
        if (val > 0 && val <= list.size()) {
            // One-based indexing!
            list.erase(list.begin() + val - 1);
        }
    }
}
开发者ID:asheidan,项目名称:fish-shell,代码行数:19,代码来源:builtin_set.cpp

示例14: remove

void DoubleList::remove(const std::set<int>& sSelPos) // removes elements from the specified indexes
{
    for (set<int>::const_reverse_iterator it = sSelPos.rbegin(), end = sSelPos.rend(); it != end; ++it)
    {
        int nRow (*it);
        int nIndex (m_listPainter.m_vSel[nRow]);
        if (MULTIPLE != m_eSelectionMode)
        {
            vector<int>::iterator it1 (lower_bound(m_listPainter.m_vAvailable.begin(), m_listPainter.m_vAvailable.end(), nIndex));
            m_listPainter.m_vAvailable.insert(it1, nIndex);
        }
        m_listPainter.m_vSel.erase(m_listPainter.m_vSel.begin() + nRow);
    }

    adjustOnDataChanged();
}
开发者ID:miracle2k,项目名称:mp3diags,代码行数:16,代码来源:DoubleList.cpp

示例15: if

void 
Network::setPhases_(Region *r, std::set<UInt32>& phases)
{
  if (phases.empty())
    NTA_THROW << "Attempt to set empty phase list for region " << r->getName();

  UInt32 maxNewPhase = *(phases.rbegin());
  UInt32 nextPhase = phaseInfo_.size();
  if (maxNewPhase >= nextPhase)
  {
    // It is very unlikely that someone would add a region
    // with a phase much greater than the phase of any other
    // region. This sanity check catches such problems, 
    // though it should arguably be legal to set any phase. 
    if (maxNewPhase - nextPhase > 3)
      NTA_THROW << "Attempt to set phase of " << maxNewPhase
                << " when expected next phase is " << nextPhase
                << " -- this is probably an error.";

    phaseInfo_.resize(maxNewPhase+1);
  }
  for (UInt i = 0; i < phaseInfo_.size(); i++)
  {
    bool insertPhase = false;
    if (phases.find(i) != phases.end())
      insertPhase = true;

    // remove previous settings for this region
    std::set<Region*>::iterator item;
    item = phaseInfo_[i].find(r);
    if (item != phaseInfo_[i].end() && !insertPhase)
    {
      phaseInfo_[i].erase(item);
    } else if (insertPhase) 
    {
      phaseInfo_[i].insert(r);
    }
  }

  // keep track (redundantly) of phases inside the Region also, for serialization
  r->setPhases(phases);

  resetEnabledPhases_();

}
开发者ID:Asele,项目名称:nupic.core,代码行数:45,代码来源:Network.cpp


注:本文中的std::set::rbegin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。