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


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

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


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

示例1: print_set

void print_set(const std::set<int>& s) {
	cout << "(";
	if (!s.empty()) {
		size_t size = s.size();
		size_t i = 0;
		for (::mpl::lexer::detail::States::const_iterator it = s.begin();
			it != s.end(); ++it) {
			if (i > 0) {
				cout << ", ";
			}
			cout << *it;
			i++;
		}
	}
	cout << ")";
}
开发者ID:LelouchHe,项目名称:mpl,代码行数:16,代码来源:dfa.cpp

示例2: no_context_error

    std::shared_ptr<context> get_current_context()
    {
        if (all_contexts.size() == 0)
        {
            current_context = create_context(nullptr);
        }

        std::shared_ptr<context> current_locked_context = current_context.lock();

        if (!current_locked_context)
        {
            throw no_context_error();
        }

        return current_locked_context;
    }
开发者ID:vonture,项目名称:fixie,代码行数:16,代码来源:context.cpp

示例3: JudgeZP

  bool ZeroPadding::JudgeZP(const itpp::bvec& input, const std::set< int > &padPositions)
  {
    int numZeros = 0;
    int threshold = PresetPaddingThreshold.at(padPositions.size());

    for (auto curPosition = padPositions.begin(); curPosition != padPositions.end(); ++curPosition){
      numZeros += static_cast< int >(!input[*curPosition]);
    } // for i

    if (numZeros >= threshold){
      return true;
    } // if
    else{
      return false;
    } // else 
  }
开发者ID:lhc180,项目名称:MyLib,代码行数:16,代码来源:turbo_code.cpp

示例4: numberOfEdgesOutsideTriangle

size_t numberOfEdgesOutsideTriangle(std::set<Edge *> &edges) {
    std::set<int> nodes;
    
    std::set<Edge *> edgesPartOfTriangle;
    
    for (std::set<Edge *>::iterator it=edges.begin(); it != edges.end(); ++it) {
        Edge *edge = *it;
        nodes.insert(edge->source);
        nodes.insert(edge->destination);
    }
    
    for (std::set<Edge *>::iterator it=edges.begin(); it != edges.end(); ++it){
        for (std::set<int>::iterator jt=nodes.begin(); jt != nodes.end(); ++jt) {
            Edge *edge1 = nullptr, *edge2 = nullptr;
            
            for (std::set<Edge *>::iterator kt=edges.begin(); kt != edges.end(); ++kt) {
                Edge *edge = *kt;
                Edge *initialEdge = *it;
                int node = *jt;
                if ((initialEdge->source == edge->source && node == edge->destination) || (initialEdge->source == edge->destination && node == edge->source)) {
                    edge1 = edge;
                    break;
                }
            }
            
            for (std::set<Edge *>::iterator kt=edges.begin(); kt != edges.end(); ++kt) {
                Edge *edge = *kt;
                Edge *initialEdge = *it;
                int node = *jt;
                if ((initialEdge->destination == edge->source && node == edge->destination) || (initialEdge->destination == edge->destination && node == edge->source)) {
                    edge2 = edge;
                    break;
                }
            }
            
            if (edge1 != nullptr && edge2 != nullptr) {
                edgesPartOfTriangle.insert(edge1);
                edgesPartOfTriangle.insert(edge2);
                Edge *edge3 = *it;
                edgesPartOfTriangle.insert(edge3);
            }
            
        }
    }
    
    return edges.size() - edgesPartOfTriangle.size();
}
开发者ID:macostea,项目名称:info-labs,代码行数:47,代码来源:Utils.cpp

示例5: search

void SimpleIndexSearcher::search(std::vector<DocId> &docIds,
        const std::set<Term> &terms) const
{
    std::set<Term>::const_iterator termsIter = terms.begin();
    if(termsIter == terms.end())
        return;

    //TODO: optimize it
    docIds = getIndex().getPostings(*termsIter);
    ++termsIter;

    for(; termsIter != terms.end(); ++termsIter)
        docIds = docIds & getIndex().getPostings(*termsIter);

    base::Log().debug("find %lu documents for %lu terms", docIds.size(),
            terms.size());
}
开发者ID:xffox,项目名称:piclex,代码行数:17,代码来源:SimpleIndexSearcher.cpp

示例6: AddCluster

