void test1() { initDataHeader(); Data *d1 = (Data*)malloc(sizeof(Data)); d1->next = NULL; addData(d1); Data *d2 = (Data*)malloc(sizeof(Data)); d2->next = NULL; addData(d2); Data *d3 = (Data*)malloc(sizeof(Data)); d3->next = NULL; addData(d3); Data *d4 = (Data*)malloc(sizeof(Data)); d4->next = NULL; addData(d4); dumpData("After add 4 Data!"); removeData(2); removeData(6); dumpData("Remove 2 Data!"); Data *d = getData(20); printf("Get Data Num = %d\n", d->num); dispose(); }
// Delete a Gltx bool QuasarDB::remove(const Gltx& gltx) { // Can't delete reconciled transaction for (unsigned int i = 0; i < gltx.accounts().size(); ++i) if (!gltx.accounts()[i].cleared.isNull()) return error("Can't delete reconciled transaction"); // Can't delete transaction before close date Company company; lookup(company); if (!company.closeDate().isNull()) { if (gltx.postDate() <= company.closeDate()) return error("Can't delete transaction before close date"); } if (!company.startOfYear().isNull()) { if (gltx.postDate() < company.startOfYear()) return error("Can't delete transaction in last year"); } // Can't delete if in a posted shift if (gltx.shiftId() != INVALID_ID) { Shift shift; lookup(gltx.shiftId(), shift); if (shift.shiftId() != INVALID_ID) return error("Can't delete from a posted shift"); } sqlDeleteLines(gltx); removeData(gltx, "gltx", "gltx_id"); return true; }
void BFS() { int i; //mark first node as visited lstVertices[0]->visited = true; //display the vertex displayVertex(0); //insert vertex index in queue insert(0); int unvisitedVertex; while(!isQueueEmpty()) { //get the unvisited vertex of vertex which is at front of the queue int tempVertex = removeData(); //no adjacent vertex found while((unvisitedVertex = getAdjUnvisitedVertex(tempVertex)) != -1) { lstVertices[unvisitedVertex]->visited = true; displayVertex(unvisitedVertex); insert(unvisitedVertex); } } //queue is empty, search is complete, reset the visited flag for(i = 0;i<vertexCount;i++) { lstVertices[i]->visited = false; } }
void SynctexHandler::loadData(const QString &fileName) { removeData(); m_fileName = fileName; m_synctexScanner = synctex_scanner_new_with_output_file(m_fileName.toUtf8().data(), 0, 1); }
MainWidget::MainWidget(QWidget *parent,const char *name) :QWidget(parent,name) { unsigned schema=0; // // Fix the Window Size // setMinimumWidth(sizeHint().width()); setMaximumWidth(sizeHint().width()); setMinimumHeight(sizeHint().height()); setMaximumHeight(sizeHint().height()); // // Generate Fonts // QFont font("Helvetica",12,QFont::Normal); font.setPixelSize(12); // // Open Database // rd_config=new RDConfig(RD_CONF_FILE); rd_config->load(); QString err; test_db=RDInitDb(&schema,&err); if(!test_db) { QMessageBox::warning(this,"Can't Connect", err,0,1,1); exit(0); } // // Generate Button // QPushButton *button=new QPushButton(this,"generate_button"); button->setGeometry(10,10,sizeHint().width()-20,50); button->setText("Generate Test"); button->setFont(font); connect(button,SIGNAL(clicked()),this,SLOT(generateData())); // // Remove Button // button=new QPushButton(this,"remove_button"); button->setGeometry(10,70,sizeHint().width()-20,50); button->setText("Remove Test"); button->setFont(font); connect(button,SIGNAL(clicked()),this,SLOT(removeData())); // // Exit Button // button=new QPushButton(this,"cancel_button"); button->setGeometry(10,130,sizeHint().width()-20,50); button->setText("Exit"); button->setFont(font); connect(button,SIGNAL(clicked()),this,SLOT(cancelData())); }
void CheckoutModel::removeAllData() { for(int i=m_amount.count();i>=0;i--){ removeData(i); } }
// Delete a Group bool QuasarDB::remove(const Group& group) { if (group.id() == INVALID_ID) return false; if (!removeData(group, "groups", "group_id")) return false; commit(); dataSignal(DataEvent::Delete, group); return true; }
// Delete a Recurring bool QuasarDB::remove(const Recurring& recurring) { if (recurring.id() == INVALID_ID) return false; if (!removeData(recurring, "recurring", "recurring_id")) return false; commit(); dataSignal(DataEvent::Delete, recurring); return true; }
// Delete a user bool QuasarDB::remove(const User& user) { if (user.id() == INVALID_ID) return false; if (!removeData(user, "users", "user_id")) return false; commit(); dataSignal(DataEvent::Delete, user); return true; }
void IMassSpectrum::setTdcConnection(QObject *tdcDataStream) { removeData(); m_msDataStruct = reinterpret_cast<TdcDataStorage*>(tdcDataStream); m_type = TDCSTREAM; m_isDeleteProhibited = true; emit state("Накопление событий..."); emit showMassSpec(qobject_cast<QObject*>(m_msDataStruct)); }
// Delete a Slip bool QuasarDB::remove(const Slip& slip) { if (slip.id() == INVALID_ID) return false; if (!sqlDeleteLines(slip)) return false; if (!removeData(slip, "slip", "slip_id")) return false; commit(); dataSignal(DataEvent::Delete, slip); return true; }
// Delete a Reconcile bool QuasarDB::remove(const Reconcile& reconcile) { if (reconcile.id() == INVALID_ID) return false; if (!sqlDeleteLines(reconcile)) return false; if (!removeData(reconcile, "reconcile", "reconcile_id")) return false; commit(); dataSignal(DataEvent::Delete, reconcile); return true; }
void clearList(LinkedList * theList, void (*removeData)(void *)) { Node *temp ; while ((temp = theList->head) != NULL) { // set curr to head, stop if list empty. theList->head = theList->head->next; // advance head to next element. removeData(temp->data); free (temp); // delete saved pointer. } }
bool CClientList::removeClient( CClientItem *pClientItem ) { if ( NULL == pClientItem ) return false; dllnode *pNode = dll_findNodeFromID( &m_clientList, pClientItem->m_clientID ); removeData( &pClientItem->m_inputQueue ); if ( NULL != pNode ) { dll_removeNode( &m_clientList, pNode ); } return true; }
void QPieModelMapperPrivate::modelColumnsRemoved(QModelIndex parent, int start, int end) { Q_UNUSED(parent); if (m_modelSignalsBlock) return; blockSeriesSignals(); if (m_orientation == Qt::Horizontal) removeData(start, end); else if (start <= m_valuesSection || start <= m_labelsSection) // if the changes affect the map - reinitialize the pie initializePieFromModel(); blockSeriesSignals(false); }
/** datasave : call after data process worker finish @req : the worker **/ void datasave(uv_work_t *req, int status) { cspider_t *cspider = ((cs_rawText_t*)req->data)->cspider; //log logger(0, "%s save finish.\n", ((cs_rawText_t*)req->data)->url, cspider); uv_rwlock_wrlock(cspider->lock); cs_rawText_queue *q = removeData(cspider->data_queue_doing, req->data); PANIC(q); logger(q != NULL, "removeData error in %s.\n", "dataProcess.c", cspider); freeData(q); uv_rwlock_wrunlock(cspider->lock); }
void CheckoutModel::addRawItem(QString id,QString item, int price) { int amt_index; amt_index=searchItemGetQuantity(item); qWarning()<<"amt index "+ amt_index; if(amt_index==-1) { addCheckoutItem(Checkout(id,item,price,1,price)); } else { int quant=m_amount.at(amt_index).get_quantity()+1; addCheckoutItem(Checkout(id,item,quant*price,quant,price)); removeData(amt_index); } }
DvtListSelector::DvtListSelector(QWidget *parent,const char *name) : QHBox(parent,name) { QFont font; // // Generate Font // font=QFont("Helvetica",10,QFont::Bold); font.setPixelSize(10); setSpacing(10); QVBox *source_box=new QVBox(this,"source_box"); list_source_label=new QLabel(source_box,"list_source_label"); list_source_label->setFont(font); list_source_label->setText(tr("Available Services")); list_source_label->setAlignment(AlignCenter); list_source_box=new QListBox(source_box,"list_source_box"); QVBox *button_box=new QVBox(this,"button_box"); list_add_button=new QPushButton(button_box,"list_add_button"); list_add_button->setText(tr("Add >>")); list_add_button->setDisabled(true); connect(list_add_button,SIGNAL(clicked()),this,SLOT(addData())); list_addall_button=new QPushButton(button_box,"list_addall_button"); list_addall_button->setText(tr("Add All >>")); list_addall_button->setDisabled(true); connect(list_addall_button,SIGNAL(clicked()),this,SLOT(addAllData())); list_remove_button=new QPushButton(button_box,"list_remove_button"); list_remove_button->setText(tr("<< Remove")); list_remove_button->setDisabled(true); connect(list_remove_button,SIGNAL(clicked()),this,SLOT(removeData())); list_removeall_button=new QPushButton(button_box,"list_removeall_button"); list_removeall_button->setText(tr("<< Remove All")); list_removeall_button->setDisabled(true); connect(list_removeall_button,SIGNAL(clicked()),this,SLOT(removeAllData())); QVBox *dest_box=new QVBox(this,"dest_box"); list_dest_label=new QLabel(dest_box,"list_dest_label"); list_dest_label->setFont(font); list_dest_label->setText(tr("Active Services")); list_dest_label->setAlignment(AlignCenter); list_dest_box=new QListBox(dest_box,"list_dest_box"); }
void LLScriptHeapRunTime::decreaseRefCount(S32 address) { if (!mBuffer) return; if (!address) { // unused temp string entry return; } // get offset S32 toffset = address; // read past offset (rely on function side effect) bytestream2integer(mBuffer, toffset); // get current reference count S32 count = bytestream2integer(mBuffer, toffset); // see which type it is U8 type = *(mBuffer + toffset); if (type == LSCRIPTTypeByte[LST_STRING]) { count--; if (mbPrint) printf("0x%X dec ref count %d\n", address - mHeapRegister, count); toffset = address + 4; integer2bytestream(mBuffer, toffset, count); if (!count) { // we can blow this one away removeData(address); } } // TO DO: put list stuff here! else { set_fault(mBuffer, LSRF_HEAP_ERROR); } }
void DomainIDataModelImpl::changeDataName(std::string OldDataName, std::string NewDataName) { if (OldDataName == "" || NewDataName == "") return; openfluid::core::UnitsList_t::iterator it; for (it = m_UnitsColl->getList()->begin(); it != m_UnitsColl->getList()->end(); ++it) { openfluid::core::Unit* TheUnit = const_cast<openfluid::core::Unit*> (&(*it)); std::string Value; TheUnit->getInputData()->getValue(OldDataName, Value); TheUnit->getInputData()->setValue(NewDataName, Value); } removeData(OldDataName); }
void IMassSpectrum::loadMassSpec(QString fileName, QString fileFilter) { MassSpecType type = stringToType(fileFilter); switch(type) { case TOFFILE: { removeData(); m_msDataStruct = new TofMacSupport(this); emit state("Загрузка файла " + fileName + " ..."); QApplication::setOverrideCursor(Qt::WaitCursor); reinterpret_cast<TofMacSupport*>(m_msDataStruct)->loadMassSpec(fileName); QApplication::restoreOverrideCursor(); if(m_msDataStruct->isError()) { QMessageBox::information ( qobject_cast<QWidget*>(this), "Oшибка", "Ошибка при загрузке файла!" ); emit state(QString()); return; } m_type = TOFFILE; emit state(QString()); emit showMassSpec(qobject_cast<QObject*>(m_msDataStruct)); return; } default: QMessageBox::information(qobject_cast<QWidget*>(this),"Загрузка нового файла","Неизвестный тип файла"); } }
CRecieveTask_zakazrf_ru::~CRecieveTask_zakazrf_ru() { disconnect(m_signaller, SIGNAL(dataParsed(QUrl)), this, SLOT(removeData(QUrl))); delete m_signaller; for(int i=0; i<m_threads.count(); i++) { disconnect(m_threads.value(i), SIGNAL(dataReady(int/*,QByteArray*/)), this, SLOT(onDataReady(int/*,QByteArray*/))); disconnect(m_threads.value(i), SIGNAL(finished()), this, SLOT(onThreadFinished())); delete m_threads.value(i); } m_threads.clear(); m_activeDataStructures.clear(); QMultiMap<QUrl, CDataStructure*>::iterator dataStructuresIter; for(dataStructuresIter=m_dataStructures.begin(); dataStructuresIter!=m_dataStructures.end(); dataStructuresIter++) { delete dataStructuresIter.value(); } m_dataStructures.clear(); }
/// Remove style node by style name /// This method is a wrapper of removeData() for style nodes. bool removeStyleNode(const LString &name) { LString key = StyleSet::makeStyleKey(name); return removeData(key); }
bool CRecieveTask_zakazrf_ru::run() { qDebug(); // m_signaller->onRecieveFinished(this); // return true; connect(m_signaller, SIGNAL(dataParsed(QUrl)), this, SLOT(removeData(QUrl))); #ifndef RUN_ALL_TASKS QUrl testUrl("http://zakazrf.ru/ViewReduction.aspx?id=4781"); CDataStructure* tmpdata = new CDataStructure(testUrl); tmpdata->setType(getUrlDataType(testUrl)); tmpdata->setRoot(); m_dataStructures.insert(testUrl, tmpdata); m_activeDataStructures.push_back(tmpdata); QUrl testUrl2("http://zakazrf.ru/ViewReduction.aspx?id=2943"); CDataStructure* tmpdata2 = new CDataStructure(testUrl2); tmpdata2->setType(getUrlDataType(testUrl2)); tmpdata2->setRoot(); m_dataStructures.insert(testUrl2, tmpdata2); m_activeDataStructures.push_back(tmpdata2); QUrl testUrl3("http://zakazrf.ru/ViewReduction.aspx?id=5319"); CDataStructure* tmpdata3 = new CDataStructure(testUrl3); tmpdata3->setType(getUrlDataType(testUrl3)); tmpdata3->setRoot(); m_dataStructures.insert(testUrl3, tmpdata3); m_activeDataStructures.push_back(tmpdata3); #else CDownloadManager_zakazrf_ru downloadManager; downloadManager.init(); QUrlList urls=downloadManager.getUrls(); if(urls.isEmpty()) { int min = getConfigurationValue("zakazrf/min_id",1).toUInt(); int max = getConfigurationValue("zakazrf/max_id",10000).toUInt(); if (max < min) { int tmp = max; max = min; min = tmp; } for(int i = min; i < max; i++) { QUrl testUrl(QString("http://zakazrf.ru/ViewReduction.aspx?id=%1").arg(i)); CDataStructure* tmpdata = new CDataStructure(testUrl); tmpdata->setType(getUrlDataType(testUrl)); tmpdata->setRoot(); m_dataStructures.insert(testUrl, tmpdata); m_activeDataStructures.push_back(tmpdata); } } else { for(int i=0; i<urls.count();i++) { CDataStructure* tmpdata = new CDataStructure(urls.at(i)); tmpdata->setType(getUrlDataType(urls.at(i))); tmpdata->setRoot(); m_dataStructures.insert(urls.at(i), tmpdata); m_activeDataStructures.push_back(tmpdata); } } #endif CDataStructure* data=NULL; QList<CDataStructure*>::iterator activeDataStructuresIter; for(activeDataStructuresIter = m_activeDataStructures.begin(); activeDataStructuresIter != m_activeDataStructures.end();) { if(m_threads.count()<(m_maxThreads+1)) { data=(*activeDataStructuresIter); CReciveThread *thread=new CReciveThread(data->url(), m_threadCounter++); thread->setDataStructure(data); m_threads.push_back(thread); connect(thread, SIGNAL(dataReady(int/*,QByteArray*/)), this, SLOT(onDataReady(int/*,QByteArray*/))); connect(thread, SIGNAL(finished()), this, SLOT(onThreadFinished())); thread->start(); activeDataStructuresIter=m_activeDataStructures.erase(activeDataStructuresIter); break; } break; }
void Keyboard::keyPressEvent(QKeyEvent *ev) { bool keepAnchor = ev->modifiers() & Qt::SHIFT ? true : false; Cursor &cursor = view_->cursor(); HexConfig &config = view_->config(); switch (ev->key()) { case Qt::Key_Home: cursor.setNibble(true); view_->cursor().movePosition(view_, 0, keepAnchor, false); break; case Qt::Key_End: cursor.setNibble(true); view_->cursor().movePosition(view_, document_->length(), keepAnchor, false); break; case Qt::Key_Left: cursor.setNibble(true); view_->moveRelativePosition(-1, keepAnchor, false); break; case Qt::Key_Right: cursor.setNibble(true); view_->moveRelativePosition(1, keepAnchor, false); break; case Qt::Key_Up: cursor.setNibble(true); view_->moveRelativePosition((qint64)-1 * config.getNum(), keepAnchor, false); break; case Qt::Key_Down: cursor.setNibble(true); view_->moveRelativePosition((qint64)config.getNum(), keepAnchor, false); break; case Qt::Key_PageUp: cursor.setNibble(true); view_->moveRelativePosition((qint64)-1 * config.getNum() * 15, keepAnchor, true); break; case Qt::Key_PageDown: cursor.setNibble(true); view_->moveRelativePosition((qint64)config.getNum() * 15, keepAnchor, true); break; case Qt::Key_Backspace: if (cursor.hasSelection()) { const quint64 pos = qMin(cursor.position(), cursor.anchor()); const quint64 len = qMax(cursor.position(), cursor.anchor()) - pos; removeData(pos, len); view_->moveRelativePosition(pos, false, false); cursor.setNibble(true); } else if (0 < cursor.position()) { removeData(cursor.position() - 1, 1); view_->moveRelativePosition(-1, false, false); cursor.setNibble(true); } break; case Qt::Key_Insert: qDebug("key insert"); cursor.reverseInsert(); break; case Qt::Key_Delete: if (cursor.hasSelection()) { const quint64 pos = qMin(cursor.position(), cursor.anchor()); const quint64 len = qMax(cursor.position(), cursor.anchor()) - pos; removeData(pos, len); view_->moveRelativePosition(0, false, false); cursor.setNibble(true); } else if (cursor.position() < document_->length()) { removeData(cursor.position(), 1); view_->moveRelativePosition(0, false, false); cursor.setNibble(true); } break; default: { QString text = ev->text(); qDebug() << "hoge"; for (int i = 0; i < text.length(); i++) { keyInputEvent(text.at(i)); } } } }
int main() { /* insert 5 items */ insert(3); insert(5); insert(9); insert(1); insert(12); // front : 0 // rear : 4 // ------------------ // index : 0 1 2 3 4 // ------------------ // queue : 3 5 9 1 12 insert(15); // front : 0 // rear : 5 // --------------------- // index : 0 1 2 3 4 5 // --------------------- // queue : 3 5 9 1 12 15 if(isFull()){ printf("Queue is full!\n"); } // remove one item int num = removeData(); printf("Element removed: %d\n",num); // front : 1 // rear : 5 // ------------------- // index : 1 2 3 4 5 // ------------------- // queue : 5 9 1 12 15 // insert more items insert(16); // front : 1 // rear : -1 // ---------------------- // index : 0 1 2 3 4 5 // ---------------------- // queue : 16 5 9 1 12 15 // As queue is full, elements will not be inserted. insert(17); insert(18); // ---------------------- // index : 0 1 2 3 4 5 // ---------------------- // queue : 16 5 9 1 12 15 printf("Element at front: %d\n",peek()); printf("----------------------\n"); printf("index : 5 4 3 2 1 0\n"); printf("----------------------\n"); printf("Queue: "); while ( !isEmpty() ) { int n = removeData(); printf("%d ",n); } printf("\n"); }
GlassWidget::GlassWidget(const QString &instance_name,QWidget *parent) : QFrame(parent) { gw_process=NULL; gw_auto_start=false; setFrameStyle(QFrame::Box|QFrame::Raised); setMidLineWidth(2); // // Fonts // QFont bold_font(font().family(),font().pointSize(),QFont::Bold); // // Dialogs // gw_server_dialog=new ServerDialog(this); gw_codec_dialog=new CodecDialog(this); gw_source_dialog=new SourceDialog(this); connect(gw_source_dialog,SIGNAL(updated()),this,SLOT(checkArgs())); gw_stream_dialog=new StreamDialog(this); gw_config_dialog=new ConfigDialog(instance_name,gw_server_dialog, gw_codec_dialog,gw_stream_dialog, gw_source_dialog,this); connect(gw_server_dialog,SIGNAL(typeChanged(Connector::ServerType,bool)), this,SLOT(serverTypeChangedData(Connector::ServerType,bool))); connect(gw_server_dialog,SIGNAL(settingsChanged()),this,SLOT(checkArgs())); for(int i=0; i<2; i++) { gw_meters[i]=new PlayMeter(SegMeter::Right,this); gw_meters[i]->setRange(-3000,0); gw_meters[i]->setHighThreshold(-800); gw_meters[i]->setClipThreshold(-100); gw_meters[i]->setMode(SegMeter::Peak); } gw_meters[0]->setLabel(tr("L")); gw_meters[1]->setLabel(tr("R")); gw_status_frame_widget=new QLabel(this); gw_status_frame_widget->setFrameStyle(QFrame::Box|QFrame::Raised); gw_status_widget=new StatusWidget(this); gw_name_label=new QLabel(instance_name,this); gw_name_label->setAlignment(Qt::AlignLeft|Qt::AlignVCenter); gw_name_label->setFont(bold_font); gw_message_widget=new MessageWidget(this); gw_message_widget->setAlignment(Qt::AlignLeft|Qt::AlignVCenter); gw_start_button=new QPushButton(tr("Start"),this); gw_start_button->setFont(bold_font); connect(gw_start_button,SIGNAL(clicked()),this,SLOT(startEncodingData())); gw_config_button=new QPushButton(tr("Settings"),this); gw_config_button->setFont(bold_font); connect(gw_config_button,SIGNAL(clicked()),this,SLOT(configData())); gw_insert_button=new QPushButton(tr("Insert"),this); gw_insert_button->setFont(bold_font); gw_insert_button->setStyleSheet("background-color: yellow"); connect(gw_insert_button,SIGNAL(clicked()),this,SLOT(insertData())); gw_insert_button->hide(); gw_remove_button=new QPushButton(tr("Remove"),this); gw_remove_button->setFont(bold_font); gw_remove_button->setStyleSheet("background-color: violet"); connect(gw_remove_button,SIGNAL(clicked()),this,SLOT(removeData())); gw_remove_button->hide(); // // Kill Timer // gw_kill_timer=new QTimer(this); gw_kill_timer->setSingleShot(true); connect(gw_kill_timer,SIGNAL(timeout()),this,SLOT(killData())); }
void Item::removeData(const std::string &fieldName) { int index = indexOf(fieldName); removeData(index); }
IMassSpectrum::~IMassSpectrum() { removeData(); }
void PHIEllipseItem::squeeze() { PHIAbstractShapeItem::squeeze(); removeData( DStartAngle ); removeData( DSpanAngle ); }