• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ List_size函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: IoAudioMixer_isActive

int IoAudioMixer_isActive(IoAudioMixer *self)
{
	return List_size(DATA(self)->sounds) || 
	List_size(DATA(self)->soundsToRemove) ||
	List_size(DATA(self)->events) ||
	List_size(DATA(self)->activeEvents);
}
开发者ID:ADTSH,项目名称:io,代码行数:7,代码来源:IoAudioMixer.c


示例2: dns

static void dns(Dict* dns, struct Context* ctx, struct Except* eh)
{
    List* servers = Dict_getList(dns, String_CONST("servers"));
    int count = List_size(servers);
    for (int i = 0; i < count; i++) {
        String* server = List_getString(servers, i);
        if (!server) {
            Except_throw(eh, "dns.servers[%d] is not a string", i);
        }
        Dict* d = Dict_new(ctx->alloc);
        Dict_putString(d, String_CONST("addr"), server, ctx->alloc);
        rpcCall(String_CONST("RainflyClient_addServer"), d, ctx, ctx->alloc);
    }

    List* keys = Dict_getList(dns, String_CONST("keys"));
    count = List_size(keys);
    for (int i = 0; i < count; i++) {
        String* key = List_getString(keys, i);
        if (!key) {
            Except_throw(eh, "dns.keys[%d] is not a string", i);
        }
        Dict* d = Dict_new(ctx->alloc);
        Dict_putString(d, String_CONST("ident"), key, ctx->alloc);
        rpcCall(String_CONST("RainflyClient_addKey"), d, ctx, ctx->alloc);
    }

    int64_t* minSigs = Dict_getInt(dns, String_CONST("minSignatures"));
    if (minSigs) {
        Dict* d = Dict_new(ctx->alloc);
        Dict_putInt(d, String_CONST("count"), *minSigs, ctx->alloc);
        rpcCall(String_CONST("RainflyClient_minSignatures"), d, ctx, ctx->alloc);
    }
}
开发者ID:bavarin-fleetfoot,项目名称:cjdns,代码行数:33,代码来源:Configurator.c


示例3: getSomething

static void getSomething(Dict* args,
                         struct RouteGen_admin_Ctx* ctx,
                         String* txid,
                         struct Allocator* requestAlloc,
                         Dict* genRoutes)
{
    int page = getIntVal(args, String_CONST("page"));
    List* routes;
    if (getIntVal(args, String_CONST("ip6"))) {
        routes = Dict_getList(genRoutes, String_CONST("ipv6"));
    } else {
        routes = Dict_getList(genRoutes, String_CONST("ipv4"));
    }
    Assert_true(routes);
    List* outList = List_new(requestAlloc);
    bool more = false;
    for (int i = page * ROUTES_PER_PAGE, j = 0; i < List_size(routes) && j < ROUTES_PER_PAGE; j++) {
        String* route = List_getString(routes, i);
        Assert_true(route);
        List_addString(outList, route, requestAlloc);
        if (++i >= List_size(routes)) {
            more = false;
            break;
        }
        more = true;
    }
    Dict* out = Dict_new(requestAlloc);
    if (more) {
        Dict_putInt(out, String_new("more", requestAlloc), 1, requestAlloc);
    }
    Dict_putList(out, String_new("routes", requestAlloc), outList, requestAlloc);
    Admin_sendMessage(out, txid, ctx->admin);
}
开发者ID:interfect,项目名称:cjdns,代码行数:33,代码来源:RouteGen_admin.c


示例4: IoList_compare

int IoList_compare(IoList *self, IoList *otherList)
{
	if (!ISLIST(otherList))
	{
		return IoObject_defaultCompare(self, otherList);
	}
	else
	{
		size_t s1 =  List_size(DATA(self));
		size_t s2 =  List_size(DATA(otherList));
		size_t i;

		if (s1 != s2)
		{
			return s1 > s2 ? 1 : -1;
		}

		for (i = 0; i < s1; i ++)
		{
			IoObject *v1 = LIST_AT_(DATA(self), i);
			IoObject *v2 = LIST_AT_(DATA(otherList), i);
			int c = IoObject_compare(v1, v2);

			if (c)
			{
				return c;
			}
		}
	}
	return 0;
}
开发者ID:doublec,项目名称:io,代码行数:31,代码来源:IoList.c


