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

C++ My402ListFirst函数代码示例

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

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



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

示例1: CompareTestList

static
void CompareTestList(My402List *pList1, My402List *pList2, int num_items)
{
    My402ListElem *elem1=NULL, *elem2=NULL;
    int idx=0;

    if (My402ListLength(pList1) != num_items) {
        fprintf(stderr, "List1 length is not %1d in CompareTestList().\n", num_items);
        exit(1);
    }
    if (My402ListLength(pList2) != num_items) {
        fprintf(stderr, "List2 length is not %1d in CompareTestList().\n", num_items);
        exit(1);
    }
    for (elem1=My402ListFirst(pList1), elem2=My402ListFirst(pList2);
            elem1 != NULL && elem2 != NULL;
            elem1=My402ListNext(pList1, elem1), elem2=My402ListNext(pList2, elem2), idx++) {
        int ival1=(int)(elem1->obj);
        int ival2=(int)(elem2->obj);

        if (ival1 != ival2) {
            fprintf(stderr, "(%1d,%1d): item %1d not identical in CompareTestList().\n", ival1, ival2, idx);
            exit(1);
        }
    }
}
开发者ID:ankit-bhatnagar,项目名称:doubly-circular-linked-list,代码行数:26,代码来源:listtest.c


示例2: My402ListUnlinkAll

void My402ListUnlinkAll(My402List *pList){
	My402ListElem *elem = NULL;
	for(elem = My402ListFirst(pList); elem != NULL; elem = My402ListNext(pList, elem)){
    	My402ListUnlink(pList, elem);
    }
	pList->num_members = 0;
}
开发者ID:YingjieHe,项目名称:Doubly-Linked-Circular-List,代码行数:7,代码来源:my402list.c


示例3:

My402ListElem *My402ListFind(My402List *pList, void *obj){
	My402ListElem *elem = NULL;
    for (elem = My402ListFirst(pList); elem != NULL; elem = My402ListNext(pList, elem)){
    	if(elem->obj == obj) return elem;
    }
    return NULL;
}
开发者ID:YingjieHe,项目名称:Doubly-Linked-Circular-List,代码行数:7,代码来源:my402list.c


示例4: main

int main(){
	
	int i=100;
	int j=0;
	My402List list;
	//========== initialization part starts==========	
	memset(&list,0,sizeof(My402List));	
	My402List *pList = NULL;	
	pList = &list;		
	My402ListElem *ptrToAnchor = &(pList->anchor);
	ptrToAnchor->next = ptrToAnchor;
	ptrToAnchor->prev = ptrToAnchor;
	//=========== initialization part ends============	
	My402ListElem *current = ptrToAnchor;
	for(; j<10;j++){
		My402ListInsertAfter(&list,(void *)&i,current);	
		i= i+10;
		current = current->next;
	}
	NL
	printf("Appneded the whole list");
	NL	
		
	for(current=My402ListFirst(pList);
		current != NULL;
		current=My402ListNext(pList,current)	
		){
		
		printf("%d -->", *((int *)current->obj));	
	}	
	NL
}
开发者ID:naveenkothamasu,项目名称:402,代码行数:32,代码来源:testMy402ListInsertAfter.c


示例5: insert_list

void insert_list(My402List * list, My402TransData * data)
{
	if(My402ListEmpty(list))
		(void)My402ListAppend(list, (void*)data);
	else
	{
		My402ListElem * elem = My402ListFirst(list);
		while(elem)
		{
			My402TransData * temp = (My402TransData *)(elem -> obj);
			if(temp -> timestamp < data -> timestamp)
			{
				elem = My402ListNext(list, elem);
				if(!elem)
					(void)My402ListAppend(list, (void*)data);
			}
			else if(temp -> timestamp > data -> timestamp)
			{
				(void)My402ListInsertBefore(list, (void*)data, elem);
				break;
			}
			else
				print_error("two identical timestamp");
		}
	}
}
开发者ID:FrankSzn,项目名称:USC-Projects,代码行数:26,代码来源:warmup1.c


示例6: printOutput

void printOutput(My402List *pList){

	int line_number = 0;
	int i=0;
	My402Output output;
	memset(&output, '\0', sizeof(My402Output));
	My402Output *pOutput = &output; 
	
	long long *pBalance = (long long *)malloc(sizeof(long long));
	memset(pBalance, 0, sizeof(long long)) ;
	if(pBalance == NULL){
		fprintf(stderr, "\nUnable to allocate memory");	
	}

	My402ListElem *current = NULL;
	/*for(; i<pList->num_members; i++){
		output[i] = (char *)malloc(80*sizeof(char));	
		memset(output[i], '\0', 80*sizeof(char));	
	}*/
	printf("\n");	
	printf("+-----------------+--------------------------+----------------+----------------+\n");
	printf("|%7cDate%6c|%1cDescription%14c|%9cAmount%1c|%8cBalance%1c|\n",32,32,32,32,32,32,32,32);
	printf("+-----------------+--------------------------+----------------+----------------+\n");
	for(current=My402ListFirst(pList);
		current!=NULL;
		current=My402ListNext(pList, current)){
		
		formatEachField((My402SortElem *)current->obj, pOutput, pBalance);
		line_number++;	
		printf("|%1c%s%1c|%1c%s%c|%c%s%1c|%c%s%c|\n",32,pOutput->printDate,32,32,pOutput->printDesc,32,32,pOutput->printAmount,32,32,pOutput->printBalance,32);	
	}	
	printf("+-----------------+--------------------------+----------------+----------------+\n");
	
}
开发者ID:naveenkothamasu,项目名称:402,代码行数:34,代码来源:my402output.c


示例7:

My402ListElem *My402ListPrev(My402List* q, My402ListElem* n)
{
    if (n==My402ListFirst(q))
        return NULL;
    else
        return n->prev;
}
开发者ID:RupasreeR,项目名称:Main_repo,代码行数:7,代码来源:my402list.c


示例8: server_procedure

void server_procedure(struct command_line_args *object)
{
	struct packet *p;
	My402ListElem *elem = NULL;
	struct timespec tim;
	double time;
	long time_diff_in_nsec;
	int i = 0;
	while( i < object->no_of_packets && !EndServerThread) 
	{
		pthread_mutex_lock(&token_bucket);
		while(My402ListEmpty(&Q2PacketList)&&!EndServerThread)
			pthread_cond_wait(&is_q2_empty,&token_bucket);

		if(EndServerThread == 1)
		{
			pthread_mutex_unlock(&token_bucket);
			break;
		}

		elem = My402ListFirst(&Q2PacketList);
		if(elem == NULL)
		{
			pthread_mutex_unlock(&token_bucket);
			break;
		}
		p = (struct packet *)elem->obj;
		My402ListUnlink(&Q2PacketList, elem);

		pthread_mutex_unlock(&token_bucket);
	
		gettimeofday(&(p->Q2leaves), NULL);
		time = (TIME_IN_USEC(p->Q2leaves) - TIME_IN_USEC(GlobalStartTime))/1000;
		p->time_in_Q2 = (TIME_IN_USEC(p->Q2leaves) - TIME_IN_USEC(p->Q2timestamp))/1000;

		LOG(stdout, "%012.3fms: p%d begin service at S, time in Q2 = %.3fms\n",time,p->packet_id,p->time_in_Q2);
 
		time_diff_in_nsec = (long)((((p->precise_packet_service_time)/1000) - (p->service_time/1000))*1000000000L);
		tim.tv_sec = (p->service_time)/1000;
		tim.tv_nsec = time_diff_in_nsec;
	
		nanosleep(&tim, NULL);
	
		gettimeofday(&(p->Leaves_server), NULL);
		time = (TIME_IN_USEC(p->Leaves_server) - TIME_IN_USEC(GlobalStartTime))/1000;
		p->time_in_system = (TIME_IN_USEC(p->Leaves_server) - TIME_IN_USEC(p->Arrival_timestamp))/1000;
		p->precise_packet_service_time = (TIME_IN_USEC(p->Leaves_server) - TIME_IN_USEC(p->Q2leaves))/1000;
		LOG(stdout, "%012.3fms: p%d departs from S, service time = %.3fms, time in system = %.3fms\n",time,p->packet_id,p->precise_packet_service_time,p->time_in_system);
		completed_packets ++;
		calculate_stats(p);
		if((packet_count == object->no_of_packets) &&(completed_packets == (packet_count-discarded_packets)) && My402ListEmpty(&Q2PacketList))
		{
			EndServerThread = 1;
			pthread_cond_signal(&is_q2_empty);
		}
		i++;
	}
	pthread_exit(NULL);
	
}
开发者ID:akshaysk,项目名称:Token-Bucket-Emulator,代码行数:60,代码来源:warmup2.c


