// { ----- begin row iteration methods ----- NS_IMETHODIMP morkTableRowCursor::NextRow( // get row cells from table for cells already in row nsIMdbEnv* mev, // context nsIMdbRow** acqRow, // acquire next row in table mdb_pos* outRowPos) { mdb_err outErr = 0; nsIMdbRow* outRow = 0; morkEnv* ev = morkEnv::FromMdbEnv(mev); if ( ev ) { mdbOid oid; // place to put oid we intend to ignore morkRow* row = NextRow(ev, &oid, outRowPos); if ( row ) { morkStore* store = row->GetRowSpaceStore(ev); if ( store ) outRow = row->AcquireRowHandle(ev, store); } outErr = ev->AsErr(); } if ( acqRow ) *acqRow = outRow; return outErr; }
bool ResourceBuffer::ReadFlagsRow() { m_vecFlags.clear(); m_nUseColCount = 0; // 跳过前面行并读取标志行 if (!NextRow(m_nFlagsRow)) { printf("[ERROR]:NextRow read fail!\n"); return false; } // 设置标记列 for (uint32 i = 0; i < m_vecCol.size(); ++i) { switch (m_vecCol[i].c_str()[0]) { case '2': case '3': { m_vecFlags.push_back(true); ++m_nUseColCount; } break; default: { m_vecFlags.push_back(false); } break; } } return true; }
/*************************************************** DeleteCol This function deletes a column at the specified position. Even if the column does not exist the function will return success. However if there are no rows in the grid the function will fail. Params col - column number to delete Return UG_SUCCESS - success UG_ERROR - failure ****************************************************/ int CUGMem::DeleteCol(int col) { //goto the first row while(PrevRow()==UG_SUCCESS); //check to see if there is a first row if(m_rowInfo == NULL) return UG_ERROR; //move the 'col' column over UGMemCI *colinfo; do{ if(GotoCol(col) ==UG_SUCCESS) { // delete the columninfo if there are columns to the right if(m_colInfo->next != NULL){ //update the links colinfo = m_colInfo->prev; if(colinfo != NULL) colinfo->next = m_colInfo->next; colinfo = m_colInfo->next; if(colinfo != NULL) colinfo->prev = m_colInfo->prev; if(m_rowInfo->col == m_colInfo) m_rowInfo->col = colinfo; //delete the colinfo if(m_colInfo->cell != NULL) delete m_colInfo->cell; delete m_colInfo; } // else if there are no more column to the right, then keep the // colinfo, but delete the cellinfo within the colinfo // since this may be the initial link to the rowinfo list else{ delete m_colInfo->cell; m_colInfo->cell = NULL; } } }while(NextRow()==UG_SUCCESS); //adjust the column translations int numCols = m_ctrl->GetNumberCols(); if(numCols > 0) { for(int loop = 0 ; loop < numCols;loop++) { if(m_ctrl->m_GI->m_colInfo[loop].colTranslation >= col) m_ctrl->m_GI->m_colInfo[loop].colTranslation--; } } //update the current column pointer m_colInfo = m_rowInfo->col; m_currentCol = 0; return UG_SUCCESS; }
ResourceBuffer::ResourceBuffer(const std::string& strFileName, uint32 nFlagsRow, uint32 nDataStartRow) : m_nFlagsRow(nFlagsRow), m_nDataStartRow(nDataStartRow), m_nCurrRowIndex(0), m_bValid(false), m_nCol(0), m_nUseColCount(0) { if (Load(strFileName.c_str()) && ReadFlagsRow() && NextRow()) { m_bValid = true; } }
/*************************************************** InsertCol This function inserts a blank column at the specified location. The previous column in that location is pushed right one column. If the specified column does not already exist for a given row, then that row will be skipped and the insert will continue. Params col - column number where a blank column will be inserted Return UG_SUCCESS - success UG_ERROR - failure (no rows in grid) ****************************************************/ int CUGMem::InsertCol(int col) { //goto the first row while(PrevRow()==UG_SUCCESS); //check to see if there is a first row if(m_rowInfo == NULL) return UG_ERROR; //get the screen position column number int numCols = m_ctrl->GetNumberCols(); if(numCols > 0) { for(int loop = 0 ; loop < numCols;loop++) { if(m_ctrl->m_GI->m_colInfo[loop].colTranslation == col) { col = loop; break; } } } //move the 'col' column over UGMemCI *newcol; do { if(GotoCol(col) ==UG_SUCCESS) { newcol = new UGMemCI; newcol->cell = NULL; newcol->next = m_colInfo; newcol->prev = m_colInfo->prev; if(newcol->prev != NULL) newcol->prev->next = newcol; if(m_rowInfo->col == m_colInfo) m_rowInfo->col = newcol; m_colInfo->prev = newcol; m_currentCol ++; } }while(NextRow()==UG_SUCCESS); //adjust the column translations if(numCols > 0) { for(int loop = 0 ; loop < numCols;loop++) { if(m_ctrl->m_GI->m_colInfo[loop].colTranslation >= col) m_ctrl->m_GI->m_colInfo[loop].colTranslation++; } } return UG_SUCCESS; }
PostgreQueryResult::PostgreQueryResult(PGresult * res, uint32 FieldCount, uint32 RowCount) : QueryResult(FieldCount, RowCount, DATABASE_TYPE_PGSQL) { // set result for later deletion and use mResult = res; // starting at row 0 mRow = 0; // retreieve the data NextRow(); }
void ContiguousMS::Reset() { _row = _startRow - 1; _rowId = size_t(-1); _time = 0.0; if(_selection.HasInterval()) _timestep = _selection.IntervalStart()-1; else _timestep = -1; NextRow(); }
IMySQLRowSet* CMySQL::DuplicateRowSet() { CMySQLCopiedRowSet *pSet = new CMySQLCopiedRowSet; pSet->m_iCurRow = -1; pSet->m_ColumnNames.SetSize( m_Fields.Count() ); for ( int i=0; i < m_Fields.Count(); i++ ) pSet->m_ColumnNames[i] = CopyString( m_Fields[i].name ); while ( NextRow() ) { CCopiedRow *pRow = new CCopiedRow; pSet->m_Rows.AddToTail( pRow ); pRow->m_Columns.SetSize( m_Fields.Count() ); for ( int i=0; i < m_Fields.Count(); i++ ) { pRow->m_Columns[i] = CopyString( m_Row[i] ); } } return pSet; }
SQLHSTMT ODBC::ExecuteSql( const char* sqltext, const char* format, ... ) { int ior; // 0 - in, 1 - out, 2 - ret, возращаемое значение процедурой int inum = 1, // номер входного параметра onum = 1; // номер выходного параметра SQLSMALLINT typeSql, // тип параметра дл¤ базы данных typeCpp; // тип параметра дл¤ c++ SQLUINTEGER clnsz; // размер пол¤ дл¤ некоторых типов SQLSMALLINT digits; // чисел после зап¤той дл¤ некоторых типов SQLLEN sqlNTS = SQL_NTS; //строка завершаетс¤ 0 SQLLEN sqlNullData = SQL_NULL_DATA; //передаем Null int tsz; // размер типа в байтах va_list va; va_start( va, format ); SQLHSTMT qr = CreateQuery(sqltext); while( format && *format ) { while( *format == ' ' ) format++; switch( *format++ ) { case 'i': ior = 0; break; case 'o': ior = 1; break; case 'r': ior = 2; break; case '!': ior = -1; break; } typeCpp = 0; clnsz = 0; digits = 0; bool null = false; SQLPOINTER ptr = va_arg( va, SQLPOINTER ); SQLLEN* strLenOrNull = 0; if( ior >= 0 ) { // если надо дл¤ получаемых данных узнать их длину или узнать, равно ли это // значение NULL (длина = -1) if( *format == '0' ) format++, null = true; switch( *format++ ) { case 'b': typeSql = SQL_CHAR; typeCpp = SQL_C_UTINYINT; tsz = sizeof(char); break; case 'c': typeSql = SQL_CHAR; typeCpp = SQL_C_STINYINT; tsz = sizeof(char); break; case 'i': typeSql = SQL_INTEGER; typeCpp = SQL_C_SLONG; tsz = sizeof(int); break; case 'u': switch( *format++ ) { case ' ': case 0 : typeSql = SQL_INTEGER; typeCpp = SQL_C_ULONG; tsz = sizeof(int); break; case 'h': typeSql = SQL_SMALLINT; typeCpp = SQL_C_USHORT; tsz = sizeof(short); break; } break; case 'd': typeSql = SQL_DOUBLE; typeCpp = SQL_C_DOUBLE; tsz = sizeof(double); break; case 'f': typeSql = SQL_REAL; typeCpp = SQL_C_FLOAT; tsz = sizeof(float); break; case 's': typeSql = SQL_CHAR; typeCpp = SQL_C_CHAR; clnsz = tsz = gettsz(&format); strLenOrNull = &sqlNTS; break; case 'h': typeSql = SQL_SMALLINT; typeCpp = SQL_C_SSHORT; tsz = sizeof(short); break; case 't': typeSql = SQL_TYPE_TIMESTAMP; typeCpp = SQL_TYPE_TIMESTAMP; tsz = sizeof(TIMESTAMP_STRUCT); if( ((TIMESTAMP_STRUCT*)ptr)->year == 0 ) strLenOrNull = &sqlNullData; break; case 'r': typeSql = SQL_LONGVARBINARY; typeCpp = SQL_C_BINARY; clnsz = tsz = gettsz(&format); break; } } // если возращаемое значение равно NULL, то его длина равна -1, поэтому нужно // в таких случа¤х об¤зательно передавать указатель дл¤ сохранени¤ длины, иначе // при встрече NULL ODBC выдаст ошибку SQLLEN* len = null ? va_arg( va, SQLLEN* ) : &lenForNull; if( ior == 0 && null ) strLenOrNull = len; switch( ior ) { case -1: break; case 0: if( (int)pSQLBindParameter( qr, inum++, SQL_PARAM_INPUT, typeCpp, typeSql, clnsz, digits, ptr, 0, strLenOrNull ) == SQL_ERROR ) { DBG( "ODBC", "Error in param %d" ); } break; case 1: pSQLBindCol( qr, onum++, typeCpp, ptr, tsz, len ); break; case 2: pSQLBindParameter( qr, inum++, SQL_PARAM_OUTPUT, typeCpp, typeSql, clnsz, digits, ptr, 0, 0 ); break; } } va_end(va); if( (SQLRETURN)pSQLExecute(qr) != SQL_ERROR ) if( onum > 1 ) //есть выходные пол¤ { if( NextRow(qr) ) return qr; } else return qr; PrintQueryError(qr); CloseQuery(qr); return 0; }
void WorldSession::HandleOfferPetitionOpcode(WorldPacket& recvData) { sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_OFFER_PETITION"); ObjectGuid petitionGuid, playerGuid; uint32 type, junk; Player* player; ObjectGuid guid1; ObjectGuid guid2; recvData >> junk; // this is not petition type! guid1[3] = recvData.ReadBit(); guid1[2] = recvData.ReadBit(); guid1[5] = recvData.ReadBit(); guid2[4] = recvData.ReadBit(); guid1[7] = recvData.ReadBit(); guid1[6] = recvData.ReadBit(); guid2[3] = recvData.ReadBit(); guid2[7] = recvData.ReadBit(); guid2[0] = recvData.ReadBit(); guid1[4] = recvData.ReadBit(); guid2[1] = recvData.ReadBit(); guid2[6] = recvData.ReadBit(); guid2[2] = recvData.ReadBit(); guid1[1] = recvData.ReadBit(); guid2[5] = recvData.ReadBit(); guid1[0] = recvData.ReadBit(); recvData.FlushBits(); recvData.ReadByteSeq(guid2[2]); recvData.ReadByteSeq(guid2[3]); recvData.ReadByteSeq(guid2[1]); recvData.ReadByteSeq(guid2[5]); recvData.ReadByteSeq(guid2[4]); recvData.ReadByteSeq(guid1[7]); recvData.ReadByteSeq(guid2[0]); recvData.ReadByteSeq(guid1[2]); recvData.ReadByteSeq(guid1[0]); recvData.ReadByteSeq(guid1[6]); recvData.ReadByteSeq(guid2[7]); recvData.ReadByteSeq(guid1[1]); recvData.ReadByteSeq(guid1[4]); recvData.ReadByteSeq(guid1[3]); recvData.ReadByteSeq(guid1[5]); recvData.ReadByteSeq(guid2[6]); petitionGuid = guid1; playerGuid = guid2; player = ObjectAccessor::FindPlayer(playerGuid); if (!player) return; type = GUILD_CHARTER_TYPE; uint32 petitionGuidLow = GUID_LOPART(petitionGuid); sLog->outDebug(LOG_FILTER_NETWORKIO, "OFFER PETITION: type %u, GUID1 %u, to player id: %u", type, petitionGuidLow, GUID_LOPART(playerGuid)); if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != player->GetTeam()) { if (type == GUILD_CHARTER_TYPE) Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NOT_ALLIED); return; } if (type == GUILD_CHARTER_TYPE) { if (player->GetGuildIdInvited()) { SendPetitionSignResult(_player->GetGUID(), MAKE_NEW_GUID(petitionGuidLow, 0, HIGHGUID_ITEM), PETITION_SIGN_ALREADY_SIGNED_OTHER); return; } if (player->GetGuildId()) { SendPetitionSignResult(_player->GetGUID(), MAKE_NEW_GUID(petitionGuidLow, 0, HIGHGUID_ITEM), PETITION_SIGN_ALREADY_IN_GUILD); return; } } auto stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_SIGNATURE); stmt->setUInt32(0, petitionGuidLow); auto result = CharacterDatabase.Query(stmt); typedef std::vector<uint32> storage; storage loParts; // result == NULL also correct charter without signs if (result) { loParts.reserve(uint32(result->GetRowCount())); do { auto fields = result->Fetch(); auto loPart = fields[0].GetUInt32(); if (GUID_LOPART(playerGuid) == loPart) { player->GetSession()->SendAlreadySigned(playerGuid); return; } loParts.push_back(loPart); } while (result->NextRow()); } WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES); ByteBuffer signsBuffer; guid2 = _player->GetGUID(); //ObjectGuid guid1 = petitionGuid; data.WriteBit(guid2[4]); data.WriteBit(guid1[4]); data.WriteBit(guid2[5]); data.WriteBit(guid2[0]); data.WriteBit(guid2[6]); data.WriteBit(guid1[7]); data.WriteBit(guid2[7]); data.WriteBit(guid1[0]); data.WriteBit(guid2[2]); data.WriteBit(guid2[3]); data.WriteBits(loParts.size(), 21); for (auto lowGuid : loParts) { ObjectGuid signerGuid = MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER); uint8 bitsSendOrder[8] = { 6, 2, 4, 5, 3, 0, 7, 1 }; data.WriteBitInOrder(signerGuid, bitsSendOrder); signsBuffer.WriteByteSeq(signerGuid[4]); signsBuffer.WriteByteSeq(signerGuid[7]); signsBuffer.WriteByteSeq(signerGuid[5]); signsBuffer.WriteByteSeq(signerGuid[3]); signsBuffer.WriteByteSeq(signerGuid[2]); signsBuffer << uint32(0); signsBuffer.WriteByteSeq(signerGuid[6]); signsBuffer.WriteByteSeq(signerGuid[1]); signsBuffer.WriteByteSeq(signerGuid[0]); } data.WriteBit(guid1[5]); data.WriteBit(guid1[6]); data.WriteBit(guid1[1]); data.WriteBit(guid1[3]); data.WriteBit(guid2[1]); data.WriteBit(guid1[2]); data.FlushBits(); data << uint32(petitionGuidLow); if (signsBuffer.size()) data.append(signsBuffer); data.WriteByteSeq(guid1[2]); data.WriteByteSeq(guid2[1]); data.WriteByteSeq(guid2[6]); data.WriteByteSeq(guid1[3]); data.WriteByteSeq(guid2[7]); data.WriteByteSeq(guid1[0]); data.WriteByteSeq(guid2[0]); data.WriteByteSeq(guid2[2]); data.WriteByteSeq(guid1[4]); data.WriteByteSeq(guid1[7]); data.WriteByteSeq(guid1[6]); data.WriteByteSeq(guid2[4]); data.WriteByteSeq(guid2[3]); data.WriteByteSeq(guid2[5]); data.WriteByteSeq(guid1[5]); data.WriteByteSeq(guid1[1]); player->GetSession()->SendPacket(&data); }
static constexpr const_pointer_type At(const_pointer_type p, unsigned pitch, int x, int y) { return Next(NextRow(p, pitch, y), x); }
void CSynBCGPEditCtrl::OnDrawLineNumbersBar( CDC* pDC, CRect rect ) { ASSERT_VALID (pDC); pDC->FillSolidRect (rect, m_clrBackLineNumber); // Draw dividing line: rect.DeflateRect (0, 0, 1, 0); WORD wHatchBits1 [8] = { 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00 }; WORD wHatchBits2 [8] = { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF }; CBitmap bmpPattern; bmpPattern.CreateBitmap (8, 8, 1, 1, (rect.top % 2) ? wHatchBits1 : wHatchBits2); CBrush br; br.CreatePatternBrush (&bmpPattern); CRect rectLine = rect; rectLine.left = rectLine.right - 1; COLORREF clrTextOld = pDC->SetTextColor (m_clrBackSidebar); pDC->FillRect (rectLine, &br); pDC->SetTextColor (clrTextOld); rect.DeflateRect (0, 0, 1, 0); // Determine start and end offsets of the visible part of buffer CPoint ptTopLeft (m_rectText.left + 1, m_rectText.top); CPoint ptBottomRight (m_rectText.right - 1, m_rectText.bottom - 1); int nStartOffset = HitTest (ptTopLeft); int nEndOffset = HitTest (ptBottomRight); if (nStartOffset == -1) { nStartOffset = 0; } if (nEndOffset == -1) { nEndOffset = m_strBuffer.GetLength () - 1; } nEndOffset = min (nEndOffset, m_strBuffer.GetLength ()); int nRowColumnTop = RowFromOffset (nStartOffset); int nRowColumnBottom = RowFromOffset (nEndOffset); // Draw line numbers: int nRow = nRowColumnTop; int nVirtualRow = GetVirtualRow (nRow); int nRowStartOffset = nStartOffset; while (nRow <= nRowColumnBottom && nRowStartOffset >= 0) { CRect rect (rect); rect.top = (nVirtualRow - m_nScrollOffsetVert) * m_nLineHeight; rect.bottom = rect.top + m_nLineHeight; OnDrawLineNumber (pDC, rect, nRow); NextRow (nRow, nVirtualRow, nRowStartOffset); } }
AveragingMSRowProvider::AveragingMSRowProvider(double nWavelengthsAveraging, const string& msPath, const MSSelection& selection, const std::map<size_t, size_t>& selectedDataDescIds, const string& dataColumnName, bool requireModel) : MSRowProvider(msPath, selection, selectedDataDescIds, dataColumnName, requireModel) { casacore::MSAntenna antennaTable(_ms.antenna()); _nAntennae = antennaTable.nrow(); casacore::ROArrayColumn<double> positionColumn(antennaTable, casacore::MSAntenna::columnName(casacore::MSAntennaEnums::POSITION)); std::vector<Pos> positions(_nAntennae); casacore::Array<double> posArr(casacore::IPosition(1, 3)); for(size_t i=0; i!=_nAntennae; ++i) { positionColumn.get(i, posArr); positions[i] = Pos(posArr.data()[0], posArr.data()[1], posArr.data()[2]); } // dataDescId x ant x ant _nElements = selectedDataDescIds.size() * _nAntennae * _nAntennae; _averagingFactors.assign(_nElements, 0.0); _buffers.resize(_nElements); MultiBandData bands(_ms.spectralWindow(), _ms.dataDescription()); double dt = (EndTime() - StartTime()) / (EndTimestep() - StartTimestep()); Logger::Debug << "Assuming integration time of " << dt * (24.0*60.0*60.0) << " seconds.\n"; size_t element = 0; size_t averagingSum = 0, minAvgFactor = std::numeric_limits<size_t>::max(), maxAvgFactor = 0; for(size_t a1=0; a1!=_nAntennae; ++a1) { Pos pos1 = positions[a1]; for(size_t a2=0; a2!=_nAntennae; ++a2) { Pos pos2 = positions[a2]; double dx = std::get<0>(pos1) - std::get<0>(pos2); double dy = std::get<1>(pos1) - std::get<1>(pos2); double dz = std::get<2>(pos1) - std::get<2>(pos2); double dist = sqrt(dx*dx + dy*dy + dz*dz); for(std::map<size_t, size_t>::const_iterator spwIter=selectedDataDescIds.begin(); spwIter!=selectedDataDescIds.end(); ++spwIter) { BandData band = bands[spwIter->first]; double lambda = band.SmallestWavelength(); double nWavelengthsPerIntegration = 2.0 * M_PI * dist / lambda * dt; _averagingFactors[element] = std::max<size_t>(size_t(floor(nWavelengthsAveraging / nWavelengthsPerIntegration)), 1); averagingSum += _averagingFactors[element]; if(a1 != a2) { minAvgFactor = std::min<size_t>(minAvgFactor, _averagingFactors[element]); maxAvgFactor = std::max<size_t>(maxAvgFactor, _averagingFactors[element]); } //Logger::Debug << a1 << '\t' << a2 << '\t' << _averagingFactors[element] << '\n'; ++element; } } } Logger::Info << "Averaging factor for longest baseline: " << minAvgFactor << " x . For the shortest: " << maxAvgFactor << " x \n"; _spwIndexToDataDescId.resize(selectedDataDescIds.size()); for(std::map<size_t, size_t>::const_iterator spwIter=selectedDataDescIds.begin(); spwIter!=selectedDataDescIds.end(); ++spwIter) { _spwIndexToDataDescId[spwIter->second] = spwIter->first; } _averageFactorSum = 0.0; _rowCount = 0; _averagedRowCount = 0; _currentData = DataArray(DataShape()); _currentModel = DataArray(DataShape()); _currentFlags = FlagArray(DataShape()); _currentWeights = WeightArray(DataShape()); _averagedDataDescId = _currentDataDescId; _flushPosition = 0; if(!MSRowProvider::AtEnd()) { bool timestepAvailable = processCurrentTimestep(); if(!timestepAvailable) NextRow(); } }
int CUGMem::SortBy(long startRow, long endRow, int *cols,int numCols,int flags) { if(m_rowInfo == NULL) return UG_ERROR; if(startRow >= endRow) return UG_ERROR; UGMemRI *OldListRowInfo; UGMemRI *OldListNextRowInfo; UGMemRI *NewListRowInfo; UGMemRI *NewListStartRowInfo; UGMemRI *NewListRowInfo_HalfPt; CUGCell* cell1; CUGCell* cell2; CUGCell blankCell; int index; int rt; BOOL bInserted = FALSE; int halfPtOffset = 0; BOOL bSkip; UGMemRI* lastSkipRow; long rowCount = startRow; //goto the first row, and copy the first row over to the sorted list GotoRow(startRow); NewListRowInfo = m_rowInfo; NewListStartRowInfo = m_rowInfo; NewListRowInfo_HalfPt = NewListRowInfo; //goto the second row and make that the unsorted list OldListRowInfo = m_rowInfo->next; m_rowInfo->next = NULL; //copy the (pointers to) cells from the columns to be sorted into the lookup list NewListRowInfo->cellLookup = new CUGCell*[numCols]; m_colInfo = NewListRowInfo->col; m_currentCol = 0; // TD JF added (for init as below) for(index =0; index < numCols;index++){ if(GotoCol(cols[index])==UG_SUCCESS) NewListRowInfo->cellLookup[index] = m_colInfo->cell; else NewListRowInfo->cellLookup[index] = NULL; } //main row sort loop - while there are items in the unsorted list while(OldListRowInfo != NULL && (rowCount < endRow) ){ //save the next row pointer OldListNextRowInfo = OldListRowInfo->next; //copy the (pointers to) cells from the columns to be sorted into the lookup list OldListRowInfo->cellLookup = new CUGCell*[numCols]; m_colInfo = OldListRowInfo->col; m_currentCol = 0; for(index =0; index < numCols;index++){ if(GotoCol(cols[index])==UG_SUCCESS) { OldListRowInfo->cellLookup[index] = m_colInfo->cell; } else { OldListRowInfo->cellLookup[index] = NULL; } } //check the half point //================================================ //get a cell from the unsorted list if(OldListRowInfo->cellLookup[0] != NULL) cell1 = OldListRowInfo->cellLookup[0]; else{ blankCell.ClearAll(); blankCell.ClearMemory(); cell1 = &blankCell; } //get a cell from the sorted list if(NewListRowInfo_HalfPt->cellLookup[0] != NULL) cell2 = NewListRowInfo_HalfPt->cellLookup[0]; else{ blankCell.ClearAll(); blankCell.ClearMemory(); cell2 = &blankCell; } //call the evaluation function rt = m_ctrl->OnSortEvaluate(cell1,cell2,flags); if(rt <= 0){ NewListRowInfo = NewListStartRowInfo; halfPtOffset -=1; } else{ NewListRowInfo = NewListRowInfo_HalfPt; halfPtOffset +=1; } if(halfPtOffset == -2){ halfPtOffset = 0; if(NewListRowInfo_HalfPt->prev != NULL) if(NewListRowInfo_HalfPt->prev->cellLookup != NULL) NewListRowInfo_HalfPt = NewListRowInfo_HalfPt->prev; } if(halfPtOffset == 2){ halfPtOffset = 0; if(NewListRowInfo_HalfPt->next != NULL) NewListRowInfo_HalfPt = NewListRowInfo_HalfPt->next; } //================================================ bSkip = TRUE; lastSkipRow = NULL; //main loop to check an unsorted item against the sorted list //NewListRowInfo = NewListStartRowInfo; bInserted = FALSE; while(NewListRowInfo != NULL){ //sort by the columns in their given order for(index = 0; index < numCols; index++){ //get a cell from the unsorted list if(OldListRowInfo->cellLookup[index] != NULL) cell1 = OldListRowInfo->cellLookup[index]; else{ blankCell.ClearAll(); blankCell.ClearMemory(); cell1 = &blankCell; } //get a cell from the sorted list if(NewListRowInfo->cellLookup[index] != NULL) cell2 = NewListRowInfo->cellLookup[index]; else{ blankCell.ClearAll(); blankCell.ClearMemory(); cell2 = &blankCell; } //call the evaluation function rt = m_ctrl->OnSortEvaluate(cell1,cell2,flags); if(rt < 0){ if(bSkip && lastSkipRow != NULL){ NewListRowInfo = lastSkipRow; bSkip = FALSE; break; } OldListRowInfo->next = NewListRowInfo; OldListRowInfo->prev = NewListRowInfo->prev; NewListRowInfo->prev = OldListRowInfo; if(OldListRowInfo->prev !=NULL) OldListRowInfo->prev->next = OldListRowInfo; if(NewListRowInfo == NewListStartRowInfo) NewListStartRowInfo = OldListRowInfo; bInserted = TRUE; rowCount++; break; } //if equal then check the next column to sort by else if(rt == 0){ } else{ break; } } //if the item was inserted into the sorted then then break if(bInserted == TRUE) break; //if at the end of the sorted list then add the item if(NewListRowInfo->next == NULL){ NewListRowInfo->next = OldListRowInfo; OldListRowInfo->prev = NewListRowInfo; OldListRowInfo->next = NULL; rowCount++; break; } //perform row skips if(bSkip){ lastSkipRow = NewListRowInfo; for(int loop = 0; loop< 100; loop++){ if(NewListRowInfo->next != NULL){ NewListRowInfo = NewListRowInfo->next; } else{ NewListRowInfo = lastSkipRow; bSkip = FALSE; break; } } } else{ NewListRowInfo = NewListRowInfo->next; } } OldListRowInfo = OldListNextRowInfo; } //reset the linked list positioning pointers m_currentRow = startRow; m_currentCol = 0; m_rowInfo = NewListStartRowInfo; m_colInfo = NewListStartRowInfo->col; //add the rest of the rows, if they were not part of the sort if(rowCount == endRow && OldListRowInfo != NULL){ GotoRow(endRow); m_rowInfo->next = OldListRowInfo; OldListRowInfo->prev = m_rowInfo; m_currentRow = startRow; m_rowInfo = NewListStartRowInfo; } //delete all of the cell lookups GotoRow(0); do { if(m_rowInfo->cellLookup != NULL) { delete[] m_rowInfo->cellLookup; } m_rowInfo->cellLookup = NULL; }while(NextRow() == UG_SUCCESS); GotoRow(0); return UG_SUCCESS; }