本文整理汇总了C++中DBObjTable::ListSort方法的典型用法代码示例。如果您正苦于以下问题:C++ DBObjTable::ListSort方法的具体用法?C++ DBObjTable::ListSort怎么用?C++ DBObjTable::ListSort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBObjTable
的用法示例。
在下文中一共展示了DBObjTable::ListSort方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Read
//.........这里部分代码省略.........
case DBTypeGridDiscrete:
{
DBInt value;
char nameStr [DBStringLength];
DBObjRecord *symRec = (data->Table (DBrNSymbols))->Add ("Default Symbol");
DBObjRecord *itemRec;
DBObjTableField *gridValueFLD = itemTable->Field (DBrNGridValue);
DBObjTableField *gridSymbolFLD = itemTable->Field (DBrNSymbol);
DBObjTableField *symbolIDFLD = (data->Table (DBrNSymbols))->Field (DBrNSymbolID);
DBObjTableField *foregroundFLD = (data->Table (DBrNSymbols))->Field (DBrNForeground);
DBObjTableField *backgroundFLD = (data->Table (DBrNSymbols))->Field (DBrNBackground);
DBObjTableField *styleFLD = (data->Table (DBrNSymbols))->Field (DBrNStyle);
symbolIDFLD->Int (symRec,0);
foregroundFLD->Int (symRec,1);
backgroundFLD->Int (symRec,0);
styleFLD->Int (symRec,0);
for (dataRec = (data->Arrays ())->First ();dataRec != (DBObjRecord *) NULL;dataRec = (data->Arrays ())->Next ())
{
for (i = 0;i < ColNum () * RowNum ();++i)
{
switch (valueType)
{
case DBTableFieldFloat: value = (DBInt) rint (*((float *) ((char *) dataRec->Data () + i * valueSize))); break;
case DBTableFieldInt:
switch (valueSize)
{
case sizeof (DBByte): value = (DBInt) (*((DBByte *) ((char *) dataRec->Data () + i * valueSize))); break;
case sizeof (DBShort): value = (DBInt) (*((DBShort *) ((char *) dataRec->Data () + i * valueSize))); break;
case sizeof (DBInt): value = (DBInt) (*((DBInt *) ((char *) dataRec->Data () + i * valueSize))); break;
default: CMmsgPrint (CMmsgAppError, "Wrong Data Size in: %s %d",__FILE__,__LINE__); return (DBFault);
}
break;
default: CMmsgPrint (CMmsgAppError, "Wrong Data Type in: %s %d",__FILE__,__LINE__); return (DBFault);
}
sprintf (nameStr,"Category%04d",value);
if ((itemRec = itemTable->Item (nameStr)) == (DBObjRecord *) NULL)
{
if ((itemRec = itemTable->Add (nameStr)) == (DBObjRecord *) NULL)
{ CMmsgPrint (CMmsgAppError, "Item Object Creation Error in: %s %d",__FILE__,__LINE__); return (DBFault); }
gridValueFLD->Int (itemRec,value);
gridSymbolFLD->Record (itemRec,symRec);
}
value = itemRec->RowID ();
switch (valueSize)
{
case sizeof (DBByte): *((DBByte *) ((char *) dataRec->Data () + i * valueSize)) = value; break;
case sizeof (DBShort): *((DBShort *) ((char *) dataRec->Data () + i * valueSize)) = value; break;
case sizeof (DBInt): *((DBInt *) ((char *) dataRec->Data () + i * valueSize)) = value; break;
default: CMmsgPrint (CMmsgAppError, "Wrong Data Size in: %s %d",__FILE__,__LINE__); return (DBFault);
}
}
}
itemTable->ListSort (gridValueFLD);
for (dataRec = (data->Arrays ())->First ();dataRec != (DBObjRecord *) NULL;dataRec = (data->Arrays ())->Next ())
{
for (i = 0;i < ColNum () * RowNum ();++i)
{
switch (valueSize)
{
case sizeof (DBByte): value = (DBInt) (*((DBByte *) ((char *) dataRec->Data () + i * valueSize))); break;
case sizeof (DBShort): value = (DBInt) (*((DBShort *) ((char *) dataRec->Data () + i * valueSize))); break;
case sizeof (DBInt): value = (DBInt) (*((DBInt *) ((char *) dataRec->Data () + i * valueSize))); break;
default: CMmsgPrint (CMmsgAppError, "Wrong Data Size in: %s %d",__FILE__,__LINE__); return (DBFault);
}
itemRec = itemTable->Item (value);
value = itemRec->ListPos ();
switch (valueSize)
{
case sizeof (DBByte): *((DBByte *) ((char *) dataRec->Data () + i * valueSize)) = value; break;
case sizeof (DBShort): *((DBShort *) ((char *) dataRec->Data () + i * valueSize)) = value; break;
case sizeof (DBInt): *((DBInt *) ((char *) dataRec->Data () + i * valueSize)) = value; break;
default: CMmsgPrint (CMmsgAppError, "Wrong Data Size in: %s %d",__FILE__,__LINE__); return (DBFault);
}
}
}
itemTable->ItemSort ();
gridIF = new DBGridIF (data);
gridIF->DiscreteStats ();
delete gridIF;
} break;
case DBTypeGridContinuous:
{
DBObjTableField *missingValueFLD = itemTable->Field (DBrNMissingValue);
for (dataRec = (data->Arrays ())->First ();dataRec != (DBObjRecord *) NULL;dataRec = (data->Arrays ())->Next ())
{
itemTable->Add (dataRec->Name ());
missingValueFLD->Float (itemTable->Item (),MissingValue ());
}
gridIF = new DBGridIF (data);
gridIF->RecalcStats ();
delete gridIF;
data->Flags (DBDataFlagDispModeContBlueRed,DBSet);
break;
}
default: break;
}
return (DBSuccess);
}
示例2: RGlibPointSubbasinStats
DBInt RGlibPointSubbasinStats(DBObjData *pntData, DBObjData *netData, DBObjData *grdData, DBObjData *tblData) {
DBInt layerID, layerNum = 0, progress = 0, maxProgress;
DBObjTable *table;
DBObjTableField *pointIDFLD;
DBObjTableField *layerIDFLD;
DBObjTableField *layerNameFLD;
DBObjTableField *minimumFLD;
DBObjTableField *maximumFLD;
DBObjTableField *averageFLD;
DBObjTableField *stdDevFLD;
DBObjTableField *areaFLD;
DBVPointIF *pntIF;
DBNetworkIF *netIF;
DBObjRecord *pntRec, *tblRec;
DBObjectLIST<DBObjTableField> *fields;
_RGlibPointGrdIF = new DBGridIF(grdData);
for (layerID = 0; layerID < _RGlibPointGrdIF->LayerNum(); ++layerID) {
_RGlibPointGrdLayerRec = _RGlibPointGrdIF->Layer(layerID);
if ((_RGlibPointGrdLayerRec->Flags() & DBObjectFlagIdle) != DBObjectFlagIdle) ++layerNum;
}
if (layerNum < 1) {
CMmsgPrint(CMmsgUsrError, "No Layer to Process!");
delete _RGlibPointGrdIF;
return (DBFault);
}
table = tblData->Table(DBrNItems);
pntIF = new DBVPointIF(pntData);
netIF = new DBNetworkIF(netData);
table->AddField(pointIDFLD = new DBObjTableField("GHAASPointID", DBTableFieldInt, "%8d", sizeof(DBInt)));
table->AddField(layerIDFLD = new DBObjTableField("LayerID", DBTableFieldInt, "%4d", sizeof(DBShort)));
table->AddField(layerNameFLD = new DBObjTableField("LayerName", DBTableFieldString, "%s", DBStringLength));
table->AddField(averageFLD = new DBObjTableField(RGlibPointMean, DBTableFieldFloat, _RGlibPointGrdIF->ValueFormat(),
sizeof(DBFloat4)));
table->AddField(minimumFLD = new DBObjTableField(RGlibPointMin, DBTableFieldFloat, _RGlibPointGrdIF->ValueFormat(),
sizeof(DBFloat4)));
table->AddField(maximumFLD = new DBObjTableField(RGlibPointMax, DBTableFieldFloat, _RGlibPointGrdIF->ValueFormat(),
sizeof(DBFloat4)));
table->AddField(
stdDevFLD = new DBObjTableField(RGlibPointStdDev, DBTableFieldFloat, _RGlibPointGrdIF->ValueFormat(),
sizeof(DBFloat4)));
table->AddField(areaFLD = new DBObjTableField(RGlibPointArea, DBTableFieldFloat, _RGlibPointGrdIF->ValueFormat(),
sizeof(DBFloat4)));
grdData->Flags(DBObjectFlagProcessed, DBSet);
maxProgress = pntIF->ItemNum() * _RGlibPointGrdIF->LayerNum();
for (layerID = 0; layerID < _RGlibPointGrdIF->LayerNum(); ++layerID) {
_RGlibPointGrdLayerRec = _RGlibPointGrdIF->Layer(layerID);
if ((_RGlibPointGrdLayerRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
for (pntRec = pntIF->FirstItem(); pntRec != (DBObjRecord *) NULL; pntRec = pntIF->NextItem()) {
if (DBPause(progress * 100 / maxProgress)) goto Stop;
progress++;
if ((pntRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
tblRec = table->Add(pntRec->Name());
pointIDFLD->Int(tblRec, pntRec->RowID() + 1);
layerIDFLD->Int(tblRec, _RGlibPointGrdLayerRec->RowID());
layerNameFLD->String(tblRec, _RGlibPointGrdLayerRec->Name());
_RGlibSubbasinArea = 0.0;
_RGlibSubbasinMin = DBHugeVal;
_RGlibSubbasinMax = -DBHugeVal;
_RGlibSubbasinMean = 0.0;
_RGlibSubbasinStdDev = 0.0;
netIF->UpStreamSearch(netIF->Cell(pntIF->Coordinate(pntRec)), (DBNetworkACTION) _RGlibSubbasinStatistics);
_RGlibSubbasinMean = _RGlibSubbasinMean / _RGlibSubbasinArea;
_RGlibSubbasinStdDev = _RGlibSubbasinStdDev / _RGlibSubbasinArea;
_RGlibSubbasinStdDev = _RGlibSubbasinStdDev - _RGlibSubbasinMean * _RGlibSubbasinMean;
_RGlibSubbasinStdDev = sqrt(_RGlibSubbasinStdDev);
minimumFLD->Float(tblRec, _RGlibSubbasinMin);
maximumFLD->Float(tblRec, _RGlibSubbasinMax);
averageFLD->Float(tblRec, _RGlibSubbasinMean);
stdDevFLD->Float(tblRec, _RGlibSubbasinStdDev);
areaFLD->Float(tblRec, _RGlibSubbasinArea);
}
}
Stop:
delete _RGlibPointGrdIF;
delete netIF;
delete pntIF;
if (progress == maxProgress) {
fields = new DBObjectLIST<DBObjTableField>("Field List");
fields->Add(new DBObjTableField(*pointIDFLD));
fields->Add(new DBObjTableField(*layerIDFLD));
table->ListSort(fields);
delete fields;
return (DBSuccess);
}
return (DBFault);
}
示例3: RGlibPointSubbasinHist
DBInt RGlibPointSubbasinHist(DBObjData *pntData, DBObjData *netData, DBObjData *grdData, DBObjData *tblData) {
DBInt layerID, layerNum = 0, progress = 0, maxProgress;
DBObjTable *itemTable = grdData->Table(DBrNItems);
DBObjTable *table = tblData->Table(DBrNItems);
DBObjTableField *pointIDFLD;
DBObjTableField *layerIDFLD;
DBObjTableField *layerNameFLD;
DBObjTableField *categoryIDFLD;
DBObjTableField *categoryFLD;
DBObjTableField *percentFLD;
DBObjTableField *areaFLD;
DBObjTableField *cellNumFLD;
DBVPointIF *pntIF;
DBNetworkIF *netIF;
DBObjRecord *pntRec, *itemRec, *tblRec;
DBObjectLIST<DBObjTableField> *fields;
_RGlibPointGrdIF = new DBGridIF(grdData);
for (layerID = 0; layerID < _RGlibPointGrdIF->LayerNum(); ++layerID) {
_RGlibPointGrdLayerRec = _RGlibPointGrdIF->Layer(layerID);
if ((_RGlibPointGrdLayerRec->Flags() & DBObjectFlagIdle) != DBObjectFlagIdle) ++layerNum;
}
if (layerNum < 1) {
CMmsgPrint(CMmsgUsrError, "No Layer to Process!");
delete _RGlibPointGrdIF;
return (DBFault);
}
pntIF = new DBVPointIF(pntData);
netIF = new DBNetworkIF(netData);
table->AddField(pointIDFLD = new DBObjTableField("GHAASPointID", DBTableFieldInt, "%8d", sizeof(DBInt)));
table->AddField(layerIDFLD = new DBObjTableField("LayerID", DBTableFieldInt, "%4d", sizeof(DBShort)));
table->AddField(layerNameFLD = new DBObjTableField("LayerName", DBTableFieldString, "%s", DBStringLength));
table->AddField(categoryIDFLD = new DBObjTableField(DBrNCategoryID, DBTableFieldInt, "%2d", sizeof(DBShort)));
table->AddField(categoryFLD = new DBObjTableField(DBrNCategory, DBTableFieldString, _RGlibPointGrdIF->ValueFormat(),
DBStringLength));
table->AddField(cellNumFLD = new DBObjTableField("CellNum", DBTableFieldInt, "%8d", sizeof(DBInt)));
table->AddField(areaFLD = new DBObjTableField(DBrNArea, DBTableFieldFloat, "%10.1f", sizeof(DBFloat4)));
table->AddField(percentFLD = new DBObjTableField(DBrNPercent, DBTableFieldFloat, "%6.2f", sizeof(DBFloat4)));
_RGlibHistogram = (Histogram *) malloc(itemTable->ItemNum() * sizeof(Histogram));
if (_RGlibHistogram == (Histogram *) NULL) {
CMmsgPrint(CMmsgAppError, "Memory Allocation Error in: %s %d", __FILE__, __LINE__);
return (DBFault);
}
maxProgress = pntIF->ItemNum() * _RGlibPointGrdIF->LayerNum();
for (layerID = 0; layerID < _RGlibPointGrdIF->LayerNum(); ++layerID) {
_RGlibPointGrdLayerRec = _RGlibPointGrdIF->Layer(layerID);
if ((_RGlibPointGrdLayerRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
for (pntRec = pntIF->FirstItem(); pntRec != (DBObjRecord *) NULL; pntRec = pntIF->NextItem()) {
if (DBPause(progress * 100 / maxProgress)) goto Stop;
progress++;
if ((pntRec->Flags() & DBObjectFlagIdle) == DBObjectFlagIdle) continue;
for (itemRec = itemTable->First(); itemRec != (DBObjRecord *) NULL; itemRec = itemTable->Next())
_RGlibHistogram[itemRec->RowID()].Initialize();
netIF->UpStreamSearch(netIF->Cell(pntIF->Coordinate(pntRec)), (DBNetworkACTION) _RGlibSubbasinCategories);
for (itemRec = itemTable->First(); itemRec != (DBObjRecord *) NULL; itemRec = itemTable->Next())
if (_RGlibHistogram[itemRec->RowID()].cellNum > 0) {
tblRec = table->Add(pntRec->Name());
pointIDFLD->Int(tblRec, pntRec->RowID() + 1);
layerIDFLD->Int(tblRec, _RGlibPointGrdLayerRec->RowID());
layerNameFLD->String(tblRec, _RGlibPointGrdLayerRec->Name());
categoryIDFLD->Int(tblRec, itemRec->RowID() + 1);
categoryFLD->String(tblRec, itemRec->Name());
areaFLD->Float(tblRec, _RGlibHistogram[itemRec->RowID()].area);
percentFLD->Float(tblRec, _RGlibHistogram[itemRec->RowID()].area /
netIF->CellBasinArea(netIF->Cell(pntIF->Coordinate(pntRec))) * 100.0);
cellNumFLD->Int(tblRec, _RGlibHistogram[itemRec->RowID()].cellNum);
}
}
}
Stop:
delete _RGlibPointGrdIF;
delete netIF;
delete pntIF;
free(_RGlibHistogram);
if (progress == maxProgress) {
fields = new DBObjectLIST<DBObjTableField>("Field List");
fields->Add(new DBObjTableField(*pointIDFLD));
fields->Add(new DBObjTableField(*layerIDFLD));
fields->Add(areaFLD = new DBObjTableField(*areaFLD));
areaFLD->Flags(DBObjectFlagSortReversed, DBSet);
table->ListSort(fields);
delete fields;
return (DBSuccess);
}
return (DBFault);
}
示例4: RGlibPointInterStationTS
DBInt RGlibPointInterStationTS(DBObjData *pntData, DBObjData *tsData, char *relateFldName, char *joinFldName) {
DBInt first = true, tsIndex, tsRowNum = 0;
DBObjTable *pntTBL = pntData->Table(DBrNItems), *tsTBL;
DBObjectLIST<DBObjTableField> *fields;
DBObjTableField *pntNextFLD = pntTBL->Field(RGlibNextStation);
DBObjTableField *pntAreaFLD = pntTBL->Field(RGlibArea);
DBObjTableField *pntInterStnFLD = pntTBL->Field(RGlibInterStation);
DBObjTableField *pntRelateFLD;
DBObjTableField *pntNewNextFLD;
DBObjTableField *pntNewInterStnFLD;
DBObjTableField *tsTimeFLD;
DBObjTableField *tsJoinFLD;
DBObjTableField *tsNextStnFLD, *tsInterStnFLD;
DBObjRecord *pntRec, *nextPntRec, *tsRec, *tsIndexRec;
DBDate curDate, date;
if (pntNextFLD == (DBObjTableField *) NULL) {
CMmsgPrint(CMmsgUsrError, "Missing Next Station Field!");
return (DBFault);
}
if (pntAreaFLD == (DBObjTableField *) NULL) {
CMmsgPrint(CMmsgUsrError, "Missing STN Area Field!");
return (DBFault);
}
if (pntInterStnFLD == (DBObjTableField *) NULL) {
CMmsgPrint(CMmsgUsrError, "Missing Interfluvial Area Field!");
return (DBFault);
}
tsTBL = tsData->Table(DBrNItems);
tsNextStnFLD = new DBObjTableField(RGlibNextStation, DBTableFieldInt, "%8d", sizeof(DBInt));
tsTBL->AddField(tsNextStnFLD);
tsInterStnFLD = new DBObjTableField(RGlibInterStation, DBTableFieldFloat, "%9.1f", sizeof(DBFloat4));
tsTBL->AddField(tsInterStnFLD);
fields = tsTBL->Fields();
for (tsTimeFLD = fields->First(); tsTimeFLD != (DBObjTableField *) NULL; tsTimeFLD = fields->Next())
if (tsTimeFLD->Type() == DBTableFieldDate) break;
if (tsTimeFLD == (DBObjTableField *) NULL) {
CMmsgPrint(CMmsgUsrError, "Missing Date Field!");
return (DBFault);
}
if ((tsJoinFLD = tsTBL->Field(joinFldName)) == (DBObjTableField *) NULL) {
CMmsgPrint(CMmsgUsrError, "Missing Join Field!");
return (DBFault);
}
fields = new DBObjectLIST<DBObjTableField>("Field List");
fields->Add(new DBObjTableField(*tsTimeFLD));
fields->Add(new DBObjTableField(*tsJoinFLD));
tsTBL->ListSort(fields);
delete fields;
pntTBL = new DBObjTable(*pntTBL);
pntNextFLD = pntTBL->Field(RGlibNextStation);
pntAreaFLD = pntTBL->Field(RGlibArea);
pntInterStnFLD = pntTBL->Field(RGlibInterStation);
pntNewNextFLD = new DBObjTableField("NextStnTS", pntNextFLD->Type(), pntNextFLD->Format(), pntNextFLD->Length());
pntNewInterStnFLD = new DBObjTableField("InterFluTS", pntInterStnFLD->Type(), pntInterStnFLD->Format(),
pntInterStnFLD->Length());
pntRelateFLD = pntTBL->Field(relateFldName);
pntTBL->AddField(pntNewNextFLD);
pntTBL->AddField(pntNewInterStnFLD);
pntTBL->ListSort(pntRelateFLD);
tsIndexRec = tsTBL->First(&tsIndex);
for (tsRec = tsTBL->First(); tsRec != (DBObjRecord *) NULL; tsRec = tsTBL->Next()) {
DBPause(tsRowNum++ * 100 / tsTBL->ItemNum());
date = tsTimeFLD->Date(tsRec);
if (date != curDate) {
if (first) first = false;
else {
for (pntRec = pntTBL->First(); pntRec != (DBObjRecord *) NULL; pntRec = pntTBL->Next()) {
if ((pntRec->Flags() & DBObjectFlagLocked) != DBObjectFlagLocked) continue;
for (nextPntRec = pntTBL->Item(pntNextFLD->Int(pntRec) - 1);
(nextPntRec != (DBObjRecord *) NULL) &&
((nextPntRec->Flags() & DBObjectFlagLocked) != DBObjectFlagLocked);
nextPntRec = pntTBL->Item(pntNextFLD->Int(nextPntRec) - 1));
if (nextPntRec != (DBObjRecord *) NULL) {
pntNewNextFLD->Int(pntRec, nextPntRec->RowID() + 1);
pntNewInterStnFLD->Float(nextPntRec,
pntNewInterStnFLD->Float(nextPntRec) - pntAreaFLD->Float(pntRec));
}
}
pntRec = pntTBL->First();
for (; tsIndexRec != (DBObjRecord *) NULL; tsIndexRec = tsTBL->Next(&tsIndex)) {
if (tsRec == tsIndexRec) break;
for (; pntRec != (DBObjRecord *) NULL; pntRec = pntTBL->Next())
if (pntRelateFLD->Int(pntRec) == tsJoinFLD->Int(tsIndexRec)) {
tsNextStnFLD->Int(tsIndexRec, pntNewNextFLD->Int(pntRec));
tsInterStnFLD->Float(tsIndexRec, pntNewInterStnFLD->Float(pntRec));
break;
}
if (pntRec == (DBObjRecord *) NULL) pntRec = pntTBL->First();
}
}
for (pntRec = pntTBL->First(); pntRec != (DBObjRecord *) NULL; pntRec = pntTBL->Next()) {
pntNewNextFLD->Int(pntRec, 0);
pntNewInterStnFLD->Float(pntRec, pntAreaFLD->Float(pntRec));
pntRec->Flags(DBObjectFlagLocked, DBClear);
}
curDate = date;
//.........这里部分代码省略.........