114 return(
new CSG_Table(File, Format, Encoding) );
122 return(
new CSG_Table(File, Format, Encoding) );
199 for(
int i=0; !bResult && i<Connections.
Get_Count(); i++)
201 if( !Connection.
Cmp(Connections[i].asString(0)) )
258 return(
Load(File, (
int)Format, Separator, Encoding) );
329 _Destroy_Selection();
374 if( !pObject || !pObject->
is_Valid()
489 if( Position < 0 || Position >
m_nFields )
528 if( del_Field < 0 || del_Field >=
m_nFields )
575 if( iField < 0 || iField >=
m_nFields || iField == Position )
581 if( Position > iField )
591 if( Position < iField )
596 #pragma omp parallel for
619 if( iField >= 0 && iField <
m_nFields && Name && *Name )
652 (*pValue) = *pRecord->
m_Values[iField];
688 if( Length < nBytes )
695 return( (
int)Length );
748 #define GET_GROW_SIZE(n) (n < 256 ? 1 : (n < 8192 ? 128 : 1024))
751 bool CSG_Table::_Inc_Array(
void)
760 if( pRecords == NULL )
765 m_Records = pRecords;
772 bool CSG_Table::_Dec_Array(
void)
781 if( pRecords == NULL )
786 m_Records = pRecords;
827 if( Selection[i] > iRecord )
836 m_Records[i] = m_Records[i - 1]; m_Records[i]->
m_Index = i;
842 m_Records[iRecord] = pRecord;
864 if( iRecord >= 0 && iRecord <
m_nRecords && pCopy )
866 return( m_Records[iRecord]->
Assign(pCopy) );
882 delete(m_Records[iRecord]);
888 m_Records[i] = m_Records[i + 1]; m_Records[i]->
m_Index = i;
918 delete(m_Records[iRecord]);
936 else if( nRecords >= 0 &&
m_nRecords > nRecords )
959 return( Value.
Cmp(m_Records[iRecord = 0]->
asString(iField)) == 0 );
972 if( Value.
Cmp(m_Records[iRecord]->
asString(iField)) == 0 )
982 #define GET_RECORD(i) Get_Record_byIndex(bAscending ? (iRecord = i) : m_nRecords - 1 - (iRecord = i))
986 if( (d = Value.
Cmp(
GET_RECORD(0 )->asString(iField))) < 0 ) {
return(
false ); }
else if( d == 0 ) {
return(
true ); }
987 if( (d = Value.
Cmp(
GET_RECORD(
m_nRecords - 1)->asString(iField))) > 0 ) {
return(
false ); }
else if( d == 0 ) {
return(
true ); }
991 d = Value.
Cmp(
GET_RECORD(a + (b - a) / 2)->asString(iField));
1021 if(
Find_Record(iRecord, iField, Value, bCreateIndex) )
1039 return( Value == m_Records[iRecord = 0]->asDouble(iField) );
1050 for(iRecord=0; iRecord<
m_nRecords; iRecord++)
1052 if( Value == m_Records[iRecord]->asDouble(iField) )
1062 #define GET_RECORD(i) Get_Record_byIndex(bAscending ? (iRecord = i) : m_nRecords - 1 - (iRecord = i))
1066 if( (d = Value -
GET_RECORD(0 )->asDouble(iField)) < 0. ) {
return(
false ); }
else if( d == 0. ) {
return(
true ); }
1067 if( (d = Value -
GET_RECORD(
m_nRecords - 1)->asDouble(iField)) > 0. ) {
return(
false ); }
else if( d == 0. ) {
return(
true ); }
1071 d = Value -
GET_RECORD(a + (b - a) / 2)->asDouble(iField);
1101 if(
Find_Record(iRecord, iField, Value, bCreateIndex) )
1123 if( bModified ==
false )
1125 #pragma omp parallel for
1141 return( pRecord && pRecord->
Set_Value(iField, Value) );
1154 return( pRecord && pRecord->
Set_Value(iField, Value) );
1206 for(
int iField=0; iField<
m_nFields; iField++)
1246 for(
double i=0; i<(double)
Get_Count(); i+=d)
1252 Statistics += pRecord->
asDouble(iField);
1268 Statistics += pRecord->
asDouble(iField);
1380 CSG_Table_Record_Compare_Field(
const CSG_Table *pTable,
int Field,
bool Ascending)
1384 m_Ascending = Ascending;
1386 if( !m_pTable || m_Field < 0 || m_Field >= m_pTable->Get_Field_Count() )
1392 bool is_Okay (
void)
const {
return( m_pTable != NULL ); }
1396 sLong a = m_Ascending ? _a : _b;
1397 sLong b = m_Ascending ? _b : _a;
1399 switch( m_pTable->Get_Field_Type(m_Field) )
1403 m_pTable->Get_Record(a)->asDouble(m_Field) -
1404 m_pTable->Get_Record(b)->asDouble(m_Field);
1406 return( d < 0. ? -1 : d > 0. ? 1 : 0 );
1412 m_pTable->Get_Record(a)->asString(m_Field),
1413 m_pTable->Get_Record(b)->asString(m_Field))
1432 CSG_Table_Record_Compare_Field Compare(
this, Field, bAscending);
1446 CSG_Table_Record_Compare_Fields(
const CSG_Table *pTable,
int Fields[],
int nFields,
bool Ascending)
1447 : m_pTable(pTable), m_Fields(Fields), m_nFields(nFields)
1449 m_Ascending.Create(nFields);
1451 for(
int i=0; m_pTable && i<m_nFields; i++)
1453 if( m_Fields[i] >= m_pTable->Get_Field_Count() )
1458 m_Ascending[i] = Ascending ? 1 : 0;
1462 CSG_Table_Record_Compare_Fields(
const CSG_Table *pTable,
int Fields[],
int nFields,
int Ascending[])
1463 : m_pTable(pTable), m_Fields(Fields), m_nFields(nFields)
1465 m_Ascending.Create(nFields);
1467 for(
int i=0; m_pTable && i<m_nFields; i++)
1469 if( m_Fields[i] >= m_pTable->Get_Field_Count() )
1474 m_Ascending[i] = Ascending[i] > 0 ? 1 : 0;
1478 bool is_Okay (
void)
const {
return( m_pTable != NULL ); }
1484 for(
int i=0; !Difference && i<m_nFields; i++)
1486 int Field = m_Fields[i];
1488 sLong a = m_Ascending[i] ? _a : _b;
1489 sLong b = m_Ascending[i] ? _b : _a;
1491 switch( m_pTable->Get_Field_Type(Field) )
1494 double d = m_pTable->Get_Record(a)->asDouble(Field);
1495 d -= m_pTable->Get_Record(b)->asDouble(Field);
1496 Difference = d < 0. ? -1 : d > 0. ? 1 : 0;
1501 CSG_String s (m_pTable->Get_Record(a)->asString(Field));
1502 Difference = s.Cmp(m_pTable->Get_Record(b)->asString(Field));
1507 return( Difference );
1513 int *m_Fields, m_nFields;
1524 CSG_Table_Record_Compare_Fields Compare(
this, Fields, nFields, bAscending);
1536 void CSG_Table::_Index_Update(
void)
1538 if( m_Index_Fields.
Get_Size() < 1 )
1547 Fields += abs(m_Index_Fields[i]) - 1;
1548 Ascending += m_Index_Fields[i] > 0 ? 1 : 0;