Example #1
0
void index_sort(const VectorKey& keys, VectorSize& ind)
{	typedef typename VectorKey::value_type Compare;
	CheckSimpleVector<size_t, VectorSize>();

	typedef index_sort_element<Compare> element;

	CPPAD_ASSERT_KNOWN(
		size_t(keys.size()) == size_t(ind.size()),
		"index_sort: vector sizes do not match"
	);

	size_t size_work = size_t(keys.size());
	size_t size_out;
	element* work =
		thread_alloc::create_array<element>(size_work, size_out);

	// copy initial order into work
	size_t i;
	for(i = 0; i < size_work; i++)
	{	work[i].set_key( keys[i] );
		work[i].set_index( i );
	}

	// sort the work array
	std::sort(work, work+size_work);

	// copy the indices to the output vector
	for(i = 0; i < size_work; i++)
		ind[i] = work[i].get_index();

	// we are done with this work array
	thread_alloc::delete_array(work);

	return;
}
Example #2
0
void XaLibDom::ParseParamFromDom (xmlDocPtr doc, xmlNodePtr cur, VectorKey VectorKey, int counter) {

	xmlChar *key;
	char* keyChar;

	cur = cur->xmlChildrenNode;

	while (cur != NULL) {

		for(unsigned j=0; j<VectorKey.size(); ++j) {

			if (cur->type == XML_ELEMENT_NODE && (!xmlStrcmp(cur->name, (const xmlChar*)VectorKey.at(j).c_str()))) {
				
				string *nodeValue = new string();
				
				string StringKey=VectorKey.at(j).c_str();
				string StringValue="";

				key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
				keyChar = (char*)key;
				*nodeValue=keyChar;
				
				if (*nodeValue!="") {

					StringValue=*nodeValue;
				} else {
					
					StringValue="";
				}
				
				ParamFromDom[counter][StringKey]=StringValue;

				cur=cur->next;
				cur=cur->next;

			} else {

			}
		}

		cur=cur->next;
	}
	
};