radixSort(std::vector<T> v) { std::vector<T> tmp; size_t radix_count = sizeof(T); // we process elements in 256 counting system. Each radix = byte. for (size_t radix = 0; radix < radix_count; ++radix) { std::vector<size_t> counts(radix_count); for (auto x : v) { // get radix auto radix = getRadix(x); // increase radix count at its position } // calculate cumulative summs // write elements from V to TMP according to cum_sums positions. Modify cum_sums after writing an element v.swap(tmp); } }
void Cask::CdapOdbc::ColumnsDataReader::getColumnValue(const ColumnBinding& binding) { auto& record = this->queryResult.getRows().at(this->currentRowIndex); std::wstring name; std::wstring typeName; SQLSMALLINT radix = 0; switch (binding.getColumnNumber()) { case 1: // TABLE_CAT case 2: // TABLE_SCHEM case 9: // DECIMAL_DIGITS case 12: // REMARKS case 13: // COLUMN_DEF case 15: // SQL_DATETIME_SUB case 16: // CHAR_OCTET_LENGTH this->fetchNull(binding); break; case 3: // TABLE_NAME this->fetchVarchar(this->tableName.c_str(), binding); break; case 4: // COLUMN_NAME name = record.at(L"name").as_string(); this->fetchVarchar(name.c_str(), binding); break; case 5: // DATA_TYPE case 14: // SQL_DATA_TYPE this->fetchSmallint(getDataType(record.at(L"type")), binding); break; case 6: // TYPE_NAME typeName = getTypeName(record.at(L"type")); this->fetchVarchar(typeName.c_str(), binding); break; case 7: // COLUMN_SIZE this->fetchInt(getColumnSize(record.at(L"type")), binding); break; case 8: // BUFFER_LENGTH this->fetchInt(getBufferLength(record.at(L"type")), binding); break; case 10: // NUM_PREC_RADIX radix = getRadix(record.at(L"type")); if (radix > 0) { this->fetchSmallint(radix, binding); } else { this->fetchNull(binding); } break; case 11: // NULLABLE this->fetchSmallint(getIsNull(record.at(L"type")), binding); break; case 17: // ORDINAL_POSITION this->fetchInt(this->currentRowIndex + 1, binding); break; case 18: // IS_NULLABLE this->fetchVarchar((getIsNull(record.at(L"type")) == SQL_NO_NULLS) ? L"NO" : L"YES", binding); break; } }
/* Insert separators iff defined. */ QString QEStringFormatting::insertSeparators( const QString image) const { QString result = image; if( separator != SEPARATOR_NONE ){ static const QChar sc_list [4] = { '?', ',', '_', ' ' }; const QChar sc = sc_list [separator]; // For decimal, this is the usual thousands separator. const unsigned int r = getRadix(); const int groupSize = ( r == 2 || r == 16 ) ? 4 : 3; int dp; // Insert separators before decimal point. dp = result.indexOf( ".", 0 ); if( dp < 0 ) dp = result.length (); // otherwise add virtual point at end of string dp -= groupSize; while( ( dp > 0 ) && ( result [dp - 1] >= '0' ) && ( result [dp - 1] <= '9') ){ result.insert (dp, sc); dp -= groupSize; } // Insert separators after decimal point. dp = result.indexOf( ".", 0 ); if( dp >= 0 ) { int ep = result.indexOf( "e", dp ); // find exponent if it exists if( ep < 0 ) ep = result.indexOf( "E", dp ); // allow for either case if( ep < 0 ) ep = result.length (); // otherwise start at end of string dp += groupSize + 1; while( dp < ep ){ result.insert (dp, sc); dp += groupSize + 1; ep += 1; } } } return result; }
int QCaLineEditPlugin::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QCaLineEdit::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 1) qt_static_metacall(this, _c, _id, _a); _id -= 1; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = getVariableNameProperty(); break; case 1: *reinterpret_cast< QString*>(_v) = getVariableNameSubstitutionsProperty(); break; case 2: *reinterpret_cast< bool*>(_v) = getWriteOnLoseFocus(); break; case 3: *reinterpret_cast< bool*>(_v) = getWriteOnEnter(); break; case 4: *reinterpret_cast< bool*>(_v) = getSubscribe(); break; case 5: *reinterpret_cast< bool*>(_v) = getVariableAsToolTip(); break; case 6: *reinterpret_cast< bool*>(_v) = isEnabled(); break; case 7: *reinterpret_cast< bool*>(_v) = getConfirmWrite(); break; case 8: *reinterpret_cast< uint*>(_v) = getPrecision(); break; case 9: *reinterpret_cast< bool*>(_v) = getUseDbPrecision(); break; case 10: *reinterpret_cast< bool*>(_v) = getLeadingZero(); break; case 11: *reinterpret_cast< bool*>(_v) = getTrailingZeros(); break; case 12: *reinterpret_cast< bool*>(_v) = getAddUnits(); break; case 13: *reinterpret_cast< Formats*>(_v) = getFormatProperty(); break; case 14: *reinterpret_cast< uint*>(_v) = getRadix(); break; case 15: *reinterpret_cast< Notations*>(_v) = getNotationProperty(); break; } _id -= 16; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setVariableNameProperty(*reinterpret_cast< QString*>(_v)); break; case 1: setVariableNameSubstitutionsProperty(*reinterpret_cast< QString*>(_v)); break; case 2: setWriteOnLoseFocus(*reinterpret_cast< bool*>(_v)); break; case 3: setWriteOnEnter(*reinterpret_cast< bool*>(_v)); break; case 4: setSubscribe(*reinterpret_cast< bool*>(_v)); break; case 5: setVariableAsToolTip(*reinterpret_cast< bool*>(_v)); break; case 6: setEnabled(*reinterpret_cast< bool*>(_v)); break; case 7: setConfirmWrite(*reinterpret_cast< bool*>(_v)); break; case 8: setPrecision(*reinterpret_cast< uint*>(_v)); break; case 9: setUseDbPrecision(*reinterpret_cast< bool*>(_v)); break; case 10: setLeadingZero(*reinterpret_cast< bool*>(_v)); break; case 11: setTrailingZeros(*reinterpret_cast< bool*>(_v)); break; case 12: setAddUnits(*reinterpret_cast< bool*>(_v)); break; case 13: setFormatProperty(*reinterpret_cast< Formats*>(_v)); break; case 14: setRadix(*reinterpret_cast< uint*>(_v)); break; case 15: setNotationProperty(*reinterpret_cast< Notations*>(_v)); break; } _id -= 16; } else if (_c == QMetaObject::ResetProperty) { _id -= 16; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 16; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 16; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 16; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 16; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 16; } #endif // QT_NO_PROPERTIES return _id; }