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


C++ closure函数代码示例

本文整理汇总了C++中closure函数的典型用法代码示例。如果您正苦于以下问题:C++ closure函数的具体用法?C++ closure怎么用?C++ closure使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: CollectRuntimeStats

CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats, ObjectPrivateVisitor *opv)
{
    if (!rtStats->compartmentStatsVector.reserve(rt->compartments.length()))
        return false;

    rtStats->gcHeapChunkTotal =
        size_t(JS_GetGCParameter(rt, JSGC_TOTAL_CHUNKS)) * gc::ChunkSize;

    rtStats->gcHeapUnusedChunks =
        size_t(JS_GetGCParameter(rt, JSGC_UNUSED_CHUNKS)) * gc::ChunkSize;

    // This just computes rtStats->gcHeapDecommittedArenas.
    IterateChunks(rt, rtStats, StatsChunkCallback);

    // Take the per-compartment measurements.
    IteratorClosure closure(rtStats, opv);
    if (!closure.init())
        return false;
    rtStats->runtime.scriptSources = 0;
    IterateCompartmentsArenasCells(rt, &closure, StatsCompartmentCallback,
                                   StatsArenaCallback, StatsCellCallback);

    // Take the "explicit/js/runtime/" measurements.
    rt->sizeOfIncludingThis(rtStats->mallocSizeOf, &rtStats->runtime);

    rtStats->gcHeapGcThings = 0;
    for (size_t i = 0; i < rtStats->compartmentStatsVector.length(); i++) {
        CompartmentStats &cStats = rtStats->compartmentStatsVector[i];

        rtStats->totals.add(cStats);
        rtStats->gcHeapGcThings += cStats.gcHeapThingsSize();
    }

    size_t numDirtyChunks =
        (rtStats->gcHeapChunkTotal - rtStats->gcHeapUnusedChunks) / gc::ChunkSize;
    size_t perChunkAdmin =
        sizeof(gc::Chunk) - (sizeof(gc::Arena) * gc::ArenasPerChunk);
    rtStats->gcHeapChunkAdmin = numDirtyChunks * perChunkAdmin;
    rtStats->gcHeapUnusedArenas -= rtStats->gcHeapChunkAdmin;

    // |gcHeapUnusedArenas| is the only thing left.  Compute it in terms of
    // all the others.  See the comment in RuntimeStats for explanation.
    rtStats->gcHeapUnusedArenas = rtStats->gcHeapChunkTotal -
                                  rtStats->gcHeapDecommittedArenas -
                                  rtStats->gcHeapUnusedChunks -
                                  rtStats->totals.gcHeapUnusedGcThings -
                                  rtStats->gcHeapChunkAdmin -
                                  rtStats->totals.gcHeapArenaAdmin -
                                  rtStats->gcHeapGcThings;
    return true;
}
开发者ID:mokerjoke,项目名称:mozilla-central,代码行数:51,代码来源:jsmemorymetrics.cpp

示例2: augmentGrammar

void CFG::constructCanonicalLR0Collection()
{
	if(!augmented)
	{
		augmentGrammar();
	}

	canonicalLR0Collection.clear();

	canonicalLR0Collection = vector<vector<LR0Item>>(
	{
		closure(
			vector<LR0Item>(
			{
				LR0Item(
					find_if(
						p.begin(), 
						p.end(),
						[this](const Production& pr)
						{
							return pr.left == s; 
						}
					) - p.begin(),
					0
				)
			})
		)
	});

	bool updated = false;
	vector<string> symbols = v;
	symbols.insert(symbols.end(), t.begin(), t.end());

	do
	{
		updated = false;

		for(size_t i = 0; i < canonicalLR0Collection.size(); ++i)
		{
			for(size_t j = 0; j < symbols.size(); ++j)
			{
				vector<LR0Item> goToIX = goTo(canonicalLR0Collection[i], symbols[j]);
				if(goToIX.size() != 0 && !in(goToIX, canonicalLR0Collection))
				{
					canonicalLR0Collection.push_back(goToIX);
					updated = true;
				}
			}
		}
	}while(updated);
}
开发者ID:ZephyrZhng,项目名称:code_ub,代码行数:51,代码来源:CFG.cpp

示例3: print_core

