TEST(SymbolTable, doubleInsertion) {
  CompileErrorList errors;
  SymbolGraph graph;
  graph.addNode(Symbol(ZP("A"), ZP("B")));
  graph.addNode(Symbol(ZP("A"), ZP("C")));
  graph.addNode(Symbol(ZP("C"), ZP("D")));
  graph.addNode(Symbol(ZP("C"), ZP("D")));
  graph.addNode(Symbol(ZP("C"), ZP("D")));
  graph.addNode(Symbol(ZP("D"), ZP("A")));
  auto eval = graph.evaluate();
  ASSERT_FALSE(eval.valid());
  ASSERT_FALSE(eval.duplicates().empty());
  ASSERT_EQ(eval.duplicates().size(), 2);
}
Exemple #2
0
void drawScene()
{
	
    
    reflection();


	//============================================Eixos
	if (noite)
		glColor4f(AMARELO);
	else
		glColor4f(BLACK);

    glColor4f(WHITE); //fazer reset as cores para o blend + texturas
    /*desenho da caixa*/

    duplicates();//mesmas funcoes que abaixo para meter os paineis a reflectir por  dentro
    //atras
     glPushMatrix();
        glColor4f(DEEPBLUE);
        glTranslatef(3, 0, 3);
        glRotatef(-90,1,0,0);  
        quad(2,0,0,0);
    glPopMatrix();

    //contrario a bola
     glPushMatrix();
        glColor4f(TORRADO);
        glTranslatef(3+multiplier*2, 0, 3+multiplier*2);
        glRotatef(180,0,1,0); //para a reflexao ficar na face exterior da caixa, senão ficava interior
        glRotatef(90,0,0,1); 
        quad(2,0,0,0);
    glPopMatrix();
    
    //em cima
   glPushMatrix();
        glColor4f(SBLUE);
        glTranslatef(3, multiplier*2, 3);   
        quad(2,0,0,0);
    glPopMatrix();

    //lado da bola
    glPushMatrix();
        glColor4f(TORRADO);
        glTranslatef(3, 0, 3);
        glRotatef(90,0,0,1); 
        quad(2,0,0,0);
    glPopMatrix();

    /* desenho do nivel */
    draw_level(level);
    /* desenho da bola */
    glPushMatrix();
        glColor4f(AMARELO);
        glTranslatef(posEsfera[0],posEsfera[1],posEsfera[2]);
        glutSolidSphere(raioEsfera, 256, 256);//radius , (slices(longitude), stacks(latitude))->malhas
    glPopMatrix();
   	glutPostRedisplay();
}
Exemple #3
0
int main(int argc, char **argv)
{
	if (argc < 2) {
		printf("missing filename\n");
		exit(127);
	}

	duplicates(argv[1]);
	return 0;
}
void Search::property_id_search(string input, vector<int> &results) {
	
	/** Note the results is a list of the integers--in the correct order and compressed **/

	// DATABASE QUERY VECTORS
	vector<string> * categories, select_list;
	vector<where_statement> where (1);
	vector<row_result> query_results;
	
	// RESULTS ANALYSIS
	vector<int>raw_list;
	vector<integer_key_value> key_value_results;
	categories = &configuration.search_categories;

	// Vanilla variables -- helpers
	string * category, table;
	int * property_id;
	
	input = helper.string_to_lower(input);
	select_list.push_back("property_id");//we only want to grab the id for each property
	where[0].column_value = input;
	
	
	for (int i = 0; i< (* categories).size(); i++) {//get a list of the tables to query

		category = &(* categories)[i];//this is the current category

		where[0].column_name = * category;
		
		table = category_table(* category);//table to be queried
		
		database.query_like(table, select_list, where, query_results);//actually grab the ids--the results will constantly be added to!
		
	}

	for (int i = 0; i < query_results.size(); i++) {
		
		property_id = & query_results[i].row_column[0].integer_value;

		if(* property_id > 0)
			raw_list.push_back(* property_id);//push the integer into the vector of raw integers!
	} 

	duplicates(raw_list, key_value_results);
	
	sort(key_value_results, results);
	
	key_value_results.clear();
}
Exemple #5
0
Variant ArrayUtil::RegularSortUnique(const Array& input) {
  /* The output of this function in PHP strictly depends on the implementation
   * of the sort function and on whether values that compare as equal end
   * up in contiguous positions in the sorted array (which is not really
   * well-defined in case of mixed strings/numbers). To get the same result
   * as in PHP we thus need to replicate the PHP algorithm more closely than
   * in the other versions of array_unique.
   */
  if (input.size() <= 1) return input;

  Array::SortData opaque;
  std::vector<int> indices;
  Array::SortImpl(indices, input, opaque, Array::SortRegularAscending, false);

  int duplicates_count = 0;
  std::vector<bool> duplicates(indices.size(), false);
  int lastIdx = indices[0];
  Variant last = input->getValue(opaque.positions[lastIdx]);
  for (unsigned int i = 1; i < indices.size(); ++i) {
    int currentIdx = indices[i];
    Variant current = input->getValue(opaque.positions[currentIdx]);
    if (equal(current, last)) {
      ++duplicates_count;
      if (currentIdx > lastIdx) {
        duplicates[currentIdx] = true;
        continue;
      }
      duplicates[lastIdx] = true;
    }
    lastIdx = currentIdx;
    last = current;
  }

  ArrayInit ret(indices.size() - duplicates_count, ArrayInit::Map{});
  int i = 0;
  for (ArrayIter iter(input); iter; ++iter, ++i) {
    if (!duplicates[i]) {
      ret.setValidKey(*iter.first().asTypedValue(), iter.secondVal());
    }
  }
  return ret.toVariant();
}
int QLCFixtureDefCache_Test::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: init(); break;
        case 1: cleanup(); break;
        case 2: duplicates(); break;
        case 3: add(); break;
        case 4: fixtureDef(); break;
        case 5: load(); break;
        case 6: defDirectories(); break;
        default: ;
        }
        _id -= 7;
    }
    return _id;
}
void CheckDuplicatesUsingOMP(const std::vector<CadPt2ID> &points, int gridSize)
{
	auto emptyPair = std::make_pair(0, 0);
	std::vector<std::pair<int, int>> duplicates(points.size(), emptyPair);

#pragma omp parallel for
	for (int i = 0; i < (int)points.size(); ++i)
	{
		auto outerPt = points.at(i);

		for (int j = 0; j < (int)points.size(); ++j)
		{
			auto innerPt = points.at(j);

			if (innerPt.id != outerPt.id && innerPt.pt == outerPt.pt) // coordinates are the same, but id's are different
			{
				duplicates.at(i) = std::make_pair(innerPt.id, outerPt.id);
			}
		}
	}

	// Remove default zeroed entries
	duplicates.erase(std::remove(duplicates.begin(), duplicates.end(), emptyPair), duplicates.end());

	// Ensure first member of pair is less than second
	std::transform(duplicates.begin(), duplicates.end(), duplicates.begin(), &OrderPair);

	// Sort vector to get pairs ordered adjacent to each other
	std::sort(duplicates.begin(), duplicates.end(), &ComparePairs);

	// The vector now contains a,b entries as well as b,a. Ensure uniqueness.
	duplicates.erase(std::unique(duplicates.begin(), duplicates.end()), duplicates.end());

	if (settings.Verify)
		Verify(duplicates, gridSize);
}
Exemple #8
0
int main(int argc, char* argv[]) {
	uint64_t limit(100000);
	
	if (argc == 2) {
		limit = static_cast<uint64_t>(atol(argv[1]));
	} else if (argc > 2) {
		std::cout << "Usage: " << argv[0] << " [number of hashes]" << std::endl;
	}
	
	std::vector<Simhash::hash_t> masks;
	
	/* This is a vector of bitmasks describing a valid permutation. This 
	 * particular permutation has 6 blocks, where each of the blocks is kept in
	 * the order that you'd expect. Changing the order of these items has the
	 * effect of reordering the blocks. */
	masks.push_back(0xFFE0000000000000);
    masks.push_back(0x1FFC0000000000  );
	masks.push_back(0x3FF80000000     );
	masks.push_back(0x7FF00000        );
	masks.push_back(0xFFE00           );
	masks.push_back(0x1FF             );
	
	/* Create a table where we're interested in matches with 3 or fewer bytes
	 * differing between two near-duplicate documents. */
	Simhash::Table duplicates(3, masks);
	
	/* We're going to insert a bunch of hashes, and then run a bunch of queries
	 * on some hashes that should be considered near duplicates and some that
	 * should not */
	std::cout << "Inserting " << limit << " hashes..." << std::endl;
	for (uint64_t i = 1; i < limit; ++i) {
		duplicates.insert(i << 28);
	}
	
	std::cout << "Running " << limit * 4 << " queries..." << std::endl;
	Simhash::hash_t query(0), first(0), errors(0);
	for (uint64_t i = 1; i < limit; ++i) {
		query   = (i << 28) | 3;
		first   = duplicates.find(query);
		errors += first ? 0 : 1;
		
		query   = (i << 28) | 9;
		first   = duplicates.find(query);
		errors += first ? 0 : 1;
		
		query   = (i << 28) | 65;
		first   = duplicates.find(query);
		errors += first ? 0 : 1;
		
		query   = (i << 28) | 15;
		first   = duplicates.find(query);
		if (first) {
			std::cout << "Found " << first << " when looking for " << query << "(" << Simhash::num_differing_bits(first, query) << ")" << std::endl;
		}
		errors += !first ? 0 : 1;
	}
	
	std::cout << "Queries complete with " << errors << " errors" << std::endl;
	
	size_t count(0);
	Simhash::Table::const_iterator it( duplicates.begin());
	Simhash::Table::const_iterator end(duplicates.end());
	for(; it != end; ++it, ++count) {}
	
	std::cout << "There are " << count << " items in the table" << std::endl;
	
	return 0;

}