Example #1
0
bool Sudoku::fillInBigSquares() {
	PQueue<BigSquare & > queue;
	for (int i = 0; i < SUDOKU_SIZE; i++)
		queue.push(squares[i]);

	return fillInSquares(queue, emptySquare);
}
Example #2
0
bool Sudoku::fillInColumns() {
	PQueue<Row & > queue;
	for (int i = 0; i < SUDOKU_SIZE; i++)
		queue.push(columns[i]);

	return fillInSquares(queue, emptySquare);
}
Example #3
0
int main() {
	PQueue<int> q;
	int* a = new int[SIZE];
		unsigned int i;
		// fill array with random integers
		for(i = 0; i < SIZE; i++) {
			a[i] = rand()%(SIZE*4);
		}

		int* p = a;
		// insert all items
		for( i = 0; i < SIZE; i++) {
			//cout << "Inserting: " << *(p+i) << "\n";
			q.push(*(p+i));
		}

		// add all elements to result array
		vector<int> result;
		while(!q.empty()) {
			int * temp = q.top();
			q.pop();
			result.push_back(*temp);
			delete temp;
		}
//		unsigned int k;
//		for (k = 0; k < result.size(); k++) {
//			cout << " " << result[k];
//		}
//		cout << endl;

		// If result is not sorted, something went wrong
		// uncomment above code to view all elements inline
		unsigned int l;
		bool fail = false;
		for (l = 1; l < result.size() ; l++) {
			if (result[l-1] > result[l]) {
				cout << "LIST NOT SORTED, FAILURE" << endl;
				fail = true;
			}
		}
		if (!fail) {
			cout << "Test was successful, integers were sorted" << endl;
		}
		delete[] a;
	return 0;
}