static void
print_core (FILE *out, state *s)
{
  size_t i;
  item_number *sitems = s->items;
  size_t snritems = s->nitems;
  symbol *previous_lhs = NULL;

  /* Output all the items of a state, not only its kernel.  */
  if (report_flag & report_itemsets)
    {
      closure (sitems, snritems);
      sitems = itemset;
      snritems = nitemset;
    }

  if (!snritems)
    return;

  fputc ('\n', out);

  for (i = 0; i < snritems; i++)
    {
      item_number *sp;
      item_number *sp1;
      rule_number r;

      sp1 = sp = ritem + sitems[i];

      while (*sp >= 0)
	sp++;

      r = item_number_as_rule_number (*sp);

      rule_lhs_print (&rules[r], previous_lhs, out);
      previous_lhs = rules[r].lhs;

      for (sp = rules[r].rhs; sp < sp1; sp++)
	fprintf (out, " %s", symbols[*sp]->tag);
      fputs (" .", out);
      for (/* Nothing */; *sp >= 0; ++sp)
	fprintf (out, " %s", symbols[*sp]->tag);

      /* Display the lookahead tokens?  */
      if (report_flag & report_lookahead_tokens
          && item_number_is_rule_number (*sp1))
	state_rule_lookahead_tokens_print (s, &rules[r], out);

      fputc ('\n', out);
    }
}
开发者ID:10114395,项目名称:android-5.0.0_r5,代码行数:51,代码来源:print.c

示例4: fprintf

struct cons_t* environment_t::define(const std::string& name, lambda_t f, bool syntactic)
{
  /*
   * TODO: Are redefinitions legal?
   */
  bool warn_mul_defs = false;

  if ( warn_mul_defs )
    fprintf(stderr, "WARNING: Already have a definition for %s\n",
      name.c_str());

  symbols[name] = closure(f, this, syntactic);
  return symbols[name];
}
开发者ID:Fangang,项目名称:mickey-scheme,代码行数:14,代码来源:environment.cpp

示例5: collection_any_satisfy2

/*
 * @NAME: collection_any_satisfy2
 * @DESC: Igual a funcion any_satisfy de Haskell
 */
bool collection_any_satisfy2( t_list* list, char (*closure)(void*, ...),...){
	va_list args_list;
	va_start(args_list,*closure);
	t_link_element *element = list->head;
	sem_wait( &list->semaforo );
	while( element != NULL ){
		if(closure(element->data, args_list)){
			return(1);
		}
		element = element->next;
	}
	sem_post( &list->semaforo );
	return(0);
}
开发者ID:martoo6,项目名称:tp-so-fuse,代码行数:18,代码来源:utilidades.c

示例6: closure

void CLRItemCollectionFamily::build(const BNFInstance& bnf)
{
    for (auto &sym : bnf.symbolSet) {
        if (sym.type == SyntaxSymbol::T_Terminal) {
            term2ID[sym.value] = (int)ID2Term.size();
            ID2Term.push_back(sym.value);
        }
    }

    vector<int> unhanldedState;
    {
        CLRItemCollection col;
        CLRItem item = {0, 0, term2ID[END_TERM]};
        col.items.insert(item.toInt());
        closure(bnf, col);
        int ns;
        addCollection(col, ns);
        unhanldedState.push_back(0);
    }
    while (!unhanldedState.empty()) {
        int state = unhanldedState.back();
        unhanldedState.pop_back();
        for (auto &sym : bnf.symbolSet) {
            const CLRItemCollection& col(ID2Collection[state]);
            CLRItemCollection newCol;
            transToNewItemCollection(bnf, col, newCol, sym);
            closure(bnf, newCol);
            if (!newCol.items.empty()) {
                int ns;
                if (addCollection(newCol, ns)) {
                    unhanldedState.push_back(ns);
                }
                dfa[state][sym] = ns;
            }
        }
    }
}
开发者ID:GHScan,项目名称:DailyProjects,代码行数:37,代码来源:CLRParser.cpp

示例7: TJSCreateArrayObject

