Ejemplo n.º 1
0
/**
* @brief main \n
* 测试程序的主函数,进行int以及char的创建、增、删、改、查、排序、清空操作。
* @param[in]	argc		带int参数形式
* @param[in]	*argv[]		带char参数形式
* @return		函数默认返回值
*/
int main( int argc, char *argv[] )
{
	DLNode *List;
	/* 进行int 数组测试 */
	int flag = 0;
	int num[1000],i = 0;
	for(i = 0; i < 1000; i++)
	{
		//srand(time(NULL));
		num[i] = rand();
	}
	List = CreateList();
	if (List == NULL)
		printf("Error!\n");
	else
		printf("OK!Create OK!\n");
	for(i = 0; i < 1000; i++)
		InsertList(List,(void *)&num[i]);//(num + i));
	ShowList(List,flag);
	sleep(1);
	SequenceList(List,flag,CallBackSequence);
	ShowList(List,flag);
	sleep(1);
	SearchList(List,&num[1],flag,CallBackSearch);
	UpdateList(List,&num[1],&num[5],flag);
	ShowList(List,flag);
	sleep(1);
	DeleteList(List,&num[5],flag);
	ShowList(List,flag);
	sleep(1);
	DropList(List);
	ShowList(List,flag);
	sleep(1);
	/* 进行char * 字符串测试 */
	char *test1 = "test1";
	char *test2 = "test2";
	char *test3 = "test3";
	char *test5 = "test5";
	List = CreateList();
	if (List == NULL)
		printf("Error!\n");
	else
		printf("OK!Create OK!\n");
	InsertList(List,test1);
	InsertList(List,test2);
	InsertList(List,test3);
	ShowList(List,2);
	sleep(1);
	SequenceList(List,2,CallBackSequence);
	SearchList(List,test2,2,CallBackSearch);
	UpdateList(List,test1,test5,2);
	ShowList(List,2);
	sleep(1);
	DeleteList(List,test5,2);
	ShowList(List,2);
	sleep(1);
	DropList(List);
	ShowList(List,2);
	sleep(1);
	/* 进行char 字符测试 */
	char ch[1000];
	int chascii;
	for(i = 0; i< 1000; i++)
	{
		//srand(time(NULL));
		chascii = rand()%25; //生成0-25的值
		ch[i] = chascii + 'a';
	}
	for(i = 0; i < 1000; i++)
		InsertList(List,(void *)&ch[i]);//(num + i));
	ShowList(List,1);
	sleep(1);
	SequenceList(List,1,CallBackSequence);
	ShowList(List,1);
	sleep(1);
	SearchList(List,&ch[1],1,CallBackSearch);
	UpdateList(List,&ch[1],&ch[5],1);
	ShowList(List,1);
	sleep(1);
	DeleteList(List,&ch[5],1);
	ShowList(List,1);
	sleep(1);
	DropList(List);
	ShowList(List,1);
	
	return 0;
}
Ejemplo n.º 2
0
/**
* @brief SequenceList \n
* 排列双向链表函数通过flag的flag,选择合适的排序方法
* @param[in]	*List			双向链表默认链表接口
* @param[in]	flag					提供接口,让用户定义具体比较函数
* @param[in]	*CallBackCmp	各种类型的回调函数接口
*/
DLNode *SequenceList(DLNode *List, int flag, int (*CallBackCmp)(const void *,const void *))
{
	if(flag == 0)
	{
		DLNode *p_one = NULL, *p_two = NULL, *temp = NULL;
		void *temp_data = NULL;

		p_one = List->next;
		p_two = List->next;

		for(p_one = p_one; p_one->next != List; p_one = p_one->next)
		{
			temp=p_one;
			for(p_two = p_one->next; p_two != List; p_two = p_two->next)
			{
				if(CallBackCmp(p_two->data, temp->data) > 0 )
					temp = p_two;
			}
			if(temp != p_one)
			{
				temp_data=p_one->data;
				p_one->data=temp->data;
				temp->data=temp_data;
			}
		}
		//free(temp);
		//free(temp_data);
	}
	else if(flag == 1)
	{
		int Nodenum = 0;
		Nodenum = ShowList(List, 2, 1);

		char **StrList = NULL;
		StrList = (char**)malloc(Nodenum * sizeof(char*));
		if(StrList == NULL)
			return ;
		memset(StrList, 0, Nodenum * sizeof(char *));
		int i = 0;
		DLNode *p = NULL;

		p = List->next;
		//printf("back %s\n",(char *)p->data);
		while(p != List)
		{	
			StrList[i] = (char *)p->data;
			//printf("get   %s\n",StrList[i]);
			p = p->next;
			i++;
		}
		qsort(StrList, Nodenum, sizeof(char*), CallBackCmp);
		p = List->next;
		for(i = 0; i < Nodenum; i++)
		{
			//printf("qsort   %s\n",StrList[i]);
			p->data = StrList[i];
			p = p->next;
		}
		free(StrList);
	}
	else if(flag == 2)
	{
		QuickSort(List, List->next, List->back, CallBackCmp);
	}
	else if(flag == 3)
	{
		int nodenum = 0;
		nodenum = ShowList(List,2,1);
		int i = 0, j = 0, k = 0;
		DLNode *p_one = NULL;
		DLNode *p_two = NULL;

		for (k = nodenum / 2; k > 0; k /= 2)
		{
			p_one = p_one->next;
			p_two = NULL;
			for(i = 0; i < nodenum; i++ )
			{
				p_one = p_one->next;
				p_two = p_two->next;
				for (j = i + k; j < nodenum; j += k )
				{
					if(CallBackCmp(p_one->data,p_two->data) < 0 )
					{
						void *temp = NULL;
						temp = p_one->data;
						int l = j - k;
						while(l >= 0 && (CallBackCmp(p_two->data,temp) > 0))
						{
							p_one->data = p_two->data;
							p_two = p_two->next;
							l -= k;

						}
						
						p_one->data = temp;

					}
				}
			}
		}
	}
	else
	{
		printf("Error Choose!\n ONLY 0, 1\n");
	}
}
Ejemplo n.º 3
0
//----------------------------------------------------
void CPhoto::OnIniLoad()
{
    ShowList() ;
    m_pLoadIniTimer->stop() ;
}
Ejemplo n.º 4
0
/***************************************************************************************************
*FunctionName: activityInput
*Description: 界面输入
*Input: 
*Output: 
*Return: 
*Author: xsx
*Date: 2016年12月21日09:00:59
***************************************************************************************************/
static void activityInput(unsigned char *pbuf , unsigned short len)
{
	S_UserPageBuffer->lcdinput[0] = pbuf[4];
	S_UserPageBuffer->lcdinput[0] = (S_UserPageBuffer->lcdinput[0]<<8) + pbuf[5];
		
	/*返回*/
	if(S_UserPageBuffer->lcdinput[0] == 0x1200)
	{
		DeleteCurrentTest();
			
		backToActivity(lunchActivityName);
	}
		
	/*上翻也*/
	else if(S_UserPageBuffer->lcdinput[0] == 0x1203)
	{			
		if(S_UserPageBuffer->pageindex > 1)
		{
			S_UserPageBuffer->pageindex--;
						
			S_UserPageBuffer->selectindex = 0;
						
			ShowList();
			SelectUser(S_UserPageBuffer->selectindex);
		}
	}
	/*下翻页*/
	else if(S_UserPageBuffer->lcdinput[0] == 0x1204)
	{			
		if(S_UserPageBuffer->pageindex < (MaxUserNum / MaxPageShowNum))
		{
			S_UserPageBuffer->tempUser = &S_UserPageBuffer->user[(S_UserPageBuffer->pageindex)*MaxPageShowNum];
			
			if(S_UserPageBuffer->tempUser->crc == CalModbusCRC16Fun1(S_UserPageBuffer->tempUser, sizeof(User_Type)-2))
			{
				S_UserPageBuffer->pageindex++;
						
				S_UserPageBuffer->selectindex = 0;
						
				ShowList();
				SelectUser(S_UserPageBuffer->selectindex);
			}
		}
	}
	/*确定*/
	else if(S_UserPageBuffer->lcdinput[0] == 0x1201)
	{
		if(S_UserPageBuffer->tempUser2 != NULL)
		{
			//如果是排队测试,则保存操作人到排队测试共用操作人
			if(S_UserPageBuffer->currenttestdata->testlocation > 0)
				SetPaiduiUser(S_UserPageBuffer->tempUser2);
				
			/*以当前选择的操作人作为本次测试数据的操作人*/
			memcpy(&(S_UserPageBuffer->currenttestdata->testdata.user), S_UserPageBuffer->tempUser2, sizeof(User_Type));
			
			startActivity(createSampleActivity, NULL);
		}
		else
		{
			AddNumOfSongToList(9, 0);
			SendKeyCode(1);
		}
	}
	/*选择操作人*/
	else if((S_UserPageBuffer->lcdinput[0] >= 0x1205)&&(S_UserPageBuffer->lcdinput[0] <= 0x1209))
	{			
		S_UserPageBuffer->selectindex = S_UserPageBuffer->lcdinput[0] - 0x1205+1;
		SelectUser(S_UserPageBuffer->selectindex);
	}
	//编辑操作人
	if(S_UserPageBuffer->lcdinput[0] == 0x120a)
	{
		startActivity(createUserManagerActivity, NULL);
	}
}
Ejemplo n.º 5
0
void pgCollection::ShowList(ctlTree *browser, ctlListView *properties)
{
	ShowList(((pgaCollectionFactory *)GetFactory())->GetItemTypeName(), browser, properties);
}
Ejemplo n.º 6
0
int main(void)
{
	int i,n;
	char a[LEN];
	SList L1 = (SList)malloc(sizeof(SNode));
	L1->next = NULL;
	SList L2 = (SList)malloc(sizeof(SNode));
	L2->next = NULL;
	for (;;) {
		printf("选择操作对象(1.表1 2.表2 3.合并):");
		scanf_s("%d", &n);
		if (n == 1) {
			printf("\n输入你的选择(1.插入2.删除3.合并):");
			scanf_s("%d", &i);
			switch (i) {
			case 1:
				Insert(&L1);
				ShowList(L1);
				break;
			case 2:
				printf("输入要删除的学生学号:");
				ReadLine(a, LEN);
				Delete(&L1, a);
				ShowList(L1);
				break;
			default:
				printf("输入操作不合法!");
				break;
			}
		}
		else if (n == 2) {
			printf("\n输入你的选择(1.插入2.删除3.合并):");
			scanf_s("%d", &i);
			switch (i) {
			case 1:
				Insert(&L2);
				ShowList(L2);
				break;
			case 2:
				printf("输入要删除的学生学号:");
				ReadLine(a, LEN);
				Delete(&L2, a);
				ShowList(L2);
				break;
			default:
				printf("输入操作不合法!");
				break;
			}
		}
		else if (n == 3) {
			Merge(&L1, &L2);
			ShowList(L1);
			system("pause");
			return 0;
		}
		else {
			printf("输入值不合法!");
			exit(0);
		}
	}
	return 0;
}
Ejemplo n.º 7
0
void
nsComboboxControlFrame::RollupFromList()
{
  if (ShowList(PresContext(), PR_FALSE))
    mListControlFrame->CaptureMouseEvents(PR_FALSE);
}
Ejemplo n.º 8
0
void Sort::Show()
{
    CountingSort();
    ShowList(transIn);
    ShowList(outValue);
}