bool SelectiveClustering::AddCluster(vtkIdType key, std::set<vtkIdType> ClusterSelectionSet)
{
	/*! 
	* Adds a unique new cluster
	* replaces cluster if one with the key currently exists
	*/
	this->iter = this->ClusterMap.find(key);
	if ((this->ClusterMap.size() > 0) && (this->iter != this->ClusterMap.end()))
	{
		//Remove old item
		this->ClusterMap.erase(iter);
	}
	this->ClusterMap[key] = ClusterSelectionSet;
	this->AddRowToClusterTable(key, vtkVariant(ClusterSelectionSet.size()), NULL);
	emit ClusterChanged();
	return true;
}
开发者ID:RoysamLab,项目名称:STrend,代码行数:17,代码来源:SelectiveClustering.cpp

示例7: main

int main()
{
    for (int i = 0; i < 20; ++i)
    {
        boost::shared_ptr<GameObject> p(new Tank);
        all_targets.insert(p);
    }

    while (all_targets.size())
    {
        std::for_each(
            all_targets.begin(),
            all_targets.end(),
            boost::bind(&GameObject::time_slice,_1)
        );
    }
}
开发者ID:boostpro,项目名称:labs,代码行数:17,代码来源:game.cpp

示例8: showCourses

void ConsoleView::showCourses(std::set<std::shared_ptr<Course>> courses)
{
    if(courses.size() == 0)
        cerr << "No course to show." << endl;
    else
    {
        for(auto i = courses.begin(); i != courses.end(); ++i)
        {
            cout << "Title : " << (*i)->getTitle() << endl;
            cout << "Author : " << (*i)->getAuthor() << endl;
            cout << "Duration : " << (*i)->getDuration() << endl;
            cout << "Price : " << (*i)->getPrice() << endl;
            cout << "Description : " << (*i)->getDescription() << endl;
            cout << endl;
        }
    }
}
开发者ID:Eruliuce,项目名称:APU_UMLProject,代码行数:17,代码来源:ConsoleView.cpp

示例9: Get

  bool CoordDataFile::Get(const std::set<OSMId>& ids, ResultMap& resultMap) const
  {
    assert(isOpen);

    resultMap.clear();
    resultMap.reserve(ids.size());

    try {
      for (const auto& id : ids) {
        PageId relatedId=id+std::numeric_limits<OSMId>::min();
        PageId pageId=relatedId/pageSize;

        PageIdFileOffsetMap::const_iterator pageOffset=pageFileOffsetMap.find(pageId);

        if (pageOffset==pageFileOffsetMap.end()) {
          continue;
        }

        FileOffset offset=pageOffset->second+(relatedId%pageSize)*(coordByteSize+1);

        scanner.SetPos(offset);

        uint8_t  serial;
        bool     isSet;
        GeoCoord coord;

        scanner.Read(serial);
        scanner.ReadConditionalCoord(coord,
                                     isSet);

        if (!isSet) {
          continue;
        }

        resultMap.insert(std::make_pair(id,
                                        Coord(serial,
                                              coord)));
      }
    }
    catch (IOException& e) {
      log.Error() << e.GetDescription();
      return false;
    }

    return true;
  }
开发者ID:Dushistov,项目名称:libosmscout,代码行数:46,代码来源:CoordDataFile.cpp

示例10: collect_garbage

		void collect_garbage ( singlethreaded_marksweep::stats *s )
		{
			size_t precollection_heap_bytes = m_current_heap_bytes;
			mark_live_objects();
			sweep_dead_objects();
			m_last_collection_heap_size = m_current_heap_bytes;
			set_collection_rate ( m_percent_growth );

			if ( s )
			{
				s->live_heap_bytes = m_current_heap_bytes;
				s->garbage_bytes = precollection_heap_bytes - s->live_heap_bytes;
				s->root_pointers = m_roots.size();
				s->live_pointers = s->root_pointers + m_heap_ptrs.size();
				s->root_containers = m_root_containers.size();
			}
		}
开发者ID:Badcreature,项目名称:sagcg,代码行数:17,代码来源:tu_gc_singlethreaded_marksweep.cpp

示例11:

std::set<T> MonsterGenerator::get_set_from_tags(std::set<std::string> tags, std::map<std::string, T> conversion_map, T fallback)
{
    std::set<T> ret;

    if (tags.size() > 0){
        for (std::set<std::string>::iterator it = tags.begin(); it != tags.end(); ++it){
            if (conversion_map.find(*it) != conversion_map.end()){
                ret.insert(conversion_map[*it]);
            }
        }
    }
    if (ret.size() == 0){
        ret.insert(fallback);
    }

    return ret;
}
开发者ID:Ferk,项目名称:Cataclysm-DDA,代码行数:17,代码来源:monstergenerator.cpp

示例12: getLodCharacterId

//-----------------------------------------------
// getLodCharacterId
// Get the lod character id from the scene, according to LodCharacterName. Cached.
// -1 if id not found.
//-----------------------------------------------
sint getLodCharacterId(UScene &scene, const string &lodCharacterName)
{
	sint lodCharacterId = scene.getCLodShapeIdByName(lodCharacterName);
	// display a warning for bad character Id, only if name was setup in the sheet
	if(lodCharacterId==-1 && !lodCharacterName.empty() )
	{
		// Limited to 100 missing Lod to avoid memories problems
		if(LodCharactersNotFound.size() < 100)
		{
			// Insert and display a waring
			if(LodCharactersNotFound.insert(lodCharacterName).second)
				nlwarning("getLodCharacterId: Not found A Character LodCharacter in the Manager: %s", lodCharacterName.c_str());
		}
	}

	return lodCharacterId;
}// getLodCharacterId //
开发者ID:AzyxWare,项目名称:ryzom,代码行数:22,代码来源:misc.cpp

示例13: singleNucleotide

Nucleotide Nucleotide::singleNucleotide(std::set<Nucleotide>& nucleotides)
{
	std::set<Nucleotide>::iterator itgap = nucleotides.find(GAP);
	if(itgap != nucleotides.end())
		nucleotides.erase(itgap);

	if (nucleotides.size() == 1)
		return *nucleotides.begin();
	
	std::set<Nucleotide> all;
	for(std::set<Nucleotide>::iterator it = nucleotides.begin(); it != nucleotides.end(); ++it) {
		std::vector<Nucleotide> t;
		it->nonAmbiguousNucleotides(t);
		all.insert(t.begin(), t.end());
	}
	bool nta = all.find(A) != all.end();
	bool ntc = all.find(C) != all.end();
	bool ntg = all.find(G) != all.end();
	bool ntt = all.find(T) != all.end();

	if (nta && ntc && ntg && ntt)
		return N;
	if (nta && ntc && ntg)
		return V;
	if (nta && ntc && ntt)
		return H;
	if (nta && ntg && ntt)
		return D;
	if (ntc && ntg && ntt)
		return B;
 	if (nta && ntc)
		return M;
	if (ntg && ntt)
		return K;
	if (nta && ntt)
		return W;
	if (ntg && ntc)
		return S;
	if (ntc && ntt)
		return Y;
	if (nta && ntg)
		return R;		

	throw std::runtime_error
	  ("Internal error in Nucleotide::singleNucleotide()");
}
开发者ID:rega-cev,项目名称:libseq,代码行数:46,代码来源:Nucleotide.C

示例14: if

void 
Network::setPhases_(Region *r, std::set<UInt32>& phases)
{
  if (phases.size() == 0)
    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:Alleyfield,项目名称:nupic,代码行数:45,代码来源:Network.cpp

示例15: mergeParagraphLineBreaks

std::vector<std::u16string> BiDi::applyLineBreaking(std::set<std::size_t> lineBreakPoints) {
    // BiDi::getLine will error if called across a paragraph boundary, so we need to ensure that all
    // paragraph boundaries are included in the set of line break points. The calling code might not
    // include the line break because it didn't need to wrap at that point, or because the text was
    // separated with a more exotic code point such as (U+001C)
    mergeParagraphLineBreaks(lineBreakPoints);

    std::vector<std::u16string> transformedLines;
    transformedLines.reserve(lineBreakPoints.size());

    std::size_t start = 0;
    for (std::size_t lineBreakPoint : lineBreakPoints) {
        transformedLines.push_back(getLine(start, lineBreakPoint));
        start = lineBreakPoint;
    }

    return transformedLines;
}
开发者ID:BharathMG,项目名称:mapbox-gl-native,代码行数:18,代码来源:bidi.cpp


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