示例5: START_TEST

END_TEST


START_TEST (test_List_findIf)
{
  List_t *list;

  const char *foo = "foo";
  const char *bar = "bar";
  const char *baz = "baz";
  const char *bop = "bop";


  List_add(L, (void *) foo);
  List_add(L, (void *) bop);

  list = List_findIf(L, myPredicate);

  fail_unless( list            != NULL );
  fail_unless( List_size(list) == 0    );

  List_free(list);

  List_add(L, (void *) foo);
  List_add(L, (void *) bar);
  List_add(L, (void *) baz);
  List_add(L, (void *) bop);

  list = List_findIf(L, myPredicate);

  fail_unless( list              != NULL );
  fail_unless( List_size(list)   == 2    );
  fail_unless( List_get(list, 0) == bar  );
  fail_unless( List_get(list, 1) == baz  );

  List_free(list);

  List_add(L, (void *) baz);

  list = List_findIf(L, myPredicate);

  fail_unless( list              != NULL );
  fail_unless( List_size(list)   == 3    );
  fail_unless( List_get(list, 0) == bar  );
  fail_unless( List_get(list, 1) == baz  );
  fail_unless( List_get(list, 2) == baz  );

  List_free(list);
}
开发者ID:TotteKarlsson,项目名称:roadrunner,代码行数:49,代码来源:TestList.c


示例6: authorizedPasswords

static void authorizedPasswords(List* list, struct Context* ctx)
{
    uint32_t count = List_size(list);
    for (uint32_t i = 0; i < count; i++) {
        Dict* d = List_getDict(list, i);
        Log_info(ctx->logger, "Checking authorized password %d.", i);
        if (!d) {
            Log_critical(ctx->logger, "Not a dictionary type %d.", i);
            exit(-1);
        }
        String* passwd = Dict_getString(d, String_CONST("password"));
        if (!passwd) {
            Log_critical(ctx->logger, "Must specify a password %d.", i);
            exit(-1);
        }
    }

    Log_info(ctx->logger, "Flushing existing authorized passwords");
    rpcCall(String_CONST("AuthorizedPasswords_flush"), NULL, ctx, ctx->alloc);

    for (uint32_t i = 0; i < count; i++) {
        Dict* d = List_getDict(list, i);
        String* passwd = Dict_getString(d, String_CONST("password"));
        Log_info(ctx->logger, "Adding authorized password #[%d].", i);

        Dict args = Dict_CONST(
            String_CONST("authType"), Int_OBJ(1), Dict_CONST(
            String_CONST("password"), String_OBJ(passwd), NULL
        ));
        struct Allocator* child = ctx->alloc->child(ctx->alloc);
        rpcCall(String_CONST("AuthorizedPasswords_add"), &args, ctx, child);
        child->free(child);
    }
}
开发者ID:TrueShiftBlue,项目名称:cjdns,代码行数:34,代码来源:Configurator.c


示例7: Datum_find_

long Datum_find_(Datum *self, void *delimsList, size_t startIndex) 
{
	List *delims = (List *)delimsList;
	List *results = List_new();
	size_t i, last = 0;
	
	if (startIndex > self->size) return -1;
	
	for (i = startIndex; i < self->size; i ++)
	{
		Datum d = Datum_datumAt_(self, i);
		size_t j; 
		
		for (j = 0; j < (size_t)List_size(delims); j ++)
		{
			Datum *delim = (Datum *)List_at_(delims, j);
			
			if (Datum_beginsWith_(&d, delim))
			{
				return i;
			}
		}
	}
	
	return -1;
}
开发者ID:IceAssassin,项目名称:skipdbv2,代码行数:26,代码来源:Datum.c


