Example #1
0
/* 得到顺序表指定数据元素的后继 */
bool NextElem(SeqList L, DataType cur_e, DataType *pre_e)
{
	int pos;

	pos = LocateList(L, cur_e, compare);

	if(pos = L.length)
		return false;
	
	*pre_e = L.list[pos];
	return true;
}	
Example #2
0
/* 得到顺序表指定数据元素的前驱 */
bool PriorElem(SeqList L, DataType cur_e, DataType *pre_e)
{
	int pos;
	
	pos = LocateList(L, cur_e, compare);

	if(pos < 2)
		return false;
	
	*pre_e = L.list[pos - 2];
	return true;

}
Example #3
0
void DelElem(SeqList *A, SeqList B)
{
	int i, pos;
	DataType e;

	for(i = 0; i < B.length; i++)
	{
		if(GetElem(B, i + 1, &e)) /* 依次把B中的每个元素取出来 */
		{
			if( (pos = LocateList(*A, e, compare )) >= 1)
				ListDelete(A, pos, &e );
		}

	}

}
Example #4
0
int main()
{
	SqList L;
	printf("%ld\n",sizeof(L));
	InitSqList(L);
	int i;
	for(i=0;i<20;++i)
		push_back(L,i);
	Display(L);
	printf("L.length :%d\n",L.length);
	printf("listlength:%d\n",ListLength(L));
	Elem e,prio,next;
	GetElem(L,2,e);
	PriorElem(L,prio,e);
	NextElem(L,next,e);
	printf("the number 2 tumple:%d\n",e);
	printf("prio e:%d\n",prio);
	printf("next e:%d\n",next);
	ListInsert(L,8,10000);
	Display(L);
	LocateList(L,10000);
	DeleteK(L,5,3);
	Display(L);
	DestroyList(L);
	printf("size of a.length :%d\n",L.listsize);
	if(ListEmpty(L))
		printf("empty!\n");
	
	/*char* p = NULL;
	p=(char*)malloc(10*sizeof(char));
	if(p==NULL)
	{
		printf("filure");
		exit(1);
	}
	printf("%p\n",p);

	strcpy(p,"abc");
	printf("%c\n%c\n%c\n",*p,*p+1,*p+2);
	printf("%p\n%p\n",p,p+1);
	//if(p!=NULL)
		free(p);
	//p=NULL;
	
	//DestroyList(L);
	//Display(L);*/ return 0;
}