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


C++ List_size函数代码示例

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


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


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