示例8: List_new

void *Datum_split_(Datum *self, void *delimsList) /* returns a List */
{
	List *delims = (List *)delimsList;
	List *results = List_new();
	size_t i, last = 0;
	
	for (i = 0; i < self->size; i ++)
	{
		Datum d = Datum_datumAt_(self, i);
		size_t j; 
		
		for (j = 0; j < (size_t)List_size(delims); j ++)
		{
			Datum *delim = (Datum *)List_at_(delims, j);
			
			if (Datum_beginsWith_(&d, delim))
			{
                                List_append_(results, Datum_newFrom_to_(self, last, i));
				
				last = i + delim->size;
				i = last - 1; /* since for() will increment it */
				break;
			}
		}
	}
	
	if (last != self->size)
	{
		List_append_(results, Datum_newFrom_to_(self, last, self->size));
	}
	
	return results;
}
开发者ID:IceAssassin,项目名称:skipdbv2,代码行数:33,代码来源:Datum.c


示例9: IoLexer_lex

int IoLexer_lex(IoLexer *self)
{
	IoLexer_clear(self);
	IoLexer_pushPos(self);

	IoLexer_messageChain(self);

	if (*(self->current))
	{
		//printf("Lexing error after: ");
		//IoLexer_printLast_(self, 30);
		//printf("\n");

		if (!self->errorToken)
		{
			if (List_size(self->tokenStream))
			{
				self->errorToken = IoLexer_currentToken(self);
			}
			else
			{
				self->errorToken = IoLexer_addTokenString_length_type_(self, self->current, 30, NO_TOKEN);
			}

			IoToken_error_(self->errorToken, "Syntax error near this location");
		}
		return -1;
	}
	return 0;
}
开发者ID:Akiyah,项目名称:io,代码行数:30,代码来源:IoLexer.c


示例10: Levels_new

IoMessage *IoMessage_opShuffle(IoMessage *self, IoObject *locals, IoMessage *m)
{
	Levels *levels = Levels_new(self);
	List *expressions = List_new();

	List_push_(expressions, self);

	while (List_size(expressions) >= 1)
	{
		IoMessage *n = List_pop(expressions);

		do
		{
			Levels_attach(levels, n, expressions);
			List_appendSeq_(expressions, DATA(n)->args);
		} while ((n = DATA(n)->next));

		Levels_nextMessage(levels);
	}

	List_free(expressions);
	Levels_free(levels);

	return self;
}
开发者ID:ADTSH,项目名称:io,代码行数:25,代码来源:IoMessage_opShuffle.c


示例11: EncodingScheme_fromList

struct EncodingScheme* EncodingScheme_fromList(List* scheme, struct Allocator* alloc)
{
    struct EncodingScheme* list = Allocator_malloc(alloc, sizeof(struct EncodingScheme));
    list->count = List_size(scheme);
    list->forms = Allocator_malloc(alloc, sizeof(struct EncodingScheme_Form) * list->count);
    for (int i = 0; i < (int)list->count; i++) {
        Dict* form = List_getDict(scheme, i);
        uint64_t* prefixLen = Dict_getInt(form, String_CONST("prefixLen"));
        uint64_t* bitCount = Dict_getInt(form, String_CONST("bitCount"));
        String* prefixStr = Dict_getString(form, String_CONST("prefix"));
        if (!prefixLen || !bitCount || !prefixStr || prefixStr->len != 8) {
            return NULL;
        }
        uint32_t prefix_be;
        if (Hex_decode((uint8_t*)&prefix_be, 4, prefixStr->bytes, 8) != 4) {
            return NULL;
        }
        list->forms[i].prefixLen = *prefixLen;
        list->forms[i].bitCount = *bitCount;
        list->forms[i].prefix = Endian_bigEndianToHost32(prefix_be);
    }
    if (!EncodingScheme_isSane(list)) {
        return NULL;
    }
    return list;
}
开发者ID:AdUser,项目名称:cjdns,代码行数:26,代码来源:EncodingScheme.c