//----------------------------------------------------------------------
// 構造体比較関数
tTJSVariant
ScriptsAdd::clone(tTJSVariant obj)
{
	// タイプがオブジェクトなら細かく判定
	if (obj.Type() == tvtObject) {

		tTJSVariantClosure &o1 = obj.AsObjectClosureNoAddRef();
		
		// Arrayの複製
		if (o1.IsInstanceOf(0, NULL, NULL, L"Array", NULL)== TJS_S_TRUE) {
			iTJSDispatch2 *array = TJSCreateArrayObject();
			tTJSVariant o1Count;
			(void)o1.PropGet(0, L"count", &countHint, &o1Count, NULL);
			tjs_int count = o1Count;
			tTJSVariant val;
			tTJSVariant *args[] = {&val};
			for (tjs_int i = 0; i < count; i++) {
				(void)o1.PropGetByNum(TJS_IGNOREPROP, i, &val, NULL);
				val = ScriptsAdd::clone(val);
				static tjs_uint addHint = 0;
				(void)array->FuncCall(0, TJS_W("add"), &addHint, 0, 1, args, array);
			}
			tTJSVariant result(array, array);
			array->Release();
			return result;
		}
		
		// Dictionaryの複製
		if (o1.IsInstanceOf(0, NULL, NULL, L"Dictionary", NULL)== TJS_S_TRUE) {
			iTJSDispatch2 *dict = TJSCreateDictionaryObject();
			DictMemberCloneCaller *caller = new DictMemberCloneCaller(dict);
			tTJSVariantClosure closure(caller);
			o1.EnumMembers(TJS_IGNOREPROP, &closure, NULL);
			caller->Release();
			tTJSVariant result(dict, dict);
			dict->Release();
			return result;
		}

		// cloneメソッドの呼び出しに成功すればそれを返す
		tTJSVariant result;
		static tjs_uint cloneHint = 0;
		if (o1.FuncCall(0, L"clone", &cloneHint, &result, 0, NULL, NULL)== TJS_S_TRUE) {
			return result;
		}
	}
	
	return obj;
}
开发者ID:xmoeproject,项目名称:X-moe,代码行数:51,代码来源:Main.cpp

示例8: nds

vector<const pddl_type *> TypeHierarchy::accumulateAll(const pddl_type * t)
{
	vector<const pddl_type *> nds(1,t);
	PTypeRef tt(t);
	GI gi = downGraph.find(&tt);
	if(gi == downGraph.end()) return nds;
	Nodes ns;
	PTypeRef pt(0);
	closure(downGraph,gi,ns,gi,&pt);
	for(Nodes::const_iterator i = ns.begin();i != ns.end();++i)
	{
		nds.push_back(***i);
	};
	return nds;
};
开发者ID:mdrichar,项目名称:POGDDL,代码行数:15,代码来源:typecheck.cpp

示例9: updateClosures

/**
 * Replace closure that point to oldEnv with closure on newEnv
 */
static void updateClosures(vector<Tree>& clos, Tree oldEnv, Tree newEnv)
{
  for(unsigned int i = 0; i < clos.size(); i++)
  {
    Tree exp, genv, visited, lenv;

    if(isClosure(clos[i], exp, genv, visited, lenv))
    {
      if(lenv == oldEnv)
      {
        clos[i] = closure(exp, genv, visited, newEnv);
      }
    }
  }
}
开发者ID:Ace17,项目名称:faust,代码行数:18,代码来源:environment.cpp

示例10: char

/*
 * @NAME: collection_filter
 * @DESC: Igual a la funcion filter de haskell
 */
void *collection_filter( t_list* list, char (*closure)(void*, void*),void *arg){
	t_list *listaAux=collection_list_create();
	t_link_element *element = list->head;
	sem_wait( &list->semaforo );
	while( element != NULL ){
		if(closure(element->data, arg)){
			void *newData=malloc(sizeof(element->data));
			memcpy(newData,element->data,sizeof(element->data));
			//newData=element->data;
			collection_list_add(listaAux,newData);
		}
		element = element->next;
	}
	sem_post( &list->semaforo );
	return(listaAux);
}
开发者ID:martoo6,项目名称:tp-so-fuse,代码行数:20,代码来源:utilidades.c

示例11: va_start

/*
 * @NAME: collection_map2
 * @DESC: Igual a la funcion map de haskell pero con argumentos variables
 */
