void FEL_spandecomposition::decomposeRange_1D( unsigned int x, std::list<Span1D>* spanList ) { int input = x; unsigned int xLow = 0, residue = 0; do { xLow = getNextRange_1D( x ); residue = x - xLow; Span1D nextRange( residue+1, x ); spanList->push_back( nextRange ); x = residue; }while( residue > 1 ); #ifdef DEBUG_MODE fprintf( stderr, "Decomposition for %d:\n", input ); for( std::list<Span1D>::iterator iter = spanList->begin(); iter != spanList->end(); iter++ ) fprintf( stderr, "[%u %u]\n", iter->low, iter->high ); #endif }
bool Backup::RangeEnum::next() { nextRange(); for (std::list<Range>::const_iterator e = mRanges.list().end(); mI != e; ++mI) { size_t offset = mOffset; mOffset += mI->size; try { mMap = mData.mFile.mapAligned(offset, mI->size); mDiff = ptrDiff(mMap->address(), mI->begin); return true; } catch (const BackupReadError &) { } } mMap.reset(); return false; }
void FEL_spandecomposition::decomposeRange_3D( unsigned int x, unsigned int y, unsigned int z, std::list<Span3D>* xyzSpanList ) { std::list<Span1D> xPartitionList; std::list<Span1D> yPartitionList; std::list<Span1D> zPartitionList; decomposeRange_1D( x, &xPartitionList ); decomposeRange_1D( y, &yPartitionList ); decomposeRange_1D( z, &zPartitionList ); int nXPart = xPartitionList.size(); int nYPart = yPartitionList.size(); int nZPart = zPartitionList.size(); #ifdef DEBUG_MODE fprintf( stderr, "1D lists contains [%d, %d, %d] spans\n", nXPart, nYPart, nZPart ); #endif std::list<Span1D>::iterator iterx = xPartitionList.begin(); for( int x=0; x<nXPart; x++ ) { std::list<Span1D>::iterator itery = yPartitionList.begin(); for( int y=0; y<nYPart; y++ ) { std::list<Span1D>::iterator iterz = zPartitionList.begin(); for( int z=0; z<nZPart; z++ ) { Span3D nextRange( iterx->low, iterx->high, itery->low, itery->high, iterz->low, iterz->high ); xyzSpanList->push_back( nextRange ); iterz++; } itery++; } iterx++; } xPartitionList.clear(); yPartitionList.clear(); zPartitionList.clear(); }
void FEL_spandecomposition::decomposeRange_2D( unsigned int x, unsigned int y, std::map<Span2D, int>* xySpanMap ) { std::list<Span1D> xPartitionList; std::list<Span1D> yPartitionList; decomposeRange_1D( x, &xPartitionList ); decomposeRange_1D( y, &yPartitionList ); int nXPart = xPartitionList.size(); int nYPart = yPartitionList.size(); std::list<Span1D>::iterator iterx = xPartitionList.begin(); for( int x=0; x<nXPart; x++ ) { std::list<Span1D>::iterator itery = yPartitionList.begin(); for( int y=0; y<nYPart; y++ ) { Span2D nextRange( iterx->low, iterx->high, itery->low, itery->high ); xySpanMap->insert( std::pair<Span2D,int>( nextRange, 0 ) ); itery++; } iterx++; } #ifdef DEBUG_MODE for( std::map<Span2D, int>::iterator iter = xySpanMap->begin(); iter != xyMap->end(); iter++ ) fprintf( stderr, "[%u %u]-[%u %u]\n", iter->first.low[0], iter->first.high[0], iter->first.low[1], iter->first.high[1] ); #endif xPartitionList.clear(); yPartitionList.clear(); }
void FEL_spandecomposition::decomposeRange_3D( unsigned int x, unsigned int y, unsigned int z, //std::map<Span3D, int, Span3DComp>* xyzSpanMap ) std::map<Span3D, int>* xyzSpanMap ) { std::list<Span1D> xPartitionList; std::list<Span1D> yPartitionList; std::list<Span1D> zPartitionList; decomposeRange_1D( x, &xPartitionList ); decomposeRange_1D( y, &yPartitionList ); decomposeRange_1D( z, &zPartitionList ); int nXPart = xPartitionList.size(); int nYPart = yPartitionList.size(); int nZPart = zPartitionList.size(); #if DEBUG_MODE fprintf( stderr, "[%d, %d, %d]\n", x, y, z ); fprintf( stderr, "1D lists contains [%d, %d, %d] spans\n", nXPart, nYPart, nZPart ); #endif std::list<Span1D>::iterator iterx = xPartitionList.begin(); for( int x=0; x<nXPart; x++ ) { std::list<Span1D>::iterator itery = yPartitionList.begin(); for( int y=0; y<nYPart; y++ ) { std::list<Span1D>::iterator iterz = zPartitionList.begin(); for( int z=0; z<nZPart; z++ ) { Span3D nextRange( iterx->low, iterx->high, itery->low, itery->high, iterz->low, iterz->high ); std::pair<std::map<Span3D,int>::iterator,bool> ret = xyzSpanMap->insert( std::pair<Span3D,int>( nextRange, 0) ); #if DEBUG_MODE if( ret.second == false ) { nextRange.print(); fprintf( stderr, "Already exists\n" ); } else { nextRange.print(); fprintf( stderr, "inserted.\n" ); } #endif iterz++; } itery++; } iterx++; } #ifdef DEBUG_MODE for( std::map<Span3D, int>::iterator iter = xyzSpanMap->begin(); iter != xyzSpanMap->end(); iter++ ) fprintf( stderr, "[%u %u]-[%u %u]-[%u %u]\n", iter->first.low[0], iter->first.high[0], iter->first.low[1], iter->first.high[1], iter->first.low[2], iter->first.high[2] ); #endif xPartitionList.clear(); yPartitionList.clear(); zPartitionList.clear(); }
bool Live::RangeEnum::next() { nextRange(); return (mI != mData.mRanges.list().end()); }