示例12: LongNum_multi

void LongNum_multi(LongNum **num1, LongNum **num2, LongNum **result)
{
	node *temp1 = (*num1)->digits;
    node *temp2 = (*num2)->digits;
    node *temp = NULL;
    LongNum *temp1S = LongNum_empty ();
    LongNum *temp2S = LongNum_empty ();
    LongNum *tempResult = LongNum_empty ();

    int curr = 0, fact = 0, i = 0, point = 0;

    if (List_size(&(*num1)->digits) > List_size(&(*num2)->digits))
	{
		while (temp2 != NULL)
	    {
			fact = temp2->val;
		    while (temp1 != NULL)
		    {
				curr = curr + fact * temp1->val;
			    List_additionElement (&temp1S->digits, curr % 10);
			    curr = curr / 10;
			    temp1 = temp1->next;
		    }
		    if (curr) List_additionElement (&temp1S->digits, curr);
		    LongNum_revert(&temp1S);
            for (i = 0; i < curr; i++) (&temp1S->digits, 0);
		    LongNum_sum (&temp1S, &temp2S,&tempResult);
		    temp = tempResult->digits;
		    while (temp != NULL)
		    {
				fact = (int)*(&temp->val);
			    List_additionElement (&(*result)->digits, fact);
			    temp = temp->next;
		    }
		    point = point + 1;
		    temp2 = temp2->next;
	   }
	   temp = temp2S->digits;
	   while (temp != NULL)
	   {
			fact = (int)*(&temp->val);
			List_additionElement (&(*result)->digits, fact);
			temp = temp->next;
	   }
    }
    return;
}
开发者ID:AnnaAK,项目名称:Homeworks,代码行数:47,代码来源:LongNum.c


示例13: Allocate_list

/* Return value negative indicates failure */
int Allocate_list(
        int           list_size  /* in  */, 
        LOCAL_LIST_T* local_keys /* out */) {

    List_allocated_size(local_keys) = list_size/p;
    List_size(local_keys) = list_size/p;
    return 0;
} /* Allocate_list */
开发者ID:cyliustack,项目名称:benchmark,代码行数:9,代码来源:sort_2.c


示例14: IO_METHOD

IO_METHOD(IoObject, recycledObjectCount)
{
	/*doc System recycledObjectCount
	Returns the current number of objects being held for recycling.
	*/

	return IONUMBER(List_size(IOSTATE->recycledObjects));
}
开发者ID:Habaut,项目名称:GameBindings,代码行数:8,代码来源:IoSystem.c


示例15: IoMessage_assertArgCount_receiver_

void IoMessage_assertArgCount_receiver_(IoMessage *self, int n, IoObject *receiver)
{
	if (List_size(DATA(self)->args) < n)
	{
		IoState_error_(IOSTATE, self, "[%s %s] requires %i arguments\n",
					   IoObject_name(receiver), CSTRING(DATA(self)->name), n);
	}
}
开发者ID:mikedouglas,项目名称:io,代码行数:8,代码来源:IoMessage.c


示例16: remove_mid

void remove_mid(List *list) {
    List_push(list, 12);
    List_push(list, 7);
    List_push(list, 8);
    List_remove(list, List_index(list, 1));
    assert(List_size(list) == 2);
    assert(List_first(list)->data == 12);
    assert(List_last(list)->data == 8);
}
开发者ID:nymacro,项目名称:tentcl,代码行数:9,代码来源:list.c


示例17: IoObject_getSlot_

