Commit cdb4d8f5 authored by BRAMAS Berenger's avatar BRAMAS Berenger
Browse files

Use typedef for iterator

parent 856f23f0
......@@ -56,11 +56,11 @@ public:
protected:
void bottomPass(){
FLOG( FTic timer; );
typename std::vector<ParticleGroupClass*>::iterator iterParticles = tree->leavesBegin();
const typename std::vector<ParticleGroupClass*>::iterator endParticles = tree->leavesEnd();
typename OctreeClass::ParticleGroupIterator iterParticles = tree->leavesBegin();
const typename OctreeClass::ParticleGroupIterator endParticles = tree->leavesEnd();
typename std::vector<CellContainerClass*>::iterator iterCells = tree->cellsBegin(tree->getHeight()-1);
const typename std::vector<CellContainerClass*>::iterator endCells = tree->cellsEnd(tree->getHeight()-1);
typename OctreeClass::CellGroupIterator iterCells = tree->cellsBegin(tree->getHeight()-1);
const typename OctreeClass::CellGroupIterator endCells = tree->cellsEnd(tree->getHeight()-1);
while(iterParticles != endParticles && iterCells != endCells){
{ // Can be a task(in:iterParticles, out:iterCells)
......@@ -89,11 +89,11 @@ protected:
void upwardPass(){
FLOG( FTic timer; );
for(int idxLevel = tree->getHeight()-2 ; idxLevel >= 2 ; --idxLevel){
typename std::vector<CellContainerClass*>::iterator iterCells = tree->cellsBegin(idxLevel);
const typename std::vector<CellContainerClass*>::iterator endCells = tree->cellsEnd(idxLevel);
typename OctreeClass::CellGroupIterator iterCells = tree->cellsBegin(idxLevel);
const typename OctreeClass::CellGroupIterator endCells = tree->cellsEnd(idxLevel);
typename std::vector<CellContainerClass*>::iterator iterChildCells = tree->cellsBegin(idxLevel+1);
const typename std::vector<CellContainerClass*>::iterator endChildCells = tree->cellsEnd(idxLevel+1);
typename OctreeClass::CellGroupIterator iterChildCells = tree->cellsBegin(idxLevel+1);
const typename OctreeClass::CellGroupIterator endChildCells = tree->cellsEnd(idxLevel+1);
while(iterCells != endCells && iterChildCells != endChildCells){
{ // Can be a task(in:iterParticles, out:iterChildCells ...)
......@@ -135,8 +135,8 @@ protected:
void transferPass(){
FLOG( FTic timer; );
for(int idxLevel = tree->getHeight()-1 ; idxLevel >= 2 ; --idxLevel){
typename std::vector<CellContainerClass*>::iterator iterCells = tree->cellsBegin(idxLevel);
const typename std::vector<CellContainerClass*>::iterator endCells = tree->cellsEnd(idxLevel);
typename OctreeClass::CellGroupIterator iterCells = tree->cellsBegin(idxLevel);
const typename OctreeClass::CellGroupIterator endCells = tree->cellsEnd(idxLevel);
while(iterCells != endCells){
std::vector<OutOfBlockInteraction> outsideInteractions;
......@@ -186,7 +186,7 @@ protected:
// Manage outofblock interaction
FQuickSort<OutOfBlockInteraction, int>::QsSequential(outsideInteractions.data(),int(outsideInteractions.size()));
typename std::vector<CellContainerClass*>::iterator iterLeftCells = tree->cellsBegin(idxLevel);
typename OctreeClass::CellGroupIterator iterLeftCells = tree->cellsBegin(idxLevel);
int currentOutInteraction = 0;
while(iterLeftCells != iterCells && currentOutInteraction < int(outsideInteractions.size())){
const MortonIndex blockStartIdx = (*iterLeftCells)->getStartingIndex();
......@@ -237,11 +237,11 @@ protected:
void downardPass(){
FLOG( FTic timer; );
for(int idxLevel = 2 ; idxLevel <= tree->getHeight()-2 ; ++idxLevel){
typename std::vector<CellContainerClass*>::iterator iterCells = tree->cellsBegin(idxLevel);
const typename std::vector<CellContainerClass*>::iterator endCells = tree->cellsEnd(idxLevel);
typename OctreeClass::CellGroupIterator iterCells = tree->cellsBegin(idxLevel);
const typename OctreeClass::CellGroupIterator endCells = tree->cellsEnd(idxLevel);
typename std::vector<CellContainerClass*>::iterator iterChildCells = tree->cellsBegin(idxLevel+1);
const typename std::vector<CellContainerClass*>::iterator endChildCells = tree->cellsEnd(idxLevel+1);
typename OctreeClass::CellGroupIterator iterChildCells = tree->cellsBegin(idxLevel+1);
const typename OctreeClass::CellGroupIterator endChildCells = tree->cellsEnd(idxLevel+1);
while(iterCells != endCells && iterChildCells != endChildCells){
{ // Can be a task(in:iterParticles, inout:iterChildCells ...)
......@@ -281,11 +281,11 @@ protected:
void directPass(){
FLOG( FTic timer; );
{
typename std::vector<ParticleGroupClass*>::iterator iterParticles = tree->leavesBegin();
const typename std::vector<ParticleGroupClass*>::iterator endParticles = tree->leavesEnd();
typename OctreeClass::ParticleGroupIterator iterParticles = tree->leavesBegin();
const typename OctreeClass::ParticleGroupIterator endParticles = tree->leavesEnd();
typename std::vector<CellContainerClass*>::iterator iterCells = tree->cellsBegin(tree->getHeight()-1);
const typename std::vector<CellContainerClass*>::iterator endCells = tree->cellsEnd(tree->getHeight()-1);
typename OctreeClass::CellGroupIterator iterCells = tree->cellsBegin(tree->getHeight()-1);
const typename OctreeClass::CellGroupIterator endCells = tree->cellsEnd(tree->getHeight()-1);
while(iterParticles != endParticles && iterCells != endCells){
{ // Can be a task(in:iterCells, inout:iterParticles)
......@@ -309,8 +309,8 @@ protected:
FAssertLF(iterParticles == endParticles && iterCells == endCells);
}
{
typename std::vector<ParticleGroupClass*>::iterator iterParticles = tree->leavesBegin();
const typename std::vector<ParticleGroupClass*>::iterator endParticles = tree->leavesEnd();
typename OctreeClass::ParticleGroupIterator iterParticles = tree->leavesBegin();
const typename OctreeClass::ParticleGroupIterator endParticles = tree->leavesEnd();
while(iterParticles != endParticles){
typename std::vector<OutOfBlockInteraction> outsideInteractions;
......@@ -359,7 +359,7 @@ protected:
// Manage outofblock interaction
FQuickSort<OutOfBlockInteraction, int>::QsSequential(outsideInteractions.data(),int(outsideInteractions.size()));
typename std::vector<ParticleGroupClass*>::iterator iterLeftParticles = tree->leavesBegin();
typename OctreeClass::ParticleGroupIterator iterLeftParticles = tree->leavesBegin();
int currentOutInteraction = 0;
while(iterLeftParticles != iterParticles && currentOutInteraction < int(outsideInteractions.size())){
const MortonIndex blockStartIdx = (*iterLeftParticles)->getStartingIndex();
......
......@@ -115,8 +115,8 @@ protected:
typename std::vector< std::vector<OutOfBlockInteraction> > allOutsideInteractions;
{
typename std::vector<ParticleGroupClass*>::iterator iterParticles = tree->leavesBegin();
const typename std::vector<ParticleGroupClass*>::iterator endParticles = tree->leavesEnd();
typename OctreeClass::ParticleGroupIterator iterParticles = tree->leavesBegin();
const typename OctreeClass::ParticleGroupIterator endParticles = tree->leavesEnd();
// We iterate on blocks
while(iterParticles != endParticles){
......@@ -159,7 +159,7 @@ protected:
// Sort to match external order
FQuickSort<OutOfBlockInteraction, int>::QsSequential((*outsideInteractions).data(),int((*outsideInteractions).size()));
typename std::vector<ParticleGroupClass*>::iterator iterLeftParticles = tree->leavesBegin();
typename OctreeClass::ParticleGroupIterator iterLeftParticles = tree->leavesBegin();
int currentOutInteraction = 0;
while((*iterLeftParticles) != containers && currentOutInteraction < int((*outsideInteractions).size())){
ParticleGroupClass* leftContainers = (*iterLeftParticles);
......@@ -201,14 +201,14 @@ protected:
for(int idxLevel = tree->getHeight()-1 ; idxLevel >= 2 ; --idxLevel){
std::vector<std::vector<OutOfBlockInteraction> > allOutsideInteractions;
typename std::vector<CellContainerClass*>::iterator iterCells = tree->cellsBegin(idxLevel);
const typename std::vector<CellContainerClass*>::iterator endCells = tree->cellsEnd(idxLevel);
typename OctreeClass::CellGroupConstIterator iterCells = tree->cellsBegin(idxLevel);
const typename OctreeClass::CellGroupConstIterator endCells = tree->cellsEnd(idxLevel);
while(iterCells != endCells){
allOutsideInteractions.push_back(std::vector<OutOfBlockInteraction>());
std::vector<OutOfBlockInteraction>* outsideInteractions = &allOutsideInteractions.back();
CellContainerClass* currentCells = (*iterCells);
const CellContainerClass* currentCells = (*iterCells);
externalInteractionsAllLevel[idxLevel].emplace_back();
std::vector<BlockInteractions<CellContainerClass>>* externalInteractions = &externalInteractionsAllLevel[idxLevel].back();
......@@ -219,7 +219,7 @@ protected:
const MortonIndex blockEndIdx = currentCells->getEndingIndex();
for(MortonIndex mindex = blockStartIdx ; mindex < blockEndIdx ; ++mindex){
CellClass* cell = currentCells->getCell(mindex);
const CellClass* cell = currentCells->getCell(mindex);
if(cell){
FAssertLF(cell->getMortonIndex() == mindex);
MortonIndex interactionsIndexes[189];
......@@ -245,7 +245,7 @@ protected:
// Manage outofblock interaction
FQuickSort<OutOfBlockInteraction, int>::QsSequential((*outsideInteractions).data(),int((*outsideInteractions).size()));
typename std::vector<CellContainerClass*>::iterator iterLeftCells = tree->cellsBegin(idxLevel);
typename OctreeClass::CellGroupIterator iterLeftCells = tree->cellsBegin(idxLevel);
int currentOutInteraction = 0;
while((*iterLeftCells) != currentCells && currentOutInteraction < int((*outsideInteractions).size())){
const MortonIndex blockStartIdx = (*iterLeftCells)->getStartingIndex();
......@@ -291,11 +291,11 @@ protected:
void bottomPass(){
FLOG( FTic timer; );
typename std::vector<ParticleGroupClass*>::iterator iterParticles = tree->leavesBegin();
const typename std::vector<ParticleGroupClass*>::iterator endParticles = tree->leavesEnd();
typename OctreeClass::ParticleGroupIterator iterParticles = tree->leavesBegin();
const typename OctreeClass::ParticleGroupIterator endParticles = tree->leavesEnd();
typename std::vector<CellContainerClass*>::iterator iterCells = tree->cellsBegin(tree->getHeight()-1);
const typename std::vector<CellContainerClass*>::iterator endCells = tree->cellsEnd(tree->getHeight()-1);
typename OctreeClass::CellGroupIterator iterCells = tree->cellsBegin(tree->getHeight()-1);
const typename OctreeClass::CellGroupIterator endCells = tree->cellsEnd(tree->getHeight()-1);
while(iterParticles != endParticles && iterCells != endCells){
CellContainerClass* leafCells = (*iterCells);
......@@ -330,11 +330,11 @@ protected:
void upwardPass(){
FLOG( FTic timer; );
for(int idxLevel = tree->getHeight()-2 ; idxLevel >= 2 ; --idxLevel){
typename std::vector<CellContainerClass*>::iterator iterCells = tree->cellsBegin(idxLevel);
const typename std::vector<CellContainerClass*>::iterator endCells = tree->cellsEnd(idxLevel);
typename OctreeClass::CellGroupIterator iterCells = tree->cellsBegin(idxLevel);
const typename OctreeClass::CellGroupIterator endCells = tree->cellsEnd(idxLevel);
typename std::vector<CellContainerClass*>::iterator iterChildCells = tree->cellsBegin(idxLevel+1);
const typename std::vector<CellContainerClass*>::iterator endChildCells = tree->cellsEnd(idxLevel+1);
typename OctreeClass::CellGroupIterator iterChildCells = tree->cellsBegin(idxLevel+1);
const typename OctreeClass::CellGroupIterator endChildCells = tree->cellsEnd(idxLevel+1);
while(iterCells != endCells && iterChildCells != endChildCells){
CellContainerClass* currentCells = (*iterCells);
......@@ -407,8 +407,8 @@ protected:
for(int idxLevel = tree->getHeight()-1 ; idxLevel >= 2 ; --idxLevel){
FLOG( timerInBlock.tic() );
{
typename std::vector<CellContainerClass*>::iterator iterCells = tree->cellsBegin(idxLevel);
const typename std::vector<CellContainerClass*>::iterator endCells = tree->cellsEnd(idxLevel);
typename OctreeClass::CellGroupIterator iterCells = tree->cellsBegin(idxLevel);
const typename OctreeClass::CellGroupIterator endCells = tree->cellsEnd(idxLevel);
while(iterCells != endCells){
CellContainerClass* currentCells = (*iterCells);
......@@ -455,8 +455,8 @@ protected:
FLOG( timerInBlock.tac() );
FLOG( timerOutBlock.tic() );
{
typename std::vector<CellContainerClass*>::iterator iterCells = tree->cellsBegin(idxLevel);
const typename std::vector<CellContainerClass*>::iterator endCells = tree->cellsEnd(idxLevel);
typename OctreeClass::CellGroupIterator iterCells = tree->cellsBegin(idxLevel);
const typename OctreeClass::CellGroupIterator endCells = tree->cellsEnd(idxLevel);
typename std::vector<std::vector<BlockInteractions<CellContainerClass>>>::iterator externalInteractionsIter = externalInteractionsAllLevel[idxLevel].begin();
......@@ -514,11 +514,11 @@ protected:
void downardPass(){
FLOG( FTic timer; );
for(int idxLevel = 2 ; idxLevel <= tree->getHeight()-2 ; ++idxLevel){
typename std::vector<CellContainerClass*>::iterator iterCells = tree->cellsBegin(idxLevel);
const typename std::vector<CellContainerClass*>::iterator endCells = tree->cellsEnd(idxLevel);
typename OctreeClass::CellGroupIterator iterCells = tree->cellsBegin(idxLevel);
const typename OctreeClass::CellGroupIterator endCells = tree->cellsEnd(idxLevel);
typename std::vector<CellContainerClass*>::iterator iterChildCells = tree->cellsBegin(idxLevel+1);
const typename std::vector<CellContainerClass*>::iterator endChildCells = tree->cellsEnd(idxLevel+1);
typename OctreeClass::CellGroupIterator iterChildCells = tree->cellsBegin(idxLevel+1);
const typename OctreeClass::CellGroupIterator endChildCells = tree->cellsEnd(idxLevel+1);
while(iterCells != endCells && iterChildCells != endChildCells){
CellContainerClass* currentCells = (*iterCells);
......@@ -589,8 +589,8 @@ protected:
FLOG( timerInBlock.tic() );
{
typename std::vector<ParticleGroupClass*>::iterator iterParticles = tree->leavesBegin();
const typename std::vector<ParticleGroupClass*>::iterator endParticles = tree->leavesEnd();
typename OctreeClass::ParticleGroupIterator iterParticles = tree->leavesBegin();
const typename OctreeClass::ParticleGroupIterator endParticles = tree->leavesEnd();
while(iterParticles != endParticles){
ParticleGroupClass* containers = (*iterParticles);
......@@ -636,8 +636,8 @@ protected:
FLOG( timerInBlock.tac() );
FLOG( timerOutBlock.tic() );
{
typename std::vector<ParticleGroupClass*>::iterator iterParticles = tree->leavesBegin();
const typename std::vector<ParticleGroupClass*>::iterator endParticles = tree->leavesEnd();
typename OctreeClass::ParticleGroupIterator iterParticles = tree->leavesBegin();
const typename OctreeClass::ParticleGroupIterator endParticles = tree->leavesEnd();
typename std::vector<std::vector<BlockInteractions<ParticleGroupClass>>>::iterator externalInteractionsIter = externalInteractionsLeafLevel.begin();
......@@ -691,11 +691,11 @@ protected:
void mergePass(){
FLOG( FTic timer; );
{
typename std::vector<ParticleGroupClass*>::iterator iterParticles = tree->leavesBegin();
const typename std::vector<ParticleGroupClass*>::iterator endParticles = tree->leavesEnd();
typename OctreeClass::ParticleGroupIterator iterParticles = tree->leavesBegin();
const typename OctreeClass::ParticleGroupIterator endParticles = tree->leavesEnd();
typename std::vector<CellContainerClass*>::iterator iterCells = tree->cellsBegin(tree->getHeight()-1);
const typename std::vector<CellContainerClass*>::iterator endCells = tree->cellsEnd(tree->getHeight()-1);
typename OctreeClass::CellGroupIterator iterCells = tree->cellsBegin(tree->getHeight()-1);
const typename OctreeClass::CellGroupIterator endCells = tree->cellsEnd(tree->getHeight()-1);
while(iterParticles != endParticles && iterCells != endCells){
CellContainerClass* leafCells = (*iterCells);
......
......@@ -65,6 +65,11 @@ protected:
}
public:
typedef typename std::vector<CellGroupClass*>::iterator CellGroupIterator;
typedef typename std::vector<CellGroupClass*>::const_iterator CellGroupConstIterator;
typedef typename std::vector<ParticleGroupClass*>::iterator ParticleGroupIterator;
typedef typename std::vector<ParticleGroupClass*>::const_iterator ParticleGroupConstIterator;
/** This constructor create a blocked octree from a usual octree
* The cell are allocated as in the usual octree (no copy constructor are called!)
* Once allocated each cell receive its morton index and tree coordinate.
......@@ -297,8 +302,8 @@ public:
// For each level from heigth - 2 to 1
for(int idxLevel = treeHeight-2; idxLevel > 0 ; --idxLevel){
typename std::vector<CellGroupClass*>::const_iterator iterChildCells = cellBlocksPerLevel[idxLevel+1].begin();
const typename std::vector<CellGroupClass*>::const_iterator iterChildEndCells = cellBlocksPerLevel[idxLevel+1].end();
CellGroupConstIterator iterChildCells = cellBlocksPerLevel[idxLevel+1].begin();
const CellGroupConstIterator iterChildEndCells = cellBlocksPerLevel[idxLevel+1].end();
MortonIndex currentCellIndex = (*iterChildCells)->getStartingIndex();
int sizeOfBlock = 0;
......@@ -417,11 +422,11 @@ public:
*/
template<class ParticlesAttachedClass>
void forEachCellLeaf(std::function<void(CellClass*,ParticlesAttachedClass*)> function){
typename std::vector<CellGroupClass*>::iterator iterCells = cellBlocksPerLevel[treeHeight-1].begin();
const typename std::vector<CellGroupClass*>::iterator iterEndCells = cellBlocksPerLevel[treeHeight-1].end();
CellGroupIterator iterCells = cellBlocksPerLevel[treeHeight-1].begin();
const CellGroupIterator iterEndCells = cellBlocksPerLevel[treeHeight-1].end();
typename std::vector<ParticleGroupClass*>::iterator iterLeaves = particleBlocks.begin();
const typename std::vector<ParticleGroupClass*>::iterator iterEndLeaves = particleBlocks.end();
ParticleGroupIterator iterLeaves = particleBlocks.begin();
const ParticleGroupIterator iterEndLeaves = particleBlocks.end();
while(iterCells != iterEndCells && iterLeaves != iterEndLeaves){
(*iterCells)->forEachCell([&](CellClass* aCell){
......@@ -482,40 +487,40 @@ public:
return treeHeight;
}
typename std::vector<CellGroupClass*>::iterator cellsBegin(const int atHeight){
CellGroupIterator cellsBegin(const int atHeight){
FAssertLF(atHeight < treeHeight);
return cellBlocksPerLevel[atHeight].begin();
}
typename std::vector<CellGroupClass*>::const_iterator cellsBegin(const int atHeight) const {
CellGroupConstIterator cellsBegin(const int atHeight) const {
FAssertLF(atHeight < treeHeight);
return cellBlocksPerLevel[atHeight].begin();
}
typename std::vector<CellGroupClass*>::iterator cellsEnd(const int atHeight){
CellGroupIterator cellsEnd(const int atHeight){
FAssertLF(atHeight < treeHeight);
return cellBlocksPerLevel[atHeight].end();
}
typename std::vector<CellGroupClass*>::const_iterator cellsEnd(const int atHeight) const {
CellGroupConstIterator cellsEnd(const int atHeight) const {
FAssertLF(atHeight < treeHeight);
return cellBlocksPerLevel[atHeight].end();
}
typename std::vector<ParticleGroupClass*>::iterator leavesBegin(){
ParticleGroupIterator leavesBegin(){
return particleBlocks.begin();
}
typename std::vector<ParticleGroupClass*>::const_iterator leavesBegin() const {
ParticleGroupConstIterator leavesBegin() const {
return particleBlocks.begin();
}
typename std::vector<ParticleGroupClass*>::iterator leavesEnd(){
ParticleGroupIterator leavesEnd(){
return particleBlocks.end();
}
typename std::vector<ParticleGroupClass*>::const_iterator leavesEnd() const {
ParticleGroupConstIterator leavesEnd() const {
return particleBlocks.end();
}
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment