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


C++ ListPtr::allocateNode方法代码示例

本文整理汇总了C++中ListPtr::allocateNode方法的典型用法代码示例。如果您正苦于以下问题:C++ ListPtr::allocateNode方法的具体用法?C++ ListPtr::allocateNode怎么用?C++ ListPtr::allocateNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ListPtr的用法示例。


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

示例1: addMiddleList

int addMiddleList(ListPtr listp,NodePtr position,void* data){ /* Add new Node in the middle of the Queue */

	int i=0;

	//there is always a previous and a next Node
	if(listp->items > 0){
		if(position == NULL) {
			printf("Position not valid...\n");
			return -1;
		}
		else {
			listp->Current = position->previous; //Current is the previous Node 
		}

		listp->Current->next = malloc(sizeof(Node));
		listp->Current->next->previous = listp->Current;
		listp->Current->next->next = position;
		position->previous = listp->Current->next;
		
		listp->allocateNode(&(listp->Current->next->data),data);

		listp->Current = listp->Head;

		(listp->items)++;

	}
	else{
		printf("List is not properly initialised...\n");
		return -1;
	}
}
开发者ID:PanagiotisPapageorgiou,项目名称:SoftDev2014-SocialNetworkDatabase,代码行数:31,代码来源:uberlist.c

示例2: addLastList

int addLastList(ListPtr listp,void* data){ /* Adds a Node to the end of the List */

	int i=0;

	if(listp->items == 0){ /* No items yet */

		listp->Head = malloc(sizeof(Node));
		listp->allocateNode(&(listp->Head->data),data);

		listp->Head->next = (Node*) NULL;
		listp->Head->previous = (Node*) NULL;

		listp->Current = listp->Head;
		listp->Last = listp->Head;

		(listp->items)++;

		return 0;
	}
	else if(listp->items > 0){

		listp->Last->next = malloc(sizeof(Node));

		listp->Last->next->previous = listp->Last;
		listp->Last = listp->Last->next;
		listp->Last->next = (Node*) NULL;
	
		listp->allocateNode(&(listp->Last->data),data);

		(listp->items)++;

		listp->Current = listp->Last;


		return 0;
	}
	else{
		printf("List is not properly initialised...\n");
		return -1;
	}

}
开发者ID:PanagiotisPapageorgiou,项目名称:SoftDev2014-SocialNetworkDatabase,代码行数:42,代码来源:uberlist.c

示例3: addFirstList

int addFirstList(ListPtr listp,void* data){ /* Add new Node as Head of the Queue */

	int i=0;

	if(listp->items == 0){
		listp->Head = malloc(sizeof(Node));
		listp->allocateNode(&(listp->Head->data),data);

		listp->Head->next = (Node*) NULL;
		listp->Head->previous = (Node*) NULL;
		listp->Current = listp->Head;
		listp->Last = listp->Head;

		(listp->items)++;
		return 0;
	}
	else if(listp->items > 0){

		listp->Head->previous = malloc(sizeof(Node));
		listp->Head->previous->next = listp->Head;
		listp->Head = listp->Head->previous;
		
		listp->allocateNode(&(listp->Head->data),data);

		listp->Head->previous = (Node*) NULL;

		listp->Current = listp->Head;

		(listp->items)++;

	}
	else{
		printf("List is not properly initialised...\n");
		return -1;
	}
}
开发者ID:PanagiotisPapageorgiou,项目名称:SoftDev2014-SocialNetworkDatabase,代码行数:36,代码来源:uberlist.c


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