Example #1
0
void OTMLNode::copy(const OTMLNodePtr& node)
{
    setTag(node->tag());
    setValue(node->rawValue());
    setUnique(node->isUnique());
    setNull(node->isNull());
    setSource(node->source());
    clear();
    for(const OTMLNodePtr& child : node->m_children)
        addChild(child->clone());
}
Example #2
0
// *****************************************************
// class RankSystem
// *****************************************************
RankSystem::RankStats::RankStats( const char* uu, const char* nn, RankSystem* pp ) {
	name = 0;
	namelen = 0;
	unique = 0;
	uniquelen = 0;
	score = 0;
	parent = pp;
	id = ++parent->rankNum;
	next = prev = 0;
	setName( nn );
	setUnique( uu );
}
Example #3
0
int main(int argc, char *argv[]){
	// Instantiate tallied variables.
	int i, j, width, correct, hintCount, guesses, hints, trys;
	//Instantiate stats array
	int stats[5]  = {0};
	// Determine width of Matrix	
	width = getWidth(argc, argv);	
	// Generate matrix based on width
	complex** M = generateMatrix(width);	
	// Create randmom number generator.
	srand((unsigned)time(NULL));	
	// Create string array for user input.
	char choice[20];	
	//	Create array of type complex to store generated row column pairs
	complex uniques[width * width];	
	// Continue game until user quits.
	while(strncmp(choice, "Q", 1) != 0){
		// Generate random row column pairs for ser to guess.
		i = rand()  % width;
		j = rand()  % width;
		// Reset counting variable for each generated row column pair.
		correct = hints = guesses = 0;
		while(correct == 0 && strncmp(choice, "Q", 1) != 0){
			// Count number of hints used for this specific pair.
			hintCount = 0;
			//	Display message to user displaying options.
			printf("M[0][0]=%p. M[i][j]=%p What's i and j?\n(Q to Quit or H or
			 HH or HHH for hints.): ", &M[0][0], &M[i][j]);
			// Recieve and store user input.
			fgets(choice, 20, stdin);
			// Check if user requested hints
			hintCount += checkHints(choice, M, width);
			// If user did not want hints check is valid answer submitted
			if (hintCount == 0){
				//	Check answer
				correct = checkAnswer(choice, i, j);
			}
			//	Accumulate hints used.
			hints += hintCount;
			// Accumulate guesses used.
			guesses++;
		}
		//	If user has not quit calculate stats for pair.
		if (strncmp(choice, "Q", 1) != 0){
			setUnique(uniques, i, j, stats);
			setStats(stats,hints, guesses);
		}
	}
	// Print stats of the game after user has quit.
	printStats(stats);
	// terminate matrix.
	killMatrix(M, width);
}
Example #4
0
    Array<T>* setIntersect(const Array<T> &first,
                           const Array<T> &second,
                           const bool is_unique)
    {
        if ((std::is_same<T, double>::value || std::is_same<T, cdouble>::value) &&
            !isDoubleSupported(getActiveDeviceId())) {
            OPENCL_NOT_SUPPORTED();
        }
        Array<T> unique_first = first;
        Array<T> unique_second = second;

        if (!is_unique) {
            unique_first  = *setUnique(first, false);
            unique_second = *setUnique(second, false);
        }

        size_t out_size = std::max(unique_first.dims()[0], unique_second.dims()[0]);
        Array<T> *out = createEmptyArray<T>(dim4(out_size, 1, 1, 1));

        compute::command_queue queue(getQueue()());

        compute::buffer first_data((*unique_first.get())());
        compute::buffer second_data((*unique_second.get())());
        compute::buffer out_data((*out->get())());

        compute::buffer_iterator<T> first_begin(first_data, 0);
        compute::buffer_iterator<T> first_end(first_data, unique_first.dims()[0]);
        compute::buffer_iterator<T> second_begin(second_data, 0);
        compute::buffer_iterator<T> second_end(second_data, unique_second.dims()[0]);
        compute::buffer_iterator<T> out_begin(out_data, 0);

        compute::buffer_iterator<T> out_end = compute::set_intersection(
            first_begin, first_end, second_begin, second_end, out_begin, queue
        );

        out->resetDims(dim4(std::distance(out_begin, out_end), 1, 1, 1));

        return out;
    }