static INLINE void destructPair(CRDS *crds, PAIR *target) { PQUE *p_que = crds->p_que[target->pcode]; uint h = hash_val(p_que->h_num, target->left, target->right); PAIR *p = p_que->h_entry[h]; PAIR *q = NULL; removePair(crds, target); while (p != NULL) { if (p->pcode == target->pcode && p->left == target->left && p->right == target->right) { break; } q = p; p = p->h_next; } if (q == NULL) { p_que->h_entry[h] = p->h_next; } else { q->h_next = p->h_next; } free(target); p_que->num_pairs--; }
void GridLayoutItem::removeItemView(int index) { if( m_listController ) { // Remove Item if(QGraphicsObject * itemViewToRemove = viewFromGridPos(gridPos(index))) { prepareGeometryChange(); removePair(itemViewToRemove); itemViewToRemove->deleteLater(); // Move Everything after index back one grid position for( int i = index + 1; i < m_listController->count() + 1; i++ ) { std::pair<int,int> oldPos = gridPos(i); QGraphicsObject * item = viewFromGridPos(oldPos); OS_ASSERT(item); std::pair<int,int> newPos = gridPos(i - 1); setItemViewGridPos(item,newPos); } } if( QGraphicsScene * _scene = scene() ) { _scene->setSceneRect(boundingRect()); } } }
void CProxy::slotDisconnected() { QLOG_INFO() << "disconnected"; QTcpSocket * s = qobject_cast<QTcpSocket *>( sender() ); if ( s ) removePair( s ); }
BanPairDialog::BanPairDialog(QWidget *parent) : QDialog(parent) { setWindowTitle(tr("Ban pair table")); list = new QListWidget; foreach(BanPair pair, BanPairSet) addPairToList(pair); QPushButton *add_button = new QPushButton(tr("Add")); QPushButton *remove_button = new QPushButton(tr("Remove")); QPushButton *save_button = new QPushButton(tr("Save")); QHBoxLayout *hlayout = new QHBoxLayout; hlayout->addStretch(); hlayout->addWidget(add_button); hlayout->addWidget(remove_button); hlayout->addWidget(save_button); connect(add_button, SIGNAL(clicked()), this, SLOT(addPair())); connect(remove_button, SIGNAL(clicked()), this, SLOT(removePair())); connect(save_button, SIGNAL(clicked()), this, SLOT(save())); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(list); layout->addLayout(hlayout); setLayout(layout); }
int main(int argc, char **argv) { MAP* map = newMap(); char *strFrank = "frank"; char *strJef = "jef"; char *strDirk = "dirk"; put(map, strFrank, "0486/11.33.23"); put(map, strJef, "0486/10.20.30"); put(map, strDirk, "0475/11.39.12"); printMap(map); printf("Nummer van frank: %s\n",get(map, strFrank)); printf("Jef verwijderen...\n"); removePair(map, strJef); removePair(map, "bla"); printMap(map); freeMemory(map); return 0; }
void deletePair(char* key, hashTable* hTable) { hTable->loadFactor = removePair(key, hTable->table, hTable->tableSize, hTable->loadFactor); if(hTable->loadFactor < hTable->minLoad && hTable->tableSize > 1) { hTable->table = halveSize(hTable->table, hTable->tableSize, hTable->loadFactor); hTable->loadFactor = hTable->loadFactor * 2; hTable->tableSize = hTable->tableSize / 2; } }
void TensegrityModel::addNodeEdgePairs(tgStructure& structure, const std::string& tags, const Yam& pairs, const std::string* childStructure1Name, const std::string* childStructure2Name, tgBuildSpec& spec) { if (pairs.size() < 3) { throw std::invalid_argument("Error: node_edge bonds must specify at least 3 node_edge pairs"); } tgStructure& childStructure1 = structure.findChild(*childStructure1Name); tgStructure& childStructure2 = structure.findChild(*childStructure2Name); // these are used for transformations std::vector<btVector3> structure1RefNodes; std::vector<btVector3> structure2RefNodes; // these are nodes std::vector<tgNode*> ligands; // these are edges std::vector< std::pair<tgNode*, tgNode*> > receptors; // populate refNodes arrays, ligands and receptors parseNodeEdgePairs(childStructure1, childStructure2, structure1RefNodes, structure2RefNodes, ligands, receptors, pairs); rotateAndTranslate(childStructure2, structure1RefNodes, structure2RefNodes); std::vector<tgBuildSpec::RigidAgent*> rigidAgents = spec.getRigidAgents(); for (unsigned int i = 0; i < ligands.size(); i++) { // remove old edge connections // try removing from both children since we are not sure which child the pair belongs to // (could add more information to receptors array so we don't have to do this) removePair(childStructure1, receptors[i].first, receptors[i].second, true, rigidAgents, spec); removePair(childStructure2, receptors[i].first, receptors[i].second, true, rigidAgents, spec); for (unsigned int j = 0; j < ligands.size(); j++) { // remove old string connections between nodes/ligands // try removing from both children since we are not sure which child the node belongs to removePair(childStructure1, ligands[i], ligands[j], false, rigidAgents, spec); removePair(childStructure2, ligands[i], ligands[j], false, rigidAgents, spec); } // make new connection from edge -> node -> edge structure.addPair(*(receptors[i].first), *ligands[i], tags); structure.addPair(*ligands[i], *(receptors[i].second), tags); } }
static INLINE void incrementPair(CRDS *crds, PAIR *target) { PQUE *p_que = crds->p_que[target->pcode]; if (target->freq >= p_que->p_max) { target->freq++; return; } removePair(crds, target); target->freq++; insertPair(crds, target); }
static INLINE void decrementPair(CRDS *crds, PAIR *target) { PQUE *p_que = crds->p_que[target->pcode]; if (target->freq > p_que->p_max) { target->freq--; return; } if (target->freq == 1) { //destructPair(crds, target); } else { removePair(crds, target); target->freq--; insertPair(crds, target); } }
void Talon::play() { std::cout<<"\n--- Willkommen zum diesjärigen cgp- Kartenspiel! ---\n" "Das Ziel dieses Spiels ist es, alle Karten auf der Hand abzulegen.\n" "Sie können Karten nur in Paaren ablegen - " "haben sie nur einzelne Karten, müssen sie zusätzliche Karten abheben.\n" "Viel Spaß!\n\n"; AskingMenu::MenuItem::item_id_t menu_choice; do { bool pair_existed; Card::card_id_t card_id; std::cout<<"Ihre Hand: \n"; showCards(); menu_choice = _game_menu.ask(); switch(menu_choice) { case MENU_DRAW: // draw new card _cardlist.push_back(Card()); break; case MENU_DISCARD: std::cout<<"Welche Karte möchten sie ablegen? "; card_id = AskingMenu::getChoice(); // check validity of card id if (card_id== Card::card_id_t(-1) || card_id > Card::_num_cards) { std::cout<<"Ungültige Auswahl\n"; continue; } // remove card, check that it really existed pair_existed = removePair(card_id); if(!pair_existed) { std::cout<<"Sie haben kein Paar der Karte "<< Card(card_id)<<" auf der Hand!\n"; } else { std::cout<<"Karte "<<Card(card_id)<<" abgelegt.\n"; } break; case MENU_QUIT: // quit game std::cout<<"Spiel Beendet\n"; return; default: ;// invalid menu choice, do nothing and repeat question } std::cout<<std::endl; if (_cardlist.empty()) std::cout<<"Sie haben gewonnen! Gratulation!\n"; } while(!_cardlist.empty()); }