IoObject *IoCFFIFunction_call(IoCFFIFunction *self, IoObject *locals, IoMessage *m)
{
	IoCFFILibrary *library;
	const char *funName;
	void *funPointer, **funArgVals, *funRetVal;
	ffi_type **funArgTypes, *funRetType;
	ffi_cif *funInterface;
	int funArgCount, i;
	ffi_status status;
	IoObject *returnValAsObj, *funRetTypeObject, *o;
	List *funArgTypeObjects;

	library = IoObject_getSlot_(self, IOSYMBOL("library"));
	funInterface = &(DATA(self)->interface);
	funName = CSTRING(IoObject_getSlot_(self, IOSYMBOL("name")));
	funPointer = IoCFFILibrary_rawGetFuctionPointer_(library, funName);
	funArgTypeObjects = IoList_rawList(IoObject_getSlot_(self, IOSYMBOL("argumentTypes")));
	funRetTypeObject = IoObject_getSlot_(self, IOSYMBOL("returnType"));

	funArgCount = (int)List_size(funArgTypeObjects);
	funArgTypes = calloc(funArgCount, sizeof(ffi_type *));
	for (i = 0; i < funArgCount; i++)
	{
		o = List_at_(funArgTypeObjects, i);
		funArgTypes[i] = IoCFFIDataType_ffiType(o);
	}
	funRetType = IoCFFIDataType_ffiType(funRetTypeObject);

	status = ffi_prep_cif(funInterface, FFI_DEFAULT_ABI, funArgCount, funRetType, funArgTypes);
	if (status != FFI_OK)
	{
		printf("\n\nUh oh.  Something went wrong in IoCFFIFunction_call.\n\n");
		free(funArgTypes);
		return IONIL(self);
	}

	funArgVals = calloc(funArgCount, sizeof(void *));
	funRetVal = calloc(1, funRetType->size);
	IoState_pushCollectorPause(IOSTATE);
	{
		for (i = 0; i < funArgCount; i++)
		{
			o = IoMessage_locals_valueArgAt_(m, locals, i);
			funArgVals[i] = IoCFFIDataType_ValuePointerFromObject_(o);
		}

		ffi_call(funInterface, funPointer, funRetVal, funArgVals);
		returnValAsObj = IoCFFIDataType_objectFromData_(funRetTypeObject, funRetVal);
	}
	IoState_popCollectorPause(IOSTATE);

	free(funArgTypes);
	free(funArgVals);
	free(funRetVal);

	return returnValAsObj;
}
开发者ID:anthem,项目名称:io,代码行数:57,代码来源:IoCFFIFunction.c


示例18: DATA

IoObject *IoAudioMixer_removeAllSounds(IoAudioMixer *self, IoObject *locals, IoMessage *m)
{
	List *sounds = DATA(self)->sounds;
	while (List_size(sounds))
	{ 
		IoAudioMixer_justRemoveSound_(self, List_at_(sounds, 0)); 
	}
	return self;
}
开发者ID:ADTSH,项目名称:io,代码行数:9,代码来源:IoAudioMixer.c


示例19: Get_local_keys

void Get_local_keys(LOCAL_LIST_T* local_keys) {
    int i;

    /* Seed the generator */
    srand(my_rank);

    for (i = 0; i < List_size(local_keys);  i++)
        Insert_key(rand() % KEY_MOD, i, local_keys);
} /* Get_local_keys */
开发者ID:cyliustack,项目名称:benchmark,代码行数:9,代码来源:sort_2.c


示例20: IoLexer_printTokens

void IoLexer_printTokens(IoLexer *self)
{
	int i;

	for (i = 0; i < List_size(self->tokenStream); i ++)
	{
		IoToken *t = List_at_(self->tokenStream, i);

		printf("'%s'", t->name);
		printf(" %s ", IoToken_typeName(t));

		if (i < List_size(self->tokenStream) - 1)
		{
			printf(", ");
		}
	}

	printf("\n");
}
开发者ID:Akiyah,项目名称:io,代码行数:19,代码来源:IoLexer.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Listen函数代码示例发布时间:2022-05-30
下一篇:
C++ List_push函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap