Exemplo n.º 1
0
		Container sort_build(I arg_begin, ///< The begin iterator for the range on which the sorted copy should be based
		                     I arg_end    ///< The begin iterator for the range on which the sorted copy should be based
		                     ) {
			return sort_copy(
				Container{ arg_begin, arg_end }
			);
		}
Exemplo n.º 2
0
		Container sort_build(I arg_begin, ///< The begin iterator for the range on which the sorted copy should be based
		                     I arg_end,   ///< The begin iterator for the range on which the sorted copy should be based
		                     P arg_bin_pred ///< The binary predicate to use as a less-than operator for sorting
					         ) {
			return sort_copy(
				Container{ arg_begin, arg_end },
				arg_bin_pred
			);
		}
Exemplo n.º 3
0
// Check if the array is sorted by priority, because that is how the insert_by_priority function
// should work, it adds according to priority, higher priority is the front of the queue, the lowest
// is the rear of the queue.
int check_queue(unsigned int a[], unsigned int copy[], int size) 
{
	int i;
	int num_items = (rear - front) + 1;

	if(num_items != size)
		return -1;

	sort_copy(copy, size);

	/* LOGGING CODE

	printf("LOG: COPY = ");
	for (i=0; i<size; i++) {
		printf("LOG: %d ", copy[i]);
	}
	printf("\nLOG: REAL = ");
	for (i=0; i<size; i++) {
		printf("LOG: %d ", a[i]);
	}
	*/	

	for (i=0; i<size; i++) {

		if (a[i] != copy[i])
			return -1;
	
		if (i == size-1) 
			break;
	
		else {
			if (a[i] < a[i+1])
				return -1;
		}
	}

	return 0;	

}