示例9: BubbleSortForwardList

static
void BubbleSortForwardList(My402List *pList, int num_items)
{
    My402ListElem *elem=NULL;
    int i=0;

    if (My402ListLength(pList) != num_items) {
        fprintf(stderr, "List length is not %1d in BubbleSortForwardList().\n", num_items);
        exit(1);
    }
    for (i=0; i < num_items; i++) {
        int j=0, something_swapped=FALSE;
        My402ListElem *next_elem=NULL;

        for (elem=My402ListFirst(pList), j=0; j < num_items-i-1; elem=next_elem, j++) {
            int cur_val=(int)(elem->obj), next_val=0;

            next_elem=My402ListNext(pList, elem);
            next_val = (int)(next_elem->obj);

            if (cur_val > next_val) {
                BubbleForward(pList, &elem, &next_elem);
                something_swapped = TRUE;
            }
        }
        if (!something_swapped) break;
    }
}
开发者ID:ankit-bhatnagar,项目名称:doubly-circular-linked-list,代码行数:28,代码来源:listtest.c


示例10: My402ListPrev

My402ListElem * My402ListPrev(My402List * list, My402ListElem * cur)
{
    if(cur == My402ListFirst(list))
        return NULL;
    else
        return cur -> prev;
}
开发者ID:FrankSzn,项目名称:USC-Projects,代码行数:7,代码来源:my402list.c


示例11: BubbleSortForwardList

static
void BubbleSortForwardList(My402List *pList)
{
    My402ListElem *elem=NULL;
    int i=0;

    if (My402ListLength(pList) == 0) {
        fprintf(stderr, "List is empty!");
        PrintErrorMessage();
        exit(1);
    }
    for (i=0; i < My402ListLength(pList); i++) {
        int j=0, something_swapped=FALSE;
        My402ListElem *next_elem=NULL;

        for (elem=My402ListFirst(pList), j=0; j < My402ListLength(pList)-i-1; elem=next_elem, j++) {
           unsigned int cur_val=(unsigned int)((TransactionElem *)(elem->obj))->eleTime, next_val=0;

            next_elem=My402ListNext(pList, elem);
            next_val = (unsigned int)((TransactionElem *)(next_elem->obj))->eleTime;

            if (cur_val > next_val) {
                BubbleForward(pList, &elem, &next_elem);
                something_swapped = TRUE;
            }
        }
        if (!something_swapped) break;
    }
}
开发者ID:saigeethakandepallicherukuru,项目名称:cs402,代码行数:29,代码来源:warmup1.c


示例12: PrintAll

