bool validateBinding(EShLanguage /*stage*/, const char* /*name*/, const glslang::TType& type, bool /*is_live*/) override { if (type.getQualifier().hasBinding()) { int set; if (type.getQualifier().hasSet()) set = type.getQualifier().layoutSet; else set = 0; if (type.getBasicType() == glslang::EbtSampler) { const glslang::TSampler& sampler = type.getSampler(); if (sampler.isPureSampler()) return checkEmpty(set, baseSamplerBinding + type.getQualifier().layoutBinding); if (sampler.isTexture()) return checkEmpty(set, baseTextureBinding + type.getQualifier().layoutBinding); } if (type.getQualifier().storage == EvqUniform) return checkEmpty(set, baseUboBinding + type.getQualifier().layoutBinding); if (type.getQualifier().storage == EvqBuffer) return checkEmpty(set, baseSsboBinding + type.getQualifier().layoutBinding); } return true; }
void states::bishopMoves(int x, int y, move *moves, int &movesIndex, char color){ checkDiag(x, y, moves, movesIndex, multiple, color); if(inBounds(x-1, y) && checkEmpty(x-1, y,color) == 0) scan(x, y, moves, movesIndex, -1, 0, single, color); //north if(inBounds(x+1, y) && checkEmpty(x+1, y, color) == 0) scan(x, y, moves, movesIndex, 1, 0, single, color); //south if(inBounds(x, y+1) && checkEmpty(x, y+1, color) == 0) scan(x, y, moves, movesIndex, 0, 1, single, color); //east if(inBounds(x, y-1) && checkEmpty(x, y-1, color) == 0) scan(x, y, moves, movesIndex, 0, -1, single, color); //west }
bool TabWidget::closeTab(int index) { if(index < 0 || m_tab_ids.size() <= (uint)index) { Q_ASSERT(false); return false; } quint32 id = m_tab_ids[index]; Tab *tab = dynamic_cast<Tab*>(widget(index)); if(!tab) { Q_ASSERT(false); return false; } if(!tab->onTabClose()) return false; if(id & IDMASK_CHILD) { sWorkTabMgr.removeChildTab((ChildTab*)tab); } else { disconnect((WorkTab*)tab, SIGNAL(statusBarMsg(QString,int)), this, SIGNAL(statusBarMsg(QString,int))); sWorkTabMgr.removeTab((WorkTab*)tab); } changeMenu(currentIndex()); checkEmpty(); return true; }
void Tooltip::redoLayout() { checkEmpty(); if (_empty) return; if (_font.empty()) _font = getFontName(); Graphics::Aurora::FontHandle font = FontMan.get(_font); _lineHeight = font.getFont().getHeight(); _lineSpacing = font.getFont().getLineSpacing(); for (std::vector<Line>::iterator l = _lines.begin(); l != _lines.end(); ++l) { if (l->text) continue; l->text = new Graphics::Aurora::Text(font, l->line, l->r, l->g, l->b, l->a); l->text->setTag("Tooltip#Text"); } float width, height; getSize(width, height); if ((_width != width) || (_height != height)) { _width = width; _height = height; redoBubble(); } updatePosition(); }
void states::scan(int x, int y, move *moves, int &movesIndex, int dx, int dy, int movement, char color){ int toX = x; int toY = y; while(inBounds(toX + dx, toY + dy)){ //if square is empty 0 or contains opponent 1 int CE = checkEmpty(toX + dx, toY + dy,color); if(CE == 0 || CE == 1 ){ moves[movesIndex].fromSquare.x = x; // new move(x, y, toX + dx, toY + dy); moves[movesIndex].fromSquare.y = y; moves[movesIndex].toSquare.x = toX + dx; moves[movesIndex].toSquare.y = toY + dy; if(CE == 1 || movement == single){ ++movesIndex; break; } else{ toX = toX + dx; toY = toY + dy; ++movesIndex; } } else{ //self is on the square break; } } }
int TabWidget::addTab(Tab *widget, const QString &name, quint32 tabId) { if(!widget->isHometab()) emit closeHomeTab(); int idx = QTabWidget::addTab(widget, name); installEventFilterToChildren(widget); std::vector<quint32>::iterator itr = m_tab_ids.begin() + idx; m_tab_ids.insert(itr, tabId); setCurrentIndex(idx); changeMenu(idx); if(count() >= 2) m_tab_bar->enableSplit(true); if(widget->isWorkTab()) { connect(widget, SIGNAL(statusBarMsg(QString,int)), SIGNAL(statusBarMsg(QString,int))); connect(widget, SIGNAL(setConnId(QString,bool)), SLOT(setConnString(QString,bool))); } else if(widget->isChild()) connect((ChildTab*)widget, SIGNAL(tabText(QString)), SLOT(setTabNameAndTooltip(QString))); connect(widget, SIGNAL(activateMe()), SLOT(activateTab())); connect(widget, SIGNAL(destroyed()), SLOT(checkEmpty()), Qt::QueuedConnection); setTabNameAndTooltip(idx, name); setTabsClosable(true); return idx; }
/** * Remove with value from the linkList * first occurence will be deleted * Modification possible: delete all occurences of value */ data *popwithValue(dlinklist *ll,float value) { if(!checkEmpty(ll)) return NULL; node *temp; for(temp= ll->head; temp != NULL; temp=temp->next) { if(temp->dataPtr->val == value) { //pop here and return; temp->prev->next = temp->next; temp->next->prev = temp->prev; #if DEBUG printf(">>==============Node pop'd with value : %f ================<<\n",value); #endif data *returndata = createData(temp->dataPtr->val); free(temp->dataPtr); free(temp); // Modification : if delete all occurences then, // comment below return and update, // temp = prev->next // also change the return type to void, as we need to // delete all occurences of value we cant return one return returndata; } } return NULL; }
int main(void) { stack my_stack; /* A stack */ int nums[10]; nums[0]=2; nums[1]=4; nums[2]=8; stackInit(&my_stack, 10); int i; for (i=0;i<3;i++) { push(&my_stack, nums[i]); } printf("\nPopped numbers are: "); while (!checkEmpty(&my_stack)) { printf("%d\n", pop(&my_stack)); } printf("\n"); stackDestroy(&my_stack); return 0; }
void Tooltip::redoLayout() { checkEmpty(); if (_empty) return; if (_font.empty()) _font = getFontName(); Graphics::Aurora::FontHandle font = FontMan.get(_font); _lineHeight = font.getFont().getHeight(); _lineSpacing = font.getFont().getLineSpacing(); float width, height; getSize(width, height); if ((_width != width) || (_height != height)) { _width = width; _height = height; redoBubble(); } updatePosition(); }
/** * Remove from position i of the linkList */ void popatPosition(dlinklist *ll,int position) { if(!checkEmpty(ll)) return; int length = listSize(ll); if(position > length) { printf("You entered the position out of the bound!\n"); return; } node *temp; int i = 1; if(position == 1) { //pop here - popFront and return; popFront(ll); } else if(position == length) { //pop here - popBack and return; popBack(ll); } for(temp= ll->head; temp != NULL; temp=temp->next) { if(i == position) { //pop here and return; temp->prev->next = temp->next; temp->next->prev = temp->prev; #if DEBUG printf(">>==============Node pop'd at position %d ================<<\n",position); #endif free(temp->dataPtr); free(temp); return; } i++; } }
//WHAT THE HELL?? void states::wPawnMoves(int x, int y, move *moves, int &movesIndex){ if(inBounds(x-1, y) && checkEmpty(x-1, y,'W') == 0){ scan(x, y, moves, movesIndex, -1, 0, single, 'W'); //north } //check for diagonal attack NW NE pawnAttacks(x, y, moves, movesIndex, -1, -1, 'W'); pawnAttacks(x, y, moves, movesIndex, -1, 1, 'W'); }
void states::bPawnMoves(int x, int y, move *moves, int &movesIndex){ if(inBounds(x+1, y) && checkEmpty(x+1, y,'B') == 0){ scan(x, y, moves, movesIndex, 1, 0, single, 'B'); //south } //check for diagonal attack SW SE pawnAttacks(x, y, moves, movesIndex, 1, -1, 'B'); pawnAttacks(x, y, moves, movesIndex, 1, 1, 'B'); }
stackElementT pop(stack *stackP) { if (checkEmpty(stackP)) { fprintf(stderr, "Can't pop element from stack: stack is empty.\n"); exit(1); /* Exit, returning error code. */ } // this time, the value of top gets used as the index BEFORE it is decremented return stackP->contents[stackP->top--]; }
void Game::newFood(int id) { foods[id].x = rand()%map.getWidth(); foods[id].y = rand()%map.getHeight(); while(!checkEmpty(foods[id])) { foods[id].x = rand()%map.getWidth(); foods[id].y = rand()%map.getHeight(); } }
/*** * count the number of elements in the dlinklist and return the count */ int listSize(dlinklist *ll) { if(!checkEmpty(ll)) return 0; node *temp = ll->head; int size = 0; while(temp != NULL) { size++; temp = temp->next; } return size; }
void TabWidget::removeChildTab(ChildTab *widget) { int idx = indexOf(widget); if(idx == -1) return; removeTab(idx); changeMenu(currentIndex()); checkEmpty(); }
List<T> &List<T>::operator = (const List<T> &source) { while (!checkEmpty()) pop(); Node<T> *counter=source.head; while (counter!=NULL) { push(counter->nodeElem); counter=counter->nextNode; } return *this; }
void Segment::setElement(int track, Element* el) { if (el) { el->setParent(this); _elist[track] = el; empty = false; } else { _elist[track] = 0; checkEmpty(); } }
void states::pawnAttacks(int x, int y, move *moves, int &movesIndex, int dx, int dy, char color){ if(inBounds(x + dx, y + dy)){ //if square contains opponent if(checkEmpty(x + dx, y + dy,color) == 1 ){ //moves[movesIndex] = new move(x, y, x + dx, y + dy); moves[movesIndex].fromSquare.x = x; // new move(x, y, toX + dx, toY + dy); moves[movesIndex].fromSquare.y = y; moves[movesIndex].toSquare.x = x + dx; moves[movesIndex].toSquare.y = y + dy; ++movesIndex; } } }
/*** * free all memory in the dlinklist */ void cleanList(dlinklist *ll) { if(!checkEmpty(ll)) return; node *temp = ll->head; while(temp != NULL) { free(temp->dataPtr); node *tempnext = temp->next; free(temp); temp = tempnext; } free(ll); #if DEBUG printf(">>==============stack memory cleaned ================<<\n"); #endif }
/*** * print values in the data structures in the dlinklist */ void printList(dlinklist *ll) { if(!checkEmpty(ll)) return; node *temp = ll->head; #if DEBUG printf(">>==============Printing stack from bottom to top================<<\n"); #endif while(temp != NULL) { printf("%f\n",temp->dataPtr->val); temp = temp->next; } #if DEBUG printf(">>==============Printing stack finished================<<\n"); #endif }
void List<T>::popHead() { Node<T> *newNode; if (checkEmpty()) { throw listExc(1, __LINE__); } else { newNode=head->nextNode; newNode->prevNode=NULL; delete head; head=newNode; } length--; }
void List<T>::pop() { Node<T> *newNode; if (checkEmpty()) { throw listExc(1, __LINE__); } else { newNode=tail->prevNode; newNode->nextNode=NULL; delete tail; tail=newNode; } length--; }
SysStatus FCMDefault::giveBack(PM::MemLevelState memLevelState) { SysStatus rc; uval numPagesStart; if (!pageable) { return _SRETUVAL(PageAllocatorKernPinned::PINNED); } // we sweep through the pagelist collecting up to listSize pages to // writeback, release locks do write, and start again if there is // more left lock.acquire(); numPagesStart = pageList.getNumPagesFree(); switch(memLevelState) { case PM::HIGH: rc = 0; // no pages needed numPagesStart = 0; // no need to checkEmpty break; case PM::MID: rc = locked_giveBack(numPagesStart/4 + 1); break; case PM::LOW: rc = locked_giveBack(numPagesStart/2 + 1); break; case PM::CRITICAL: locked_pageScan(memLevelState); rc = locked_giveBack(numPagesStart); break; default: passertMsg(0, "Bogus memLevelState %ld in giveBack\n", uval(memLevelState)); rc = -1; } locked_pageScan(memLevelState); lock.release(); if (numPagesStart > 0) { /* Only checkEmpty if we had frames, since we * don't want to repeatedly signal a transition to * empty when nothing happened. */ checkEmpty(); } return rc; }
int sem_init(int start_val) { int init = -1; if(checkEmpty(&sem_stack)){ init = vector_add(&sem_list, &start_val); } else{ // use top stack value init = pop(&sem_stack); vector_set(&sem_list, init, &start_val); } return init; // I'm not sure where we should return the ENOMEM error val.. // ..probably in the vector.c file }
void List<T>::insert(iterator &pos, const T &elem) { if ((checkEmpty()) || (pos.currentNode==NULL)) { throw listExc(1, __LINE__); } else { if (pos.currentNode->prevNode==NULL) { try { Node<T> *newNode=new Node<T>(elem); newNode->prevNode=NULL; newNode->nextNode=pos.currentNode; pos.currentNode->prevNode=newNode; } catch (exception &all) { throw listExc(3, __LINE__); } } else { try { Node<T> *newNode=new Node<T>(elem); pos.currentNode->prevNode->nextNode=newNode; newNode->prevNode=pos.currentNode->prevNode; newNode->nextNode=pos.currentNode; pos.currentNode->prevNode=newNode; pos.currentNode=newNode; //Why, oh god why } catch (exception &all) { throw listExc(3, __LINE__); } } } length++; }
/*** * reverse the elements of the dlinklist */ void reverseList(dlinklist *ll) { if(!checkEmpty(ll)) return; node *next; node *temphead = ll->head; while (temphead != NULL) { next = temphead->next; if(temphead->prev == NULL) ll->tail = temphead; if(next == NULL) ll->head = temphead; temphead->next = temphead->prev; temphead->prev = next; temphead = next; } #if DEBUG printf(">>==============stack reversed ================<<\n"); #endif }
void MediaSet::releasePointer (MediaObjectImpl *mediaObject) { std::unique_lock <std::recursive_mutex> lock (recMutex); std::string id = mediaObject->getId(); objectsMap.erase (id ); post (std::bind (async_delete, mediaObject, id) ); if (this->serverManager && !terminated) { serverManager->signalObjectDestroyed (ObjectDestroyed (this->serverManager, id) ); } lock.unlock(); checkEmpty(); }
Encode_Status VaapiEncoderBase::getOutput(VideoEncOutputBuffer * outBuffer, bool withWait) { bool isEmpty; PicturePtr picture; Encode_Status ret; FUNC_ENTER(); ret = checkEmpty(outBuffer, &isEmpty); if (isEmpty) return ret; getPicture(picture); ret = picture->getOutput(outBuffer); if (ret != ENCODE_SUCCESS) return ret; checkCodecData(outBuffer); return ENCODE_SUCCESS; }
void List<T>::erase(iterator &pos) { // ... -- el1 -- el2 -- el3 -- ... //Deleting el2 if ((checkEmpty()) || (pos.currentNode==NULL)) { throw listExc(1, __LINE__); } else { Node<T> *newNode=pos.currentNode; if (pos.currentNode->prevNode==NULL) { //cout << "deleting head" << endl; popHead(); length++; //++pos; //delete newNode; } else if (pos.currentNode->nextNode==NULL) { //cout << "deleting tail" << endl; pop(); length++; //--pos; //delete newNode; } else { //cout << "deleting in body" << endl; pos.currentNode->prevNode->nextNode=newNode->nextNode; // el2 el1 ->el2 = el2 ->el3 //el1->next = el3 newNode->nextNode->prevNode=pos.currentNode->prevNode; // el2 el3 ->el2 el2 ->el1 //el3->prev = el1 pos.currentNode=pos.currentNode->prevNode; delete newNode; } } length--; }