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

C++ List_new函数代码示例

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

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



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

示例1: IoObject_rawClonePrimitive

IoAudioMixer *IoAudioMixer_rawClone(IoAudioMixer *proto) 
{ 
	IoObject *self = IoObject_rawClonePrimitive(proto);
	self->data = cpalloc(proto->data, sizeof(IoAudioMixerData));
	
	DATA(self)->ioBuffer = IoSeq_new(IOSTATE);
	DATA(self)->buffer = IoSeq_rawUArray(DATA(self)->ioBuffer);
	DATA(proto)->mixBuffer = UArray_new();
	DATA(self)->writeMessage = 
		IoMessage_newWithName_label_(IOSTATE, 
							    IOSYMBOL("write"), 
							    IOSYMBOL("AudioMixer"));
	IoMessage_setCachedArg_to_(DATA(self)->writeMessage, 0, DATA(self)->ioBuffer);
	
	DATA(self)->nonBlockingWriteMessage = 
		IoMessage_newWithName_label_(IOSTATE, 
							    IOSYMBOL("nonBlockingWrite"), 
							    IOSYMBOL("AudioMixer"));
	IoMessage_setCachedArg_to_(DATA(self)->nonBlockingWriteMessage, 0, DATA(self)->ioBuffer);
	
	DATA(self)->sounds = List_new();
	DATA(self)->soundsToRemove = List_new();
	DATA(self)->events = List_new();
	DATA(self)->activeEvents = List_new();
	DATA(self)->volume = DATA(self)->volume;
	
	DATA(self)->soundTouch = SoundTouch_init();
	SoundTouch_setSampleRate(DATA(self)->soundTouch, 44100);
	SoundTouch_setChannels(DATA(self)->soundTouch, 2);
	DATA(self)->tempo = 1.0;
	IoState_addValue_(IOSTATE, self);
	return self; 
}
开发者ID:ADTSH,项目名称:io,代码行数:33,代码来源:IoAudioMixer.c


示例2: s16_svc_new

svc_t * s16_svc_new ()
{
    svc_t * newSvc = calloc (1, sizeof (svc_t));
    newSvc->properties = List_new ();
    newSvc->instances = List_new ();
    return newSvc;
}
开发者ID:Prospero86,项目名称:ServiceManager,代码行数:7,代码来源:object.c


示例3: Post_new

Post_t Post_new(int xCoord, int yCoord){
    Post_t self = (Post_t) malloc(sizeof(struct Post));
    self->wantedCars = List_new();
    self->wantedCarEvents = List_new();
    self->transists = List_new();
    self->xCoord = xCoord;
    self->yCoord = yCoord;
    return self;
}
开发者ID:Silchenko-Nikita,项目名称:Silchenko-Nikita-s,代码行数:9,代码来源:main.c


示例4: ASSERT

// Creates a new RULE CONDITION GRAPH - it creates a RCG node for every tuple variable
// Takes the tuple variable and the data source list along with the number of tuple variables
// as the input
RCG *RCG_new(int num_tuple_var, List *tuple_var_list, List *datasrc_list)
{
	RCG *graph;
	int i;
	ListElement *cursor1, *cursor2;
	RCG_node *node;
	void *tuple_var_name, *datasrc_name;

	ASSERT(tuple_var_list);
	ASSERT(datasrc_list);
    
	graph = (RCG *)tman_malloc(sizeof(RCG));	
	memset(graph, '\0', sizeof(RCG));

	graph->type = RCG_TYPE;
	
	graph->num_tuple_variables = num_tuple_var;
	graph->nodes = List_new();
	graph->catch_all = List_new();

	
	if (!num_tuple_var)
	{
		/* The RCG does not have any tuple variables. For ex.
		** when 1 = 1.
		*/
		return graph;
	}

	/* create the individual nodes -- one for each tuple variable*/
	node = RCG_node_new();
	tuple_var_name = (char *)List_getFirst(tuple_var_list, &cursor1);
   	datasrc_name = (char *)List_getFirst(datasrc_list, &cursor2);

	node->tuple_variable_name = get_chars(tuple_var_name);
    node->datasrc_name = get_chars(datasrc_name);

    /* Insert the node into the RCG */
	List_insertElement(graph->nodes, node);
	
	for (i = 1; i < num_tuple_var; i++)
	{
		/* create the individual nodes */
		node = RCG_node_new();
		tuple_var_name = (char *)List_getNext(&cursor1);
   		datasrc_name = (char *)List_getNext(&cursor2);

		node->tuple_variable_name = get_chars(tuple_var_name);
        node->datasrc_name = get_chars(datasrc_name);

		/* Insert the node into the RCG */
		List_insertElement(graph->nodes, node);
	}

    return graph;
}
开发者ID:aevernon,项目名称:triggerman,代码行数:59,代码来源:rcg.c


示例5: sizeof

IoLexer *IoLexer_new(void)
{
	IoLexer *self = (IoLexer *)io_calloc(1, sizeof(IoLexer));
	self->s = (char *)io_calloc(1, 1);
	self->s[0] = 0;
	self->posStack = Stack_new();
	self->tokenStack = Stack_new();
	self->tokenStream = List_new();
	self->charLineIndex = List_new();
	return self;
}
开发者ID:Akiyah,项目名称:io,代码行数:11,代码来源:IoLexer.c


示例6: IoObject_rawClonePrimitive

IoODEWorld *IoODEWorld_rawClone(IoODEWorld *proto)
{
	IoObject *self = IoObject_rawClonePrimitive(proto);
	IoObject_setDataPointer_(self, calloc(1, sizeof(IoODEWorldData)));
	WORLDID = dWorldCreate();
	DATA(self)->bodies = List_new();
	DATA(self)->jointGroups = List_new();
	IoObject_inlineSetSlot_to_(self, IOSYMBOL("Body"), IoODEBody_newBodyProtoWithWorld(IOSTATE, self));
	IoObject_inlineSetSlot_to_(self, IOSYMBOL("JointGroup"), IoODEJointGroup_newJointGroupProtoWithWorld(IOSTATE, self));
	return self;
}
开发者ID:ADTSH,项目名称:io,代码行数:11,代码来源:IoODEWorld.c


示例7: Command_new

T Command_new(const char *path, const char *arg0, ...) {
        T C;
        if (! File_exist(path))
                THROW(AssertException, "File '%s' does not exist", path ? path : "null");
        NEW(C);
        C->env = List_new();
        C->args = List_new();
        List_append(C->env, Str_dup(Command_Path));
        va_list ap;
        va_start(ap, arg0);
        buildArgs(C, path, arg0, ap);
        va_end(ap);
        return C;
}
开发者ID:cention-nazri,项目名称:monit-5.5,代码行数:14,代码来源:Command.c


示例8: main

int main(int argc, char **argv)
{
  List_t l = List_new();
  fprintf(stdout, "test List...\n");
  int i;
  for (i = 0; i < 100; i++) {
    List_addFirst(l, i);
  }

  fprintf(stdout, "List_getFirst\n");
  int r = (int) List_getFirst(l);
  assert(r == 99);

  fprintf(stdout, "List_getIndexOf\n");
  for (i = 0; i < 100; i++) {
    r = (int) List_getIndexOf(l, i);
    assert(r == (99 - i));

  }

  fprintf(stdout, "List_addLast\n");
  List_addLast(l, 200);
  r = (int) List_getIndexOf(l, 100);
  assert(r == 200);

  fprintf(stdout, "List_size\n");
  r = List_size(l);
  assert(r == 101);

  fprintf(stdout, "List_isEmpty\n");
  r = List_isEmpty(l);
  assert(r == 0);
  List_t l2 = List_new();
  r = List_isEmpty(l2);
  assert(r == 1);

  fprintf(stdout, "List_remove\n");
  for (i = 0; i < 100; i++) {
    r = (int) List_removeFirst(l);
    assert(r == (99 - i));
  }
  r = (int) List_removeFirst(l);
  assert(r == 200);
  r = List_isEmpty(l);
  assert(r == 1);


  return 0;
}
开发者ID:qc1iu,项目名称:c-lib,代码行数:49,代码来源:list-test.c


示例9: RCG_node_new

RCG_node * RCG_node_new(void)
{
	RCG_node *node;

	node = (RCG_node *) tman_malloc(sizeof(RCG_node));

	memset(node, '\0', sizeof(RCG_node));

	node->selection_predicates_list = List_new();
	node->join_predicates_list = List_new();
	node->already_inserted = 0;
	node->decorated_selection_predicate = NULL;
    node->type = RCG_NODE_TYPE;
	return node;
}
开发者ID:aevernon,项目名称:triggerman,代码行数:15,代码来源:rcg.c


示例10: Context_intersect_clip_rect

//Update the clipping rectangles to only include those areas within both the
//existing clipping region AND the passed Rect
void Context_intersect_clip_rect(Context* context, Rect* rect) {

    int i;
    List* output_rects;
    Rect* current_rect;
    Rect* intersect_rect;
 
    context->clipping_on = 1;

    if(!(output_rects = List_new()))
        return;

    for(i = 0; i < context->clip_rects->count; i++) {

        current_rect = (Rect*)List_get_at(context->clip_rects, i);
        intersect_rect = Rect_intersect(current_rect, rect);

        if(intersect_rect)
            List_add(output_rects, (Object*)intersect_rect);
    }

    //Delete the original rectangle list
    Object_delete((Object*)context->clip_rects);

    //And re-point it to the new one we built above
    context->clip_rects = output_rects;

    //Free the input rect
    Object_delete((Object*)rect);
}
开发者ID:JMarlin,项目名称:P5-Redux,代码行数:32,代码来源:context.c


示例11: adminInterfaces

static void adminInterfaces(Dict* args,
                            void* vcontext,
                            String* txid,
                            struct Allocator* alloc)
{
    struct Context* context = Identity_check((struct Context*)vcontext);

    int64_t* page = Dict_getIntC(args, "page");
    int i = (page) ? *page * ENTRIES_PER_PAGE : 0;

    int count = InterfaceController_ifaceCount(context->ic);
    //int count = InterfaceController_getIface(context->ic, alloc, &stats);

    List* list = List_new(alloc);
    for (int counter = 0; i < count && counter++ < ENTRIES_PER_PAGE; i++) {
        struct InterfaceController_Iface* iface = InterfaceController_getIface(context->ic, i);
        Dict* d = Dict_new(alloc);
        Dict_putIntC(d, "ifNum", iface->ifNum, alloc);
        Dict_putStringC(d, "name", iface->name, alloc);
        char* bs = InterfaceController_beaconStateString(iface->beaconState);
        Dict_putStringCC(d, "beaconState", bs, alloc);
        List_addDict(list, d, alloc);
    }

    Dict* resp = Dict_new(alloc);
    Dict_putListC(resp, "ifaces", list, alloc);
    Dict_putIntC(resp, "total", count, alloc);
    if (i < count) { Dict_putIntC(resp, "more", 1, alloc); }
    Admin_sendMessage(resp, txid, context->admin);
}
开发者ID:cjdelisle,项目名称:cjdns,代码行数:30,代码来源:InterfaceController_admin.c


示例12: searchResponse

static void searchResponse(struct RouterModule_Promise* promise,
                           uint32_t lag,
                           struct Address* from,
                           Dict* responseDict)
{
    struct Search* search = Identity_check((struct Search*) promise->userData);
    struct Allocator* alloc = Allocator_child(search->alloc);

    Dict* resp = Dict_new(alloc);
    if (!from) {
        Dict_putStringCC(resp, "error", "none", alloc);
        Dict_putIntC(resp, "complete", 1, alloc);
        Admin_sendMessage(resp, search->txid, search->ctx->admin);
        Allocator_free(alloc);
        return;
    }

    String* fromStr = Address_toString(from, alloc);
    Dict_putStringC(resp, "from", fromStr, alloc);

    Dict_putIntC(resp, "ms", lag, alloc);

    struct Address_List* addrs = ReplySerializer_parse(from, responseDict, NULL, true, alloc);
    List* nodes = List_new(alloc);
    for (int i = 0; addrs && i < addrs->length; i++) {
        String* addr = Address_toString(&addrs->elems[i], alloc);
        List_addString(nodes, addr, alloc);
    }
    Dict_putListC(resp, "nodes", nodes, alloc);

    Admin_sendMessage(resp, search->txid, search->ctx->admin);
}
开发者ID:DmytroOrlov,项目名称:cjdns,代码行数:32,代码来源:SearchRunner_admin.c


示例13: io_calloc

Levels *Levels_new(IoMessage *msg)
{
	Levels *self = io_calloc(1, sizeof(Levels));

	IoState *state = IoObject_state(msg);
	IoSymbol *operatorTableSymbol = IoState_symbolWithCString_(state, "OperatorTable");

	// Be ultra flexable, and try to use the first message's operator table.
	IoObject *opTable = IoObject_rawGetSlot_(msg, operatorTableSymbol);

	// Otherwise, use Core OperatorTable, and if that doesn't exist, create it.
	if (opTable == NULL)
	{
		// There is a chance the message didn't have it, but the core did---due
		// to the Core not being part of the message's protos. Use Core
		// Message's OperatorTable
		opTable = IoObject_rawGetSlot_(state->core, operatorTableSymbol);

		// If Core doesn't have an OperatorTable, then create it.
		if (opTable == NULL)
		{
			opTable = IoObject_new(state);
			IoObject_setSlot_to_(state->core, operatorTableSymbol, opTable);
			IoObject_setSlot_to_(opTable, IoState_symbolWithCString_(state, "precedenceLevelCount"), IoState_numberWithDouble_(state, IO_OP_MAX_LEVEL));
		}
	}

	self->operatorTable = getOpTable(opTable, "operators", IoState_createOperatorTable);
	self->assignOperatorTable = getOpTable(opTable, "assignOperators", IoState_createAssignOperatorTable);

	self->stack = List_new();
	Levels_reset(self);
	return self;
}
开发者ID:cdcarter,项目名称:io,代码行数:34,代码来源:IoMessage_opShuffle.c


示例14: Section_new

Section* Section_new(double x, double y, double z,
	double width, double height, double length, int enemies) {
	Section* inst = (Section*) malloc(sizeof(Section));
	int i;
	Vector spawn;
	double spacing;

	inst->pos[0] = x, inst->pos[1] = y, inst->pos[2] = z;
	inst->size[0] = width, inst->size[1] = height, inst->size[2] = length;
	inst->entities = List_new();

	for(i = 0, spacing = 0; i < enemies; ++i) {
		spawn[0] = randomInterval(x, x + width - Enemy_DEF_SIZE[0]);
		spawn[1] = randomInterval(y, y + height - Enemy_DEF_SIZE[1]);
		spawn[2] = randomInterval(z + spacing, z + length);

		List_pushBack(inst->entities, Enemy_new(
			spawn[0], spawn[1], spawn[2], random(),
			random() * 5 + 1, 800));

		spacing += Enemy_DEF_SIZE[2] + length/enemies;
	}

	return inst;
}
开发者ID:yancouto,项目名称:LabProgGame,代码行数:25,代码来源:Section.c


示例15: 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


示例16: Context_new

//Constructor for our context
Context* Context_new(uint16_t width, uint16_t height, uint32_t* buffer) {

    static unsigned int handle_source = 0;

    //Attempt to allocate
    Context* context;
    if(!(context = (Context*)malloc(sizeof(Context))))
        return context; 

    //Init base object
    Object_init((Object*)context, Context_delete_function);

    //Attempt to allocate new rect list 
    if(!(context->clip_rects = List_new())) {

        free(context);
        return (Context*)0;
    }

    //Finish assignments
    context->id = ++handle_source;
    context->translate_x = 0;
    context->translate_y = 0;
    context->width = width; 
    context->height = height; 
    context->buffer = buffer;
    context->clipping_on = 0;
    context->finalize_handler = (ContextFinalizeHandler)0;

    return context;
}
开发者ID:JMarlin,项目名称:P5-Redux,代码行数:32,代码来源:context.c


示例17: getHandles

static void getHandles(Dict* args, void* vcontext, String* txid, struct Allocator* requestAlloc)
{
    struct Context* context = Identity_check((struct Context*) vcontext);
    struct Allocator* alloc = Allocator_child(context->alloc);

    int64_t* page = Dict_getInt(args, String_CONST("page"));
    int i = (page) ? *page * ENTRIES_PER_PAGE : 0;
    struct SessionManager_HandleList* hList = SessionManager_getHandleList(context->sm, alloc);

    List* list = List_new(alloc);
    for (int counter = 0; i < hList->length && counter++ < ENTRIES_PER_PAGE; i++) {
        List_addInt(list, hList->handles[i], alloc);
    }

    Dict* r = Dict_new(alloc);
    Dict_putList(r, String_CONST("handles"), list, alloc);
    Dict_putInt(r, String_CONST("total"), hList->length, alloc);

    String* more = String_CONST("more");
    if (i < hList->length) {
        Dict_putInt(r, more, 1, alloc);
    }

    Admin_sendMessage(r, txid, context->admin);

    Allocator_free(alloc);
}
开发者ID:FSFTN,项目名称:cjdns,代码行数:27,代码来源:SessionManager_admin.c


示例18: Trace_addFunc

void Trace_addFunc(char *s)
{
    if (!traceList)
        traceList = List_new();

    List_addFirst(traceList, s);
}
开发者ID:qc1iu,项目名称:turkeyVM,代码行数:7,代码来源:trace.c


示例19: dumpRumorMill

static void dumpRumorMill(Dict* args, void* vcontext, String* txid, struct Allocator* requestAlloc)
{
    struct Context* ctx = Identity_check((struct Context*) vcontext);

    Dict* out = Dict_new(requestAlloc);
    struct RumorMill* rm = getRumorMill(ctx, Dict_getString(args, String_CONST("mill")));
    if (!rm) {
        Dict_putString(out,
                       String_CONST("error"),
                       String_CONST("mill must be one of "
                                    "[externalMill,linkMill,nodeMill,dhtMill,splitMill]"),
                       requestAlloc);
        Admin_sendMessage(out, txid, ctx->admin);
        return;
    }

    int64_t* page = Dict_getInt(args, String_CONST("page"));
    int ctr = (page) ? *page * ENTRIES_PER_PAGE : 0;

    List* table = List_new(requestAlloc);
    for (int i = 0; i < ENTRIES_PER_PAGE && ctr < rm->count; i++) {
        String* addr = Address_toString(&rm->addresses[ctr++], requestAlloc);
        List_addString(table, addr, requestAlloc);
    }
    Dict_putList(out, String_CONST("addresses"), table, requestAlloc);
    Dict_putInt(out, String_CONST("total"), rm->count, requestAlloc);
    Admin_sendMessage(out, txid, ctx->admin);
}
开发者ID:BurnBeforeReading,项目名称:cjdns,代码行数:28,代码来源:Janitor_admin.c


示例20: genericResponse

static void genericResponse(struct RouterModule_Promise* promise,
                            uint32_t lag,
                            struct Address* from,
                            Dict* responseDict,
                            String* name)
{
    struct Ping* ping = Identity_check((struct Ping*)promise->userData);
    Dict* out = Dict_new(promise->alloc);
    String* result = (responseDict) ? name : String_CONST("timeout");
    Dict_putString(out, String_CONST("result"), result, promise->alloc);

    if (responseDict) {
        struct Address_List* addrs =
            ReplySerializer_parse(from, responseDict, NULL, promise->alloc);

        List* nodes = List_new(promise->alloc);
        for (int i = 0; i < addrs->length; i++) {
            String* addr = Address_toString(&addrs->elems[i], promise->alloc);
            List_addString(nodes, addr, promise->alloc);
        }
        Dict_putList(out, name, nodes, promise->alloc);
    }

    Dict_putInt(out, String_CONST("ms"), lag, promise->alloc);

    Dict_putString(out, String_CONST("error"), String_CONST("none"), promise->alloc);

    Admin_sendMessage(out, ping->txid, ping->ctx->admin);
}
开发者ID:0x20c24,项目名称:cjdns,代码行数:29,代码来源:RouterModule_admin.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ List_push函数代码示例发布时间:2022-05-30
下一篇:
C++ List_create函数代码示例发布时间: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