コード例 #1
0
/* BrowserWindow::openTree
 * 'Opens' the items in [node] and all its children, adding them
 * to the browser canvas' list of items. If [clear] is true, the
 * current list contents will be cleared
 *******************************************************************/
void BrowserWindow::openTree(BrowserTreeNode* node, bool clear)
{
	// Clear if needed
	if (clear)
	{
		canvas->clearItems();

		// Also add global items
		for (unsigned a = 0; a < items_global.size(); a++)
			canvas->addItem(items_global[a]);
	}

	// Add all items in the node
	for (unsigned a = 0; a < node->nItems(); a++)
	{
		canvas->addItem(node->getItem(a));
		node->getItem(a)->parent = this;
	}

	// Add all child nodes' items
	for (unsigned a = 0; a < node->nChildren(); a++)
		openTree((BrowserTreeNode*)node->getChild(a), false);

	// If the list was cleared, sort it, filter it and update the canvas scrollbar
	if (clear)
	{
		doSort(choice_sort->GetSelection());
		canvas->filterItems(text_filter->GetValue());
		canvas->showSelectedItem();
	}
}
コード例 #2
0
ファイル: SVIS.CPP プロジェクト: rpmessner/bouncingballs
void initializeSpheres() {
	groundRad=0;
    int i;
	for(i=0; i<MAXSPHERES; i++) order[i][1]=65000;

	for(i=0; i<NUMSPHERES; i++) {
		sphere[i].r=i+1;
		sphere[i].x=(i+1)*((NUMSPHERES/6)+3)*spir[i%12][0]+5; //position it along a spiral
		sphere[i].z=(i+1)*((NUMSPHERES/6)+3)*spir[i%12][1]+5; //position it along a spiral
		//only change color if it had no color so far
		if (!(sphere[i].color[0]>0.0)||!(sphere[i].color[1]>0.0)||!(sphere[i].color[2]>0.0)) {
			changeColor(&sphere[i], COLOR);
		} 
		sphere[i].up=true;
		sphere[i].firstUp=false;
		sphere[i].inAir=false;
		sphere[i].SEC=0;
		sphere[i].height=0;
		if (i==NUMSPHERES-1) {
			groundRad=sqrt((double)((sphere[i].x)*(sphere[i].x))+(double)((sphere[i].z)*(sphere[i].z)))+(double)(i*1.2);
		}
		doSort(i,sphere[i].z);
	}

	//to always have the same view on the scene independend of how big the circle surface is
	//and how many spheres are on it I compute the coordinates for y and z dynamically
	double distance=(double)(groundRad*1.02)/(double)(sin((alpha/2)*(M_PI/180)));
	double yz=sqrt((distance*distance)/2);
	
	//The view is along and on the z axis to the origin
	glLoadIdentity();
	gluLookAt(0.0, yz, yz, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
}
コード例 #3
0
int main()
{
	double x [100];
	double y [50];
	int i;
	
	srand(time(NULL));
		
	setToZero(x,100);
	/*fillArray(x, 10);*/
	
	fillRandom(&x[0],100);
	printArray(x,100);
	printf("The largest is %6.2f\n",largest(x,100));
	printf("Total is %6.2f\n",sumArray(x,100));
	printf("Ave is %6.2f\n",aveArray(x,100));
	printf("\n@@@@@@@@@@Sorted@@@@@@@@@@@@@@@@@@\n");
	doSort(x,100);
	
	printArray(x,100);
	/*
	fillRandom(y,50);
	printArray(y,50);
	*/
	
	
	
	
	
	
	return 0;
}
コード例 #4
0
int main()
{
	double x[100];
	double y[30];
	double z[10];
	
	int i;
	srand(time(NULL));
	
	/* set element to zero	*/
	init(x,100);
	init(y,30);
	init(z , 10);
	
	/*fillArray(&z[0],10);*/
	fillRandom(x,100);
	/*fillRandom(y, 30);*/
	printArray(x,100);
	printf("The largest is :%6.2f\n",largest(x,100));
	doSort(x,100);
	printf("@@@@@@@@@@@  Sorted @@@@@@@@@@@@@@@@@@\n");
	printArray(x,100);
	
	
	
	/*
	printf("Total is :%6.2f\n",sumArray(x,100)+sumArray(y,30)); 
	printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
	printf("Total is :%6.2f\n",aveArray(x,100));
	*/
	
	return 0;
}
コード例 #5
0
/* BrowserWindow::setSortType
 * Sets the current sorting method to [type]
 *******************************************************************/
void BrowserWindow::setSortType(int type)
{
	// Check type index
	if (type < 0 || (unsigned)type >= choice_sort->GetCount())
		return;

	// Select sorting type
	choice_sort->SetSelection(type);

	// Do sorting
	doSort(type);
}
コード例 #6
0
ファイル: main.cpp プロジェクト: georgy-schukin/mpiaa
void doWork(const std::string &input_file, const std::string &output_file) {
    ArrayType data = readFromFile<ArrayType>(input_file);

    std::cout << "Sorting " << data.size() << " elements..." << std::endl;
    std::clock_t start_time = std::clock();

    ArrayType sorted_data = doSort(data);

    std::clock_t end_time = std::clock();
    const double duration = (end_time - start_time)/double(CLOCKS_PER_SEC);
    std::cout << "Sorting took " << duration << " seconds" << std::endl;

    writeToFile(output_file, sorted_data);
}
コード例 #7
0
ファイル: Algorithm.cpp プロジェクト: SortC/SortC
Step* Algorithm::getPrevStep() {
    doSort();
    if (numbOfCurrentStep > 0)
    {
        return steps[--numbOfCurrentStep];
	}
    else if(numbOfCurrentStep == 0) {
        return steps[numbOfCurrentStep];
    }
	else
	{
		return NULL;
	}
}
コード例 #8
0
ファイル: Algorithm.cpp プロジェクト: SortC/SortC
Step* Algorithm::getNextStep() {
    doSort();
    if (numbOfCurrentStep < numbOfSteps -1)
    {
        return steps[++numbOfCurrentStep];
	}
    else if(numbOfCurrentStep < 0){
        return steps[++numbOfCurrentStep];
    }
	else
	{
		return NULL;
	}
}
コード例 #9
0
void doSearchByID(student_t_ptr student_ptr[]){
    test();
    int number,i=0;
    puts("Please input ID");
    scanf("%d",&number);
    doSort(student_ptr,scoreless);
    do{
    if(number == student_ptr[i]->ID){
        doPrintStudent(*student_ptr[i]);
        printf("\tRank:%d",student_ptr[i]->rank);
        putchar('\n');
        pause();
        return;
    }
    i++;
    }while(i<numberofstudent);
    printf("\nID %d is not exist\n",number);
    pause();
}
コード例 #10
0
void doSearchByName(student_t_ptr student_ptr[]){
    test();
    int i=0;
    char name[50];
    puts("Please input name");
    scanf("%s",name);
    doSort(student_ptr,scoreless);
    do{
    if(strcmp(name,student_ptr[i]->name) == 0){
        doPrintStudent(*student_ptr[i]);
        printf("\tRank:%d",student_ptr[i]->rank);
        putchar('\n');
        pause();
        return;
    }
    i++;
    }while(i<numberofstudent);
    printf("\nname %s is not exist\n",name);
    pause();
}
コード例 #11
0
/* BrowserWindow::onChoiceSortChanged
 * Called when the 'Sort By' dropdown selection is changed
 *******************************************************************/
void BrowserWindow::onChoiceSortChanged(wxCommandEvent& e)
{
	// Re-sort items
	doSort(choice_sort->GetSelection());
}
コード例 #12
0
ファイル: IS.cpp プロジェクト: ggrunewald/NPB3.0-Cpp
void IS::RunBenchMark()
{
	cout << " Size: " << TOTAL_KEYS << " Iterations: " << MAX_ITERATIONS << endl;

	//Initialize timer
	timer = new Timer();
	timer->ResetTimer(0);

	//Generate random number sequence and subsequent keys on all procs
	InitKeys(amult); 	// Random number gen seed
						// Random number gen mult

	/* Do one iteration for free (i.e., "untimed") to guarantee initialization of
		all data and code pages and respective tables */
	if(isSerial)
	{
		Rank(1);
	}
	else
	{
		SetupThreads(this);

		RankThread::iteration = 1;

		doSort();

		for(int i=0; i<MAX_KEY; i++ )
			master_hist[i] = 0;

		doSort();

		Partial_Verify(1);
	}

	/*Start verification counter */
	passed_verification = 0;

	if( execClass != 'S' )
		cout << "\n     iteration#" << endl;

	timer->Start(0);

	/*This is the main iteration */
	for(int it=1; it<=MAX_ITERATIONS; it++ )
	{
		if( execClass != 'S' ) cout << "	  " << it << endl;

		if(isSerial)
		{
			Rank(it);
		}
		else
		{
			RankThread::iteration = it;

			doSort();

			for(int i=0; i<MAX_KEY; i++ )
				master_hist[i] = 0;

			doSort();
			Partial_Verify(it);
		}
	}

	timer->Stop(0);

	/*This tests that keys are in sequence: sorting of last ranked key seq
	  occurs here, but is an untimed operation			       */
	Full_Verify();

	int verified = 0;

	if( passed_verification == 5*MAX_ITERATIONS + 1 )
		verified = 1;

	std::chrono::duration<double> tm = timer->ReadTimer(0);

	BMResults * results = new BMResults(BMName,
						execClass,
						TOTAL_KEYS,
						0,
						0,
						MAX_ITERATIONS,
						tm,
						GetMOPS(tm, MAX_ITERATIONS, TOTAL_KEYS),
						"keys ranked",
						verified,
						isSerial,
						numThreads,
						bid);

	results->PrintVerificationStatus(execClass, verified, BMName);

	results->Print();
}
コード例 #13
0
void doSortDictionaryOrderByName(student_t_ptr student_ptr[]){
    test();
    doSort(student_ptr,nameless);
    doListWithRanl(student_ptr);
}
コード例 #14
0
void doSortInAscendingOrderByID(student_t_ptr student_ptr[]){
    test();
    doSort(student_ptr,IDmore);
    doListWithRanl(student_ptr);
}
コード例 #15
0
void doSortInAsescendingOrderByTotalScore(student_t_ptr student_ptr[]){
    test();
    doSort(student_ptr,scoremore);
    doListWithRanl(student_ptr);
}