void *collection_map2( t_list* list, void *(*closure)(void*, ...),...){
	va_list args_list;
	va_start(args_list,*closure);
	t_list *listaAux=collection_list_create();
	t_link_element *element = list->head;
	sem_wait( &list->semaforo );
	while( element != NULL ){
		void *newData=malloc(sizeof(*closure));
		//newData=closure(element->data, args_list);
		memcpy(newData,closure(element->data, args_list),sizeof(*closure));
		collection_list_add(listaAux,newData);
		element = element->next;
	}
	sem_post( &list->semaforo );
	return(listaAux);
}
开发者ID:martoo6,项目名称:tp-so-fuse,代码行数:20,代码来源:utilidades.c

示例12: closure

void closure( const Entity & e_from , std::vector<Entity*> & eset )
{
  PairIterRelation rel = e_from.relations();
  for ( ; rel ; ++rel ) {
    if ( rel->forward() ) {
      Entity * const e = rel->entity();
      std::vector<Entity*>::iterator i = eset.begin();
      std::vector<Entity*>::iterator j = eset.end();
      i = std::lower_bound( i , j , e , LessEntityPointer() );
      if ( i == j || e != *i ) {
        eset.push_back( e );
        closure( *e , eset );
      }
    }
  }
}
开发者ID:00liujj,项目名称:trilinos,代码行数:16,代码来源:MeshRelation.cpp

示例13: cairo_surface_destroy

bool	GR_CocoaImage::convertFromBuffer(const UT_ByteBuf* pBB, const std::string & mimetype, 
                                         UT_sint32 iDisplayWidth, UT_sint32 iDisplayHeight)
{
	const char *buffer = (const char *) pBB->getPointer(0);
	UT_uint32 buflen = pBB->getLength();


	if(mimetype == "image/png") {

		if (buflen < 6) {
			return false;
		}

		char str1[10] = "\211PNG";
		char str2[10] = "<89>PNG";

		if ( !(strncmp(buffer, str1, 4)) || !(strncmp(buffer, str2, 6)) )
		{
			m_grtype = GRT_Raster;
			if(m_surface) {
				cairo_surface_destroy(m_surface);
			}
			
			_PNG_read_state closure(pBB);
			m_surface = cairo_image_surface_create_from_png_stream (&_UT_ByteBuf_PNG_read, &closure);
			if(CAIRO_SURFACE_TYPE_IMAGE == cairo_surface_get_type(m_surface)) 
			{
				if((cairo_image_surface_get_width(m_surface) != iDisplayWidth) ||
					(cairo_image_surface_get_height(m_surface) != iDisplayHeight)) {
					// needs resize.
					
					cairo_surface_t *rescaled = _rescaleTo(m_surface, iDisplayWidth, iDisplayHeight);
					cairo_surface_destroy(m_surface);
					m_surface = rescaled;
				}
			}
			setDisplaySize(iDisplayWidth, iDisplayHeight);
			return true;
		}
	}
	// Otherwise, assume SVG. Do scaling when drawing; save size for then:
	m_grtype = GRT_Vector;

	setDisplaySize(iDisplayWidth, iDisplayHeight);

	return true;
}
开发者ID:Distrotech,项目名称:abiword,代码行数:47,代码来源:gr_CocoaImage.cpp

示例14: closure

vector<LR0Item> CFG::goTo(const vector<LR0Item>& is, const string& x)
{
	vector<LR0Item> js;

	for(size_t i = 0; i < is.size(); ++i)
	{
		Production pr = p[is[i].productionIndex];
		if(!(pr.right.size() == 1 && pr.right[0] == "")
			&& is[i].dotPosition < pr.right.size()
			&& pr.right[is[i].dotPosition] == x)
		{
			js.push_back(LR0Item(is[i].productionIndex, is[i].dotPosition + 1));
		}
	}
	
	return closure(js);
}
开发者ID:ZephyrZhng,项目名称:code_ub,代码行数:17,代码来源:CFG.cpp

示例15: prawyArgument

//----------------------------------------------------------------
string prawyArgument(const string & text)
{
	if(text.empty())
	{
		return "";
	}

	if(text[0] == '(')
	{
		size_t pozycja = closure(text, 0);
		return text.substr(0, pozycja);
	}
	else
	{
		size_t pozycja = text.find_first_of("*/+-()");
		return text.substr(0, pozycja - 1);
	}
}
开发者ID:kipu44,项目名称:Fortran-IV-parser,代码行数:19,代码来源:utils.cpp


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