Exemple #1
0
void TriplePuzzle::testAndMarkSwap(int x1, int y1, int x2, int y2)
{
	if (testSwap(x1, y1, x2, y2))
	{
		markCanMove(x1, y1, x2, y2);
	}
}
Exemple #2
0
int main(){
	testChange();

	testSwap();
	
	testLength();
}
Exemple #3
0
int main() {
	testSwap();
	testBuildMaxHeap();
	testMaxHeapify();
	testMerge();
	testBubbleSort();
	testSelectSort();
	testInsertSort();
	testMergeSort();
	testHeapSort();
	return 0;
}
Exemple #4
0
//
// used to swap red and blue
void PspMemorySwap::swap(uint16 *dst16, const uint16 *src16, uint32 bytes, PSPPixelFormat &format) {
	DEBUG_ENTER_FUNC();

#ifdef TEST_MEMORY_COPY
	uint32 debugBytes = bytes;
	const uint16 *debugDst = dst16, *debugSrc = src16;
#endif

	// align the destination pointer first
	uint32 prefixDst = (((uint32)dst16) & 0x3);	// for swap, we can only have 2 or 0 as our prefix

	if (prefixDst) {
		bytes -= prefixDst;						// remember we assume bytes > 4
		*dst16++ = format.swapRedBlue16(*src16++);

		if (bytes < MIN_AMOUNT_FOR_COMPLEX_COPY) { // check if it's worthwhile to continue
			swap16(dst16, src16, bytes, format);

#ifdef TEST_MEMORY_COPY
			testSwap(debugDst, debugSrc, debugBytes, format);
#endif
			return;
		}
	}

	// check the source pointer alignment now
	uint32 alignSrc = (((uint32)src16) & 0x3);

	if (alignSrc) {						// we'll need to realign our reads
		PSP_DEBUG_PRINT("misaligned copy of %u bytes from %p to %p\n", bytes, src16, dst16);
		swap32Misaligned((uint32 *)dst16, src16, bytes, format);
	} else {
		swap32Aligned((uint32 *)dst16, (const uint32 *)src16, bytes, format);
	}

#ifdef TEST_MEMORY_COPY
	testSwap(debugDst, debugSrc, debugBytes, format);
#endif

}
Exemple #5
0
	bool TestBTree::doTest()
	{
		if( benchmark )
		{
			doBenchmark();
			return true;
		}
		else
		{
			return testRandom() && testClear() && testIteration() 
				&& testComparisons() && testSearching() && testSwap() 
				&& testInsert() && testErase() && testCopy();
		}
	}
Exemple #6
0
int* perturbation(int* s0, int k, int n) {
	int* s = new int[n];
    int* randItems = new int[n];

    shuffle(randItems, n);

    for(int i = 0; i < n; i++) {
    	s[i] = s0[i];
    }

    for(int i = 0; i < 2*k; i = i+2) {
    	if(randItems[i] < randItems[i+1]) {
    		cost = testSwap(s, randItems[i], randItems[i+1]);	
    		swap(s, randItems[i], randItems[i+1]);
    	} else {
    		cost = testSwap(s, randItems[i+1], randItems[i]);	
    		swap(s, randItems[i+1], randItems[i]);
    	}
    }

    delete [] randItems;

    return s;
}
Exemple #7
0
 void run() override
 {
     testFreeFunctions();
     testPrepare();
     testSwap();
 }
Exemple #8
0
 void run() override
 {
     testConstruction();
     testSwap();
 }