Exemplo n.º 1
0
void GroupByScan::executeGroupBy() {
  auto resultTab = createResultTableLayout();
  auto groupResults = getInputHashTable();
  // Allocate some memory for the result tab and resize the table
  resultTab->resize(groupResults->numKeys());

  pos_t row = 0;
  typename HashTableType::map_const_iterator_t it1, it2, end;
  // set iterators: in the sequential case, getInputTable() returns an AggregateHashTable, in the parallel case a HashTableView<>
  // Alternatively, a common type could be introduced
  if (_count < 1) {
    auto aggregateHashTable = std::dynamic_pointer_cast<const HashTableType>(groupResults);
    it1 = aggregateHashTable->getMapBegin();
    end = aggregateHashTable->getMapEnd();
  } else {
    auto hashTableView = std::dynamic_pointer_cast<const HashTableView<MapType, KeyType> >(groupResults);
    it1 = hashTableView->getMapBegin();
    end = hashTableView->getMapEnd();
  }
  for (it2 = it1; it1 != end; it1 = it2) {
    // outer loop over unique keys
    auto pos_list = std::make_shared<pos_list_t>();
    for (; (it2 != end) && (it1->first == it2->first); ++it2) {
      // inner loop, all keys equal to it1->first
      pos_list->push_back(it2->second);
    }
    writeGroupResult(resultTab, pos_list, row);
    row++;
  }
  this->addResult(resultTab);
}
Exemplo n.º 2
0
TYPED_TEST(HashTableViewTest, no_range) {
  field_list_t columns {0, 1, 2};

  auto hashTab = std::make_shared<TypeParam>(this->table, columns);
  auto view = hashTab->view(0, 0);

  EXPECT_TRUE(view->size() == 0);
  EXPECT_TRUE(view->getMapBegin() == view->getMapEnd());
  EXPECT_TRUE(view->getMapEnd() == hashTab->getMapBegin());

  auto itMap = hashTab->getMapBegin();

  for (; itMap != hashTab->getMapEnd(); ++itMap) {
    auto key = itMap->first;
    EXPECT_TRUE(view->get(key).empty());
  }
}
Exemplo n.º 3
0
void Globals::dump(TiXmlElement *root)
{
    root->SetAttribute("ActualRandomSeed",getRandom().getSeed());
    root->SetAttribute("NodeCounter",nodeCounter);
    root->SetAttribute("LinkCounter",linkCounter);
    root->SetAttribute("SpeciesCounter",speciesCounter);
    StackMap<string,double,4096>::iterator mapIterator = getMapBegin();
    StackMap<string,double,4096>::iterator mapEnd = getMapEnd();
    for (; mapIterator!=mapEnd; mapIterator++)
    {
        root->SetDoubleAttribute(
            mapIterator->first.c_str(),
            mapIterator->second
        );
    }
}
Exemplo n.º 4
0
void sdlTerrainAff(const sdlMap *sdMap)
{
	int x,y,i;
	Map *map = getSdlMap(sdMap);
	Coord dim = getMapDim(map);
	//affichage terrain
	if (getSdlMapMode(sdMap))
	{
		sdlApplySurface(sdMap->Terrain->sprites[1], getSdlMapEcran(sdMap), -1, -1);
		
	} else {
		sdlApplySurface(sdMap->Terrain->sprites[0], getSdlMapEcran(sdMap), -1, -1);
	}

	//Affichage chemin
	for(y=0;y<dim.y;++y)
	{
		for(x=0;x<dim.x;++x)
		{
			if (getCellPath(map->grid[y][x]))
			{
				sdlApplySurface(sdMap->Path->sprites[0], getSdlMapEcran(sdMap), x, y);
			}
		}
	}

	Coord end = getMapEnd(map);
	Coord start = getMapStart(map);
	//Affichage chateau
	//affichage arrive des monstres
	if(map->numero == 4){
		sdlApplySurface(sdMap->Grotte->sprites[0], getSdlMapEcran(sdMap), (start.y-1), (start.x-1));
		sdlApplySurface(sdMap->Ville->sprites[0], getSdlMapEcran(sdMap), end.y, (end.x-6.7));
	} else if(map->numero == 3){
		sdlApplySurface(sdMap->Grotte->sprites[1], getSdlMapEcran(sdMap), (start.y-1), (start.x-1));
		sdlApplySurface(sdMap->Ville->sprites[1], getSdlMapEcran(sdMap), (end.y-8), end.x);
	} else if(map->numero == 2){
		sdlApplySurface(sdMap->Grotte->sprites[0], getSdlMapEcran(sdMap), (start.y-1), (start.x-1));
		sdlApplySurface(sdMap->Ville->sprites[1], getSdlMapEcran(sdMap), (end.y-8), end.x);
	} else if(map->numero == 1){
		sdlApplySurface(sdMap->Grotte->sprites[1], getSdlMapEcran(sdMap), (start.y-1), (start.x-1));
		sdlApplySurface(sdMap->Ville->sprites[0], getSdlMapEcran(sdMap), end.y, (end.x-6.7));
	}
	
}