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

C++ ListInit函数代码示例

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

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



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

示例1: RequestInit

void
RequestInit(TSession * const sessionP,
            TConn *    const connectionP) {

    time_t nowtime;

    sessionP->validRequest = false;  /* Don't have valid request yet */

    time(&nowtime);
    sessionP->date = *gmtime(&nowtime);

    sessionP->conn = connectionP;

    sessionP->responseStarted = FALSE;

    sessionP->chunkedwrite = FALSE;
    sessionP->chunkedwritemode = FALSE;

    ListInit(&sessionP->cookies);
    ListInit(&sessionP->ranges);
    TableInit(&sessionP->request_headers);
    TableInit(&sessionP->response_headers);

    sessionP->status = 0;  /* No status from handler yet */

    StringAlloc(&(sessionP->header));
}
开发者ID:4N7HR4X,项目名称:kamailio,代码行数:27,代码来源:abyss_http.c


示例2: InitParkingLot

ParkingLot * InitParkingLot( FILE * mapconfig, int col, int row, int floors, int accesses )
{
    char *** matrix;
    int *vertices, *ramps;
    ParkingLot * parkinglot;

    vertices = (int*)malloc(sizeof(int));
    VerifyMalloc( (Item) vertices );

    ramps = (int*)malloc(sizeof(int));
    VerifyMalloc( (Item) ramps );

    parkinglot = (ParkingLot*) malloc( sizeof(ParkingLot) );
    VerifyMalloc((Item) parkinglot);
    parkinglot->freespots = 0;
    matrix = MatrixInit(vertices, ramps, mapconfig, col, row, floors); /*Creates string cointaining the map - its a 3d string */
    parkinglot->graphdecoder = GraphDecoderInit(matrix, col, row, floors, *vertices, &(parkinglot->freespots) ); /*Creates array cointaining the Decoder for the graph positions*/
    parkinglot->g = GraphInit(*vertices, matrix, parkinglot->graphdecoder, col, row);
    parkinglot->accesseshead = InitAccesses(accesses, parkinglot->graphdecoder, *vertices);
    parkinglot->parkedcarshead = ListInit();
    parkinglot->queuehead = ListInit();

    /**PrintGraph(GetGraph(parkinglot), *vertices); */ /*prints the graph in the parkinglot */
    FreeMatrix(matrix, col, row);
    free(vertices);
    free(ramps);

    return (parkinglot);
}
开发者ID:jsmvalente,项目名称:projectoaed,代码行数:29,代码来源:ParkingLot.c


示例3: ParseBuildList

List* ParseBuildList(char* s, Err* err){
    List* L=NULL,*Lold=NULL;
    int i=0,iold=0; Str* S=NULL; Err* err2=ErrInit();
    i=0;
    while ((s!=NULL)&&(i<strlen(s))){
        iold=i;
        
        S=ParseLex(s, err,&i);
         
        if (S==NULL && i<strlen(s)){
            err->pres=err2->pres;
            err->err=err2->err;
            myfree(err2);
            return NULL;
        }
        if (S==NULL && i>=strlen(s)){
            break;
        }

        i=i;
        
        if (L==NULL) { L=ListInit(); Lold=L;}
        else { L->next=NULL; L->next=ListInit(); L=L->next;}
        ListPutDataStr(L,S->s);
        StrFree(S);
        /*printf("%s\n",S->s);*/
    }
    myfree(err2->err);
    myfree(err2);
    return Lold;
}
开发者ID:PoCTo,项目名称:yamsh,代码行数:31,代码来源:parse.c


示例4: RequestInit

void
RequestInit(TSession * const sessionP,
            TConn *    const connectionP) {

    sessionP->validRequest = false;  /* Don't have valid request yet */

    time(&sessionP->date);

    sessionP->connP = connectionP;

    sessionP->responseStarted = FALSE;

    sessionP->chunkedwrite = FALSE;
    sessionP->chunkedwritemode = FALSE;

    sessionP->continueRequired = FALSE;

    ListInit(&sessionP->cookies);
    ListInit(&sessionP->ranges);
    TableInit(&sessionP->requestHeaderFields);
    TableInit(&sessionP->responseHeaderFields);

    sessionP->status = 0;  /* No status from handler yet */

    StringAlloc(&(sessionP->header));
}
开发者ID:BirminghamConservatoire,项目名称:IntegraLive,代码行数:26,代码来源:http.c


示例5: printf

heap_t *heapCreate (size_t heapSize)
{
    heap_t *new_heap;
    sector_t *s0;
    new_heap = (heap_t*)malloc(sizeof(heap_t));
    if(new_heap == NULL)
    {
        printf("Error during heap allocation\n");
        exit(EXIT_FAILURE);
    }
    new_heap->empty=ListInit();
    new_heap->full=ListInit();
    new_heap->dim=heapSize;
    new_heap->base=malloc(heapSize);//memoria dello heap allocata
    if(new_heap->base == NULL)
    {
        printf("Error during base allocation\n");
        exit(EXIT_FAILURE);
    }
    s0=(sector_t*)malloc(sizeof(sector_t));
    if(s0==NULL) return NULL;
    s0->offset=(int)new_heap->base;
    s0->dimen=heapSize;
    new_heap->empty = OrderInsert(new_heap->empty,(void*)s0,NULL);//inserisco in empty la partizione intera
    return(new_heap);
}
开发者ID:blubecks,项目名称:Laboratorio,代码行数:26,代码来源:myheap.c


示例6: MediaSrvInit

////////////////////////////////////////////////////
// 功能:
// 输入:
// 输出:
// 返回:
// 说明:
////////////////////////////////////////////////////
void MediaSrvInit(void)
{
	ListInit(&MediaObjList);
	ListInit(&MediaCallbackList);
	hMediaMutex = kMutexCreate();
	JzSrvInit();
	SaveMplayerVar();
}
开发者ID:DanielGit,项目名称:Intrisit201202,代码行数:15,代码来源:MediaSrv.c


示例7: TaskInit

// 说明:任务管理模块初始化
void TaskInit(void)
{
    static uint32_t flag = FALSE;
    if (flag) {
        TEE_Printf("Task Module has been inited sometime before!\n");
        return;
    }
    flag = TRUE;
    current_task = NULL;
    ListInit(&list_all_tasks);
    ListInit(&list_ready_tasks);
    ListInit(&list_suspud_tasks);
}
开发者ID:HappyASR,项目名称:Trust-E-OS,代码行数:14,代码来源:tee_scheduler.c


示例8: MIMETypeCreate

MIMEType *
MIMETypeCreate(void) {
 
    MIMEType * MIMETypeP;

    MALLOCVAR(MIMETypeP);

    if (MIMETypeP) {
        ListInit(&MIMETypeP->typeList);
        ListInit(&MIMETypeP->extList);
        PoolCreate(&MIMETypeP->pool, 1024);
    }
    return MIMETypeP;
}
开发者ID:BirminghamConservatoire,项目名称:IntegraLive,代码行数:14,代码来源:response.c


示例9: main

int main(void)
{
	// 양방향 연결 리스트의 생성 및 초기화  ///////
	List list;
	int data;
	ListInit(&list);

	// 8개의 데이터 저장  ///////
	LInsert(&list, 1);  LInsert(&list, 2);
	LInsert(&list, 3);  LInsert(&list, 4);
	LInsert(&list, 5);  LInsert(&list, 6);
	LInsert(&list, 7);  LInsert(&list, 8);

	// 저장된 데이터의 조회  ///////
	if(LFirst(&list, &data))
	{
		printf("%d ", data);

		while(LNext(&list, &data)) 
			printf("%d ", data);
		
		while(LPrevious(&list, &data))
			printf("%d ", data);
		
		printf("\n\n");
	}

	return 0;
}
开发者ID:jhBang8917,项目名称:study_algorithm,代码行数:29,代码来源:DBLinkedListMain.c


示例10: PointInitList

/* initialize a list point - sets it as an empty list */
static FSTATUS PointInitList(Point *point, PointType type)
{
	DLIST *pList;

	point->Type = POINT_TYPE_NONE;
	switch (type) {
	case POINT_TYPE_PORT_LIST:
		pList = &point->u.portList;
		break;
	case POINT_TYPE_NODE_LIST:
		pList = &point->u.nodeList;
		break;
#if !defined(VXWORKS) || defined(BUILD_DMC)
	case POINT_TYPE_IOC_LIST:
		pList = &point->u.iocList;
		break;
#endif
	default:
		ASSERT(0);
		return FINVALID_OPERATION;
	}
	ListInitState(pList);
	if (! ListInit(pList, MIN_LIST_ITEMS)) {
		fprintf(stderr, "%s: unable to allocate memory\n", g_Top_cmdname);
		return FINSUFFICIENT_MEMORY;
	}
	point->Type = type;
	return FSUCCESS;
}
开发者ID:01org,项目名称:opa-ff,代码行数:30,代码来源:point.c


示例11: main

int main()
{
	CommonDataStr commonDataStr;
	CommonDataStr *commonDataPtr = &commonDataStr;
	FILE *vertFilePtr;
	fopen_s(&vertFilePtr, VERTEX_FILE, "r");

	if (vertFilePtr == NULL)
	{
		printf("Fatal Error: Unable to open %s File\n", VERTEX_FILE);
		return 1;
	}
	
	//Initialise the common data structure
	ListInit(&commonDataPtr->vertDataHead);
	commonDataPtr->numBits = 0;
	commonDataPtr->numVerts = 0;

	//Parse the vert file and create the vert data list
	ParseVertFile(vertFilePtr, commonDataPtr);

	//Decompress the bitstream file and find RMS error
	DecompressFromBitStream(commonDataPtr);

	//Free the vert data
	FreeVertData(commonDataPtr);

	fclose(vertFilePtr);
	return 0;
}
开发者ID:maheshvele,项目名称:GameDataCodec,代码行数:30,代码来源:main.c


示例12: TestIterator

void TestIterator()
{
    List* list = ListInit();

    /* Prepare the initial elements. */
    CU_ASSERT(list->push_back(list, (void*)(intptr_t)1) == true);
    CU_ASSERT(list->push_back(list, (void*)(intptr_t)2) == true);
    CU_ASSERT(list->push_back(list, (void*)(intptr_t)3) == true);
    CU_ASSERT(list->push_back(list, (void*)(intptr_t)4) == true);

    /* Iterate through the list. */
    void* element;
    int check = 1;

    list->first(list, false);
    while (list->next(list, &element)) {
        CU_ASSERT_EQUAL((int)(intptr_t)element, check);
        ++check;
    }

    /* Iterate through the list in reversed order. */
    check = 4;
    list->first(list, true);
    while (list->reverse_next(list, &element)) {
        CU_ASSERT_EQUAL((int)(intptr_t)element, check);
        --check;
    }

    ListDeinit(list);
}
开发者ID:ZSShen,项目名称:C-Common-Data-Structures,代码行数:30,代码来源:unit_list.c


示例13: InitAccesses

ListNode * InitAccesses(int accesses, Array decoder, int vertices)
{
    int i, *index, counter = 0;
    char type;
  	ListNode* accesseshead = ListInit();

    for(i = 0; i < vertices; i++) /*Goes through every vertice in the decoder to see if it is or not an access */
    {
        type = GetIP_Type(i, decoder);
        if( type == 'R' || type == 'C' || type == 'H' || type == 'E' || type == 'L' ) /*If it is an access */
        {
          	index = (int*) malloc( sizeof(int) );
          	VerifyMalloc((Item) index);

          	*index = i;
            counter++;
            accesseshead = AddNodeToListHead(accesseshead, (Item) index);
        }
    }
    if(counter != accesses)
    {
        printf("Error. Number of read accesses doesnt match info from file.");
        exit(0);
    }

    return accesseshead;
}
开发者ID:jsmvalente,项目名称:projectoaed,代码行数:27,代码来源:ParkingLot.c


示例14: ListInit

List *ListCopy(List *in, int deep)
 {
  ListItem *item, *outitem;
  List *out;
  out = ListInit();
  item = in->first;
  while (item != NULL)
   {
    outitem           = (ListItem *)lt_malloc_incontext(sizeof(ListItem), out->memory_context);
    outitem->prev     = out->last;
    outitem->next     = NULL;
    outitem->DataSize = item->DataSize;
    if (item->copyable != 0)
     {
      outitem->data     = (void *)lt_malloc_incontext(outitem->DataSize, out->memory_context);
      memcpy(outitem->data, item->data, outitem->DataSize);
     } else {
      if      ((deep!=0)&&(item->DataType == DATATYPE_LIST)) outitem->data = ListCopy((List *)item->data,1);
      else if ((deep!=0)&&(item->DataType == DATATYPE_DICT)) outitem->data = DictCopy((Dict *)item->data,1);
      else                                                   outitem->data =                  item->data   ;
     }
    outitem->copyable = item->copyable;
    outitem->DataType = item->DataType;
    if (out->first == NULL) out->first      = outitem;
    if (out->last  != NULL) out->last->next = outitem;
    out->last = outitem;
    out->length++;
    item = item->next;
   }
  return out;
 }
开发者ID:dcf21,项目名称:pyxplot8,代码行数:31,代码来源:lt_list.c


示例15: TestInsert

void TestInsert()
{
    List* list = ListInit();

    /* Insert elements to the specified indexes. */
    CU_ASSERT(list->insert(list, 1, (void*)(intptr_t)1) == false);

    CU_ASSERT(list->insert(list, 0, (void*)(intptr_t)1) == true);
    CU_ASSERT(list->insert(list, 1, (void*)(intptr_t)4) == true);
    CU_ASSERT(list->insert(list, 1, (void*)(intptr_t)2) == true);
    CU_ASSERT(list->insert(list, 2, (void*)(intptr_t)3) == true);
    CU_ASSERT(list->insert(list, 0, (void*)(intptr_t)0) == true);

    /* Check element insertion sequence. */
    void* element;
    CU_ASSERT(list->get_front(list, &element) == true);
    CU_ASSERT_EQUAL(element, (void*)(intptr_t)0);
    CU_ASSERT(list->get_back(list, &element) == true);
    CU_ASSERT_EQUAL(element, (void*)(intptr_t)4);

    CU_ASSERT(list->get_at(list, 0, &element) == true);
    CU_ASSERT_EQUAL(element, (void*)(intptr_t)0);
    CU_ASSERT(list->get_at(list, 1, &element) == true);
    CU_ASSERT_EQUAL(element, (void*)(intptr_t)1);
    CU_ASSERT(list->get_at(list, 2, &element) == true);
    CU_ASSERT_EQUAL(element, (void*)(intptr_t)2);
    CU_ASSERT(list->get_at(list, 3, &element) == true);
    CU_ASSERT_EQUAL(element, (void*)(intptr_t)3);
    CU_ASSERT(list->get_at(list, 4, &element) == true);
    CU_ASSERT_EQUAL(element, (void*)(intptr_t)4);

    CU_ASSERT_EQUAL(list->size(list), 5);
    ListDeinit(list);
}
开发者ID:ZSShen,项目名称:C-Common-Data-Structures,代码行数:34,代码来源:unit_list.c


示例16: TestReverse

void TestReverse()
{
    List* list = ListInit();

    /* Prepare the initial elements. */
    CU_ASSERT(list->push_back(list, (void*)(intptr_t)1) == true);
    CU_ASSERT(list->push_back(list, (void*)(intptr_t)2) == true);
    CU_ASSERT(list->push_back(list, (void*)(intptr_t)3) == true);
    CU_ASSERT(list->push_back(list, (void*)(intptr_t)4) == true);

    list->reverse(list);

    /* Check the reversed element sequence. */
    void* element;
    CU_ASSERT(list->get_at(list, 0, &element) == true);
    CU_ASSERT_EQUAL(element, (void*)(intptr_t)4);
    CU_ASSERT(list->get_at(list, 1, &element) == true);
    CU_ASSERT_EQUAL(element, (void*)(intptr_t)3);
    CU_ASSERT(list->get_at(list, 2, &element) == true);
    CU_ASSERT_EQUAL(element, (void*)(intptr_t)2);
    CU_ASSERT(list->get_at(list, 3, &element) == true);
    CU_ASSERT_EQUAL(element, (void*)(intptr_t)1);

    ListDeinit(list);
}
开发者ID:ZSShen,项目名称:C-Common-Data-Structures,代码行数:25,代码来源:unit_list.c


示例17: MediaSrvRegistCallback

////////////////////////////////////////////////////
// 功能:
// 输入:
// 输出:
// 返回:
// 说明:
////////////////////////////////////////////////////
int MediaSrvRegistCallback(int type, DWORD device, PMEDIA_CALLBACK callback)
{
	PLIST n;
	PLIST head;
	PCALLBACK_LINK check;
	PCALLBACK_LINK link;

	// 申请节点,并初始化
	link = kmalloc(sizeof(CALLBACK_LINK));
	if(link == NULL)
		return -1;
	kmemcpy(&link->Callback, callback, sizeof(MEDIA_CALLBACK));
	link->Type = type;
	link->Device = device;
	ListInit(&link->Link);
	
	// 检查设备是否已经注册
	head = &MediaCallbackList;
	for(n=ListFirst(head); n!=head; n=ListNext(n))
	{
		check = ListEntry(n, CALLBACK_LINK, Link);
		if(&check->Callback == callback)
		{
			kfree(link);
			return -1;
		}
	}
	ListInsert(&MediaCallbackList, &link->Link);		
	return 0;
}
开发者ID:DanielGit,项目名称:Intrisit201202,代码行数:37,代码来源:MediaSrv.c


示例18: main

int main()
{
	DPoint _PFir;
	DPoint _PSec;
	DPoint _PAim;
	DPoint _pCro;

	_PFir._PointX=0.0;
	_PFir._PointY=0.0;

	_PSec._PointX=100.0;
	_PSec._PointY=0.0;

	_PAim._PointX=20.0;
	_PAim._PointY=60.0;

	CalcuVertical(_PFir,_PSec, _PAim,&_pCro);

	printf("%.6lf, %.6lf", _pCro._PointX, _pCro._PointY);
	printf("%.6lf",CalcuDis(_PFir,_PSec,_PAim));
	////////////////////////////////////////
	SqList lo;
	ListInit(&lo);
	DPoint _dPValue;
	DPoint _dPIValue;

	_dPValue._PointX = 100.0;
	_dPValue._PointY = 100.0;
	_dPIValue._PointX = 300.0;
	_dPIValue._PointY = 300.0;
	for (size_t _i=0;_i<3;_i++)
	{
		ListInsert(&lo,1,_dPValue);
	}
		
	ListInsert(&lo,2,_dPIValue);

	printf("%.6lf,%.6lf",lo._nArray[0]._PointX,lo._nArray[0]._PointX);
	//////////////////////////////////////
//	vector<vector<CPoint>> _vecPOINT;
//	vector<CPoint> _vecIn;
//	CPoint _ptFir;
//	CPoint _ptIn;
//	_ptIn.SetPoint(300,300);
//	_ptFir.SetPoint(100,100);
//
//	_vecIn.push_back(_ptFir);
//	for (size_t _i=0; _i<5;_i++)
//	{
//		_vecIn.push_back(_ptFir);
		//_vecPOINT.push_back(_vecIn);
//	}
//	
//	_vecPOINT.push_back(_vecIn);
//
//	_vecPOINT[0].insert(_vecPOINT[0].begin()+1,_ptIn);
	///////////////////////////////////////
	return 0;
}
开发者ID:dusong7,项目名称:C-CPP-Advance-Test,代码行数:59,代码来源:垂直.c


示例19: TestObjectInsert

/*-----------------------------------------------------------------------------*
 *              Unit tests relevant to complex data maintenance                *
 *-----------------------------------------------------------------------------*/
void TestObjectInsert()
{
    char* nums[SIZE_MID_TEST];
    char buf[SIZE_TXT_BUFF];
    int idx = 0;
    while (idx < SIZE_MID_TEST) {
        snprintf(buf, SIZE_TXT_BUFF, "%d", idx);
        nums[idx] = strdup((const char*)buf);
        ++idx;
    }

    List* list = ListInit();
    list->set_clean(list, CleanElement);

    /* Push the elements ranging from 1536 to 2047 to the list tail. */
    idx = SIZE_MID_TEST - SIZE_SML_TEST;
    while (idx < SIZE_MID_TEST) {
        CU_ASSERT(list->push_back(list, strdup(nums[idx])) == true);
        ++idx;
    }

    /* Push the elements ranging from 0 to 511 to the list head. */
    idx = SIZE_SML_TEST - 1;
    while (idx >= 0) {
        CU_ASSERT(list->push_front(list, strdup(nums[idx])) == true);
        --idx;
    }

    /* Insert the elements ranging from 512 to 1535. */
    idx = SIZE_SML_TEST;
    int bnd = SIZE_MID_TEST - SIZE_SML_TEST;
    while (idx < bnd) {
        CU_ASSERT(list->insert(list, idx, strdup(nums[idx])) == true);
        ++idx;
    }

    /* Check the element sequence. */
    void* element;
    CU_ASSERT(list->get_front(list, &element) == true);
    CU_ASSERT(strcmp((char*)element, nums[0]) == 0);

    CU_ASSERT(list->get_back(list, &element) == true);
    CU_ASSERT(strcmp((char*)element, nums[SIZE_MID_TEST - 1]) == 0);

    idx = 0;
    while (idx < SIZE_MID_TEST) {
        CU_ASSERT(list->get_at(list, idx, &element) == true);
        CU_ASSERT(strcmp((char*)element, nums[idx]) == 0);
        ++idx;
    }

    ListDeinit(list);

    idx = 0;
    while (idx < SIZE_MID_TEST) {
        free(nums[idx]);
        ++idx;
    }
}
开发者ID:ZSShen,项目名称:C-Common-Data-Structures,代码行数:62,代码来源:unit_list.c


示例20: main

int main(int argc, char *args[])
{
    char *buffer = (char *)malloc(MAX_LINE_LEN);;
    char *result = (char *)malloc(MAX_LINE_LEN);;
    int number;
    int dwnum;

    dwnum = GetPrice();
    if(dwnum != 0)
    {
	return dwnum;
    }
    list_t *L = ListInit();
    if(L == NULL)
    {
	return ERRNO_NULL_POINTER;
    }

    while(fgets(buffer, MAX_LINE_LEN, stdin))
    {
	number = 0;
	memset(result, 0, MAX_LINE_LEN);
	dwnum = ParseLine(buffer, result, &number);

	if(dwnum == 0)
	{
	    item_t* curnode;
	    if((curnode = ListIsNodeInListById(L, result)) != NULL)
	    {
		curnode->count += number;
		continue;
	    }

	    item_t * node = ItemMakeitem(result, number);
	    if(node == NULL)
	    {
		return ERRNO_MAKEITEM_FAIL;
	    }

	    dwnum = ListPushBack(L, (void*) node);
	    if(dwnum != 0)
	    {
		return ERRNO_LISTPUSHBACK_FAIL;
	    }
	}
    }

    dwnum = CalculateSum(L);
    if(dwnum != 0)
    {
	return ERRNO_CALCULATESUM_FAIL;	
    }

    ListFree(L);
    ListFree(my_price);
    free(buffer);
    free(result);
    return 0;
}
开发者ID:pengpengxp,项目名称:supermartket,代码行数:59,代码来源:main.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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