void PrintAll(My402List *List)
{
    printf("+-----------------+--------------------------+----------------+----------------+\n");
    printf("|       Date      | Description              |         Amount |        Balance |\n");
    printf("+-----------------+--------------------------+----------------+----------------+\n");
    My402ListElem *toPrint = My402ListFirst(List);
    while(toPrint != NULL)
    {
        My402ListElemObj *Pnt = (My402ListElemObj*)toPrint->obj;
        printf("|");
        time_t *timep = &(Pnt->TTime);
        print_TTime(timep);
        printf("|");

        printf(" %-24s ", Pnt->TDesc);
        printf("|");

        print_TAm(Pnt->TAm, Pnt->TSign);
        printf("|");

        print_bal(Pnt->TAm,Pnt->TSign);

        printf("|\n");
        //nextone;

        toPrint = My402ListNext(List,toPrint);

    }
    printf("+-----------------+--------------------------+----------------+----------------+\n");
}
开发者ID:neilChenXie,项目名称:Sort_warmup,代码行数:30,代码来源:functionlist.c


示例13: ExistTimestamp

int ExistTimestamp(My402List *pList,int timeval)
{
  My402ListElem *elem=NULL;
  /* Return FALSE if list is empty*/
  if (pList->num_members == 0)
  {
    return FALSE;
  }
  else
  {
    /* Traverse the list for finding the element
       return the element if the object is found
    */
    for (elem=My402ListFirst(pList);
         elem != NULL;
         elem=My402ListNext(pList, elem)) {
            if (((trnx*)(elem->obj))->timeval == timeval)
            {
              return TRUE;
            }
       }

    return FALSE;
  }
}
开发者ID:garrynigel,项目名称:Projects,代码行数:25,代码来源:warmup1.c


示例14: BubbleSort

static
void BubbleSort(My402List *pList)
{
    My402ListElem *elem=NULL;
    int i=0;
    int num_items = My402ListLength(pList);
    for (i=0; i < num_items; i++) {
        int j=0, something_swapped=FALSE;
        My402ListElem *next_elem=NULL;

        for (elem=My402ListFirst(pList), j=0; j < num_items-i-1; elem=next_elem, j++) {
          struct transaction_info *cur_val=(struct transaction_info *)&elem->obj;
          struct transaction_info *next_val;

            next_elem=My402ListNext(pList, elem);
            next_val = (struct transaction_info *)&next_elem->obj;
            int *a = (int *)cur_val->t_date;
            int *b = (int *)next_val->t_date;
            //printf("%d %d\n",*a,*b );


            if (*a > *b) {
              //printf("ok\n");
              BubbleSwap(pList, &elem, &next_elem);
              something_swapped = TRUE;
            }
        }
        if (!something_swapped) break;
    }
}
开发者ID:agbpatro,项目名称:Custom-Doubly-Linkkist,代码行数:30,代码来源:warmup1.c


示例15: My402ListPrepend

 int  My402ListPrepend(My402List* list, void* obj)
 {
	 My402ListElem* first, *elem;
	 first = My402ListFirst(list);
	 if(first == NULL)
		first = &list->anchor;
	 
	elem = (My402ListElem*)malloc(sizeof(My402ListElem));
	 if(NULL == elem)
	 {
		 //error??
		 return FALSE;
	 }
	 elem->obj = obj;

	 list->anchor.next = elem;
	 elem->prev = &list->anchor;

	 elem->next = first;
	 first->prev = elem;
	 ++list->num_members;
	 return TRUE;
	 
	 return FALSE;
 }
开发者ID:qqibrow,项目名称:os_course_project,代码行数:25,代码来源:my402list.c


示例16:

// Returns previous element else NULL if element is first item on list
My402ListElem *My402ListPrev(My402List* myList, My402ListElem* listElement) { 
	if(listElement != My402ListFirst(myList)) {
		return listElement->prev;
	} else {
		return NULL;
	}
}
开发者ID:saigeethakandepallicherukuru,项目名称:cs402,代码行数:8,代码来源:my402list.c


示例17: My402ListPrepend

int  My402ListPrepend(My402List *list, void *obj)
{
if(list==NULL)
	return FALSE;
//the new elemenet to be prepended
My402ListElem *listelem = NULL;
listelem = (My402ListElem *) malloc( sizeof(My402ListElem) );
if(listelem == NULL)
	return FALSE;
//if list is empty just alter anchor ptrs
if(list->num_members == 0){
	list->anchor.next = listelem;
	list->anchor.prev = listelem;
	listelem->obj = (void*) obj;
	//store anchor address as it is not a ptr type
        listelem->next = &(list->anchor);
        listelem->prev = &(list->anchor);
        list->num_members++;
}
//Just prepend the new element to the first element
else{
	My402ListElem *firstelem = My402ListFirst(list);
	if (firstelem != NULL){
		firstelem->prev = listelem;
		list->anchor.next = listelem;
		listelem->prev = &(list->anchor);
		listelem->next = firstelem;
		listelem->obj = (void*) obj;
		list->num_members++;
	}
}
return TRUE;
}
开发者ID:darshanramu,项目名称:TokenBucketEmulation,代码行数:33,代码来源:my402list.c


示例18: My402ListPrepend

int My402ListPrepend(My402List * list, void * data)
{
    // Create the new node
    My402ListElem * elem;
    elem = (My402ListElem *)malloc(sizeof(My402ListElem));
    if(!elem) // Allocate memory failed
        return 0;
    elem -> obj = data;
    // Insert the node
    My402ListElem * first_elem = My402ListFirst(list);
    if(first_elem)
    {
        elem -> prev = &(list -> anchor);
        elem -> next = first_elem;
        (list -> anchor).next = elem;
        first_elem -> prev = elem;
        list -> num_members++;
    }
    else // List is empty
    {
        elem -> next = &(list -> anchor);
        elem -> prev = &(list -> anchor);
        (list -> anchor).next = elem;
        (list -> anchor).prev = elem;
        list -> num_members++;
    }
    return 1;
}
开发者ID:FrankSzn,项目名称:USC-Projects,代码行数:28,代码来源:my402list.c


示例19: interrupt_main

void interrupt_main()
{
    //printf("<-----CTR+C RECIEVED------>\n");
    SERVER_DIE = 1;
    pthread_kill(TOKEN, SIGUSR1);
    pthread_kill(PACKET, SIGUSR2);

    pthread_mutex_lock(&m);
    //printf("Inside mutex of Man\n");
    while(!My402ListEmpty(Q2)){
        My402ListElem *elem = My402ListFirst(Q2);
        My402dataElem *topEle = (My402dataElem*)(elem->obj);
        My402ListUnlink(Q2, elem);

        TIME_AT_Q1 = diff_timeval(TIME_AT_Q1, topEle->q1duration);
    }
    /* Clear the list */
    My402ListUnlinkAll(Q1);
    pthread_mutex_unlock(&m);

    pthread_cond_broadcast(&cond_t);

    //printf("<-----MAIN DYING------>\n");
    pthread_exit(0);
}
开发者ID:dan-boa,项目名称:Assignment2,代码行数:25,代码来源:warmup2.c


示例20: My402ListPrepend

extern int  My402ListPrepend(My402List* List, void* insData)
 {
   My402ListElem *newNode = (My402ListElem *) malloc(sizeof(My402ListElem));

   if(newNode != NULL)
    {
        newNode->obj = insData;
        if(My402ListEmpty(List))
            {
                List->anchor.next = newNode;
                List->anchor.prev = newNode;
                newNode->next = &(List->anchor);
                newNode->prev = &(List->anchor);
                (List->num_members)++;
                return TRUE;
            }
        else
            {
                My402ListElem *firstNode = My402ListFirst(List);
                List->anchor.next = newNode;
                newNode->next = firstNode;
                firstNode->prev = newNode;
                newNode->prev = &(List->anchor);
                (List->num_members)++;
                return TRUE;
            }
    }
     return FALSE;

 }
开发者ID:mitulshr,项目名称:acad_projects,代码行数:30,代码来源:my402list.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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