void TabList::logic() { if (locked) return; if (scrolltype == VERTICAL || scrolltype == TWO_DIRECTIONS) { if (inpt->pressing[DOWN] && !inpt->lock[DOWN]) { inpt->lock[DOWN] = true; getNext(); } else if (inpt->pressing[UP] && !inpt->lock[UP]) { inpt->lock[UP] = true; getPrev(); } } if (scrolltype == HORIZONTAL || scrolltype == TWO_DIRECTIONS) { if (inpt->pressing[MV_LEFT] && !inpt->lock[MV_LEFT]) { inpt->lock[MV_LEFT] = true; getPrev(false); } else if (inpt->pressing[MV_RIGHT] && !inpt->lock[MV_RIGHT]) { inpt->lock[MV_RIGHT] = true; getNext(false); } } if (inpt->pressing[ACTIVATE] && !inpt->lock[ACTIVATE]) { inpt->lock[ACTIVATE] = true; deactivatePrevious(); //Deactivate previously activated item activate(); // Activate the currently infocus item } // If mouse is clicked, defocus current tabindex item if (inpt->pressing[MAIN1] && !inpt->lock[MAIN1]) { defocus(); } }
Track *TrackList::GetPrev(Track * t, bool linked) const { if (t) { TrackNodePointer prev; auto node = t->GetNode(); if ( !isNull( node ) ) { // linked is true and input track second in team? if (linked) { prev = getPrev( node ); if( !isNull( prev ) && !t->GetLinked() && t->GetLink() ) // Make it the first node = prev; } prev = getPrev( node ); if ( !isNull( prev ) ) { // Back up once node = prev; // Back up twice sometimes when linked is true if (linked) { prev = getPrev( node ); if( !isNull( prev ) && !(*node.first)->GetLinked() && (*node.first)->GetLink() ) node = prev; } return node.first->get(); } } } return nullptr; }
auto_ptr<SnapshotDelta> Snapshots::computeDelta( int numBack ) { scoped_lock lk(_lock); auto_ptr<SnapshotDelta> p; if ( numBack < numDeltas() ) p.reset( new SnapshotDelta( getPrev(numBack+1) , getPrev(numBack) ) ); return p; }
bool fl_EmbedLayout::doclistener_deleteStrux(const PX_ChangeRecord_Strux * pcrx) { UT_ASSERT(pcrx->getType()==PX_ChangeRecord::PXT_DeleteStrux); // // Remove all remaining structures // if(getPrev()) { getPrev()->setNeedsReformat(getPrev()); } collapse(); // UT_ASSERT(pcrx->getStruxType()== PTX_SectionFootnote); // // Find the block that contains this layout. // PT_DocPosition prevPos = pcrx->getPosition(); fl_BlockLayout * pEncBlock = m_pLayout->findBlockAtPosition(prevPos); // // Fix the offsets for the block // m_bHasEndFootnote = false; pEncBlock->updateOffsets(prevPos,0,-getOldSize()); getSectionLayout()->remove(this); delete this; // TODO whoa! this construct is VERY dangerous. return true; }
ATOM_OctreeNode *ATOM_OctreeNodeChunk::getOrCreateNodeChain (ATOM_OctreeNode::NodeIndex index) { ATOM_OctreeNode *node = getOrCreateNode (index); if (getPrev ()) { getPrev()->getOrCreateNodeChain (getParentIndex (index)); } return node; }
/*delete_freelist Remove the allocated block pointer from its assigned segregated free list */ void delete_freelist (void *bp){ int index = getlist_index(GET_SIZE(HDRP(bp))); if (getPrev(bp) != NULL) setNext(getPrev(bp),getNext(bp)); else free_listp[index] = getNext(bp); if (getNext(bp) != NULL) setPrev(getNext(bp), getPrev(bp)); return; }
void Snapshots::outputLockInfoHTML( stringstream& ss ) { scoped_lock lk(_lock); ss << "\n<div>"; for ( int i=0; i<numDeltas(); i++ ) { SnapshotDelta d( getPrev(i+1) , getPrev(i) ); unsigned e = (unsigned) d.elapsed() / 1000; ss << (unsigned)(100*d.percentWriteLocked()); if( e < 3900 || e > 4100 ) ss << '(' << e / 1000.0 << "s)"; ss << ' '; } ss << "</div>\n"; }
/* no set proc fbc_id */ void eFBCTunerManager::disconnectLinkNoSimulate(eDVBRegisteredFrontend *link_fe) { if(getNext(link_fe)) { eFecDebug("[*][eFBCTunerManager::disconnectLinkNoSimulate] link fe is no last."); return; } eDVBRegisteredFrontend *prev_fe = getPrev(link_fe); if(!prev_fe) { eFecDebug("[*][eFBCTunerManager::disconnectLinkNoSimulate] can not found prev fe."); return; } prev_fe->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (long)-1); link_fe->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (long)-1); /* enable linked fe */ link_fe->m_frontend->setEnabled(false); /* add slot mask*/ updateLNBSlotMask(FE_SLOT_ID(link_fe), FE_SLOT_ID(prev_fe), true); }
/********************************************************** * extend_heap * Extend the heap by "words" words, maintaining alignment * requirements of course. Free the former epilogue block * and reallocate its new header **********************************************************/ void *extend_heap(size_t words) { #if DEBUG >= 3 printf(" %zu words ", words); #endif char *bp; size_t size; /* Allocate an even number of words to maintain alignments */ size = (words % 2) ? (words+1) * WSIZE : words * WSIZE; if ( (bp = mem_sbrk(size)) == (void *)-1 ) return NULL; /* Initialize free block header/footer and the epilogue header */ PUT(HDRP(bp), PACK(size, 0)); // free block header PUT(FTRP(bp), PACK(size, 0)); // free block footer PUT(HDRP(NEXT_BLKP(bp)), PACK(0, 1)); // new epilogue header getNext(bp) = NULL; getPrev(bp) = NULL; /* Coalesce if the previous block was free */ return coalesce(bp); }
/*auxiliar para conseguir imprimir um dado numero de elementos por pagina*/ Result printResultPagina(Result r, int indice){ Result aux = r; int i = 0; if(aux == NULL) return NULL; if(indice>=0){ while(aux != NULL && i<ELEMS_POR_PAGINA){ printf("%s\n",getElem(aux)); aux = getNext(aux); i++; } } else{ while(i<ELEMS_POR_PAGINA*2){ aux = getPrev(aux); i++; } i = 0; while(aux != NULL && i<ELEMS_POR_PAGINA){ printf("%s\n",getElem(aux)); aux = getNext(aux); i++; } } return aux; }
Track *Track::GetLink() const { auto pList = mList.lock(); if (!pList) return nullptr; if (!pList->isNull(mNode)) { if (mLinked) { auto next = pList->getNext( mNode ); if ( !pList->isNull( next ) ) return next.first->get(); } if (mNode.first != mNode.second->begin()) { auto prev = pList->getPrev( mNode ); if ( !pList->isNull( prev ) ) { auto track = prev.first->get(); if (track && track->GetLinked()) return track; } } } return nullptr; }
void TrackList::RecalcPositions(TrackNodePointer node) { if ( isNull( node ) ) return; Track *t; int i = 0; int y = 0; auto prev = getPrev( node ); if ( !isNull( prev ) ) { t = prev.first->get(); i = t->GetIndex() + 1; y = t->GetY() + t->GetHeight(); } const auto theEnd = end(); for (auto n = Find( node.first->get() ); n != theEnd; ++n) { t = *n; t->SetIndex(i++); t->DoSetY(y); y += t->GetHeight(); } UpdatePendingTracks(); }
bool CudnnConvLayer::init(const LayerMap &layerMap, const ParameterMap ¶meterMap) { if (!ConvBaseLayer::init(layerMap, parameterMap)) return false; CHECK(useGpu_) << "CudnnConvLayer only support gpu"; CHECK_EQ(inputLayers_.size(), parameters_.size()); projections_.reserve(inputLayers_.size()); projConf_.reserve(inputLayers_.size()); numFilters_ = config_.num_filters(); CHECK(config_.shared_biases()); for (size_t i = 0; i < inputLayers_.size(); i++) { ProjectionConfig* conf = new ProjectionConfig(); conf->set_type("conv"); conf->set_num_filters(numFilters_); ConvConfig* convConf = conf->mutable_conv_conf(); *convConf = *(config_.mutable_inputs(i)->mutable_conv_conf()); conf->set_input_size(getPrev(i)->getSize()); conf->set_output_size(getSize()); projConf_.emplace_back(conf); projections_.emplace_back(Projection::create(*projConf_[i], parameters_[i], useGpu_)); } if (biases_.get() && sharedBiases_) { hl_create_tensor_descriptor(&biasDesc_); hl_create_tensor_descriptor(&outputDesc_); hl_tensor_reshape(biasDesc_, 1, numFilters_ / groups_[0], 1, 1); biasOffset_ = numFilters_ / groups_[0]; } return true; }
int main(int argc, char **argv) { SdlSc2k *sc; ScDisplay *sd; int id; ShapHeader *sh; ShapHeader *head; int running; SDL_Event ev; int key_state; if(argc != 2 && argc != 3) { printf("Usage: sc2kviewer <mif file>\n"); return -1; } sd = new ScDisplay(); sc = new SdlSc2k(); sc->loadFile(argv[1]); head = sc->getShap(0); if(argc == 3) { id = atoi(argv[2]); sh = sc->getShap((unsigned short)(id & 0xffff)); } else { sh = head; } sd->initGraph(512,512); sd->display(sh); running = 1; key_state = 0; while(running) { SDL_PollEvent(&ev); switch(ev.type) { case SDL_QUIT: running = 0; break; case SDL_KEYDOWN: if(key_state == 0) { if(ev.key.keysym.sym == SDLK_UP) { sh = getPrev(sh, head); } else if(ev.key.keysym.sym == SDLK_DOWN) { sh = getNext(sh, head); } else if(ev.key.keysym.sym == SDLK_d) { debugShap(sh); } printf("Select: Scale: %02x ID: (%02x %d) Len: %d\n", sh->scale, sh->id, sh->id, sh->len2); sd->display(sh); key_state = 1; } break; case SDL_KEYUP: key_state = 0; break; } } delete sc; delete sd; }
ChatContainer::~ChatContainer() { if (!released) { EnterCriticalSection(&mutex); if (getPrev()!=NULL) { getPrev()->setNext(next); } else if (list==this) { list = getNext(); } if (getNext()!=NULL) { getNext()->setPrev(prev); } LeaveCriticalSection(&mutex); } if (hEvent!=NULL) { CloseHandle(hEvent); } }
int main() { // the list's name is "nodolista" insertHead(&nodolista.next, 1); insertTail(&nodolista.next, 6); insertTail(&nodolista.next, 3); insertTail(&nodolista.next, 8); insertTail(&nodolista.next, 4); insertTail(&nodolista.next, 7); insertTail(&nodolista.next, 5); insertTail(&nodolista.next, 9); insertTail(&nodolista.next, 2); // end //printList printList(nodolista.next); //getHead printf("\nHead:\t[ (%d) %d ]\n", getHead(nodolista.next)->index, getHead(nodolista.next)->info); //getTail printf("Tail:\t[ (%d) %d ]\n", getTail(nodolista.next)->index, getTail(nodolista.next)->info); // getPrev int k = 0; printf("Insert an index to return the prev (starting from 0 to %d): ", getIndex(getTail(nodolista.next))); scanf("%d", &k); printf("The prev of value %d is: %d\n", getValue(nodolista.next, k)->info, \ (getPrev(nodolista.next, k) ? getPrev(nodolista.next, k)->info : 0)); // search k = 0; printf("Insert a value to search into the list: "); scanf("%d", &k); printf("The search went: %s\n", (search(nodolista.next, k) ? "true" : "false")); // delete printf("Insert an item in the list to delete: "); scanf("%d", &k); delete(nodolista.next, k); printList(nodolista.next); // inserction sort inserctionSort(nodolista.next); printList(nodolista.next); return 0; } //end main
size_t TrackList::size() const { int cnt = 0; if (!empty()) cnt = getPrev( getEnd() ).first->get()->GetIndex() + 1; return cnt; }
/********************************************************** * mm_free * Free the block and coalesce with neighbouring blocks **********************************************************/ void mm_free(void *bp) { #if DEBUG >= 3 printf("\nmm_free\n"); #endif //printf(" list before freeing..\n"); //print_free_list(); if(bp == NULL){ printf("null found.."); return; } size_t size = GET_SIZE(HDRP(bp)); printf(" size %zu\n", size); PUT(HDRP(bp), PACK(size,0)); PUT(FTRP(bp), PACK(size,0)); if (bp == flhead){ if (getNext(flhead) != NULL ){ flhead = getNext(flhead); } else { flhead = NULL; } } if (bp == fltail){ if (getPrev(fltail) != NULL){ fltail = getPrev(fltail); } else { fltail = NULL; } } coalesce(bp); //printf("list after freeing\n"); //print_free_list(); }
fp_Container * fp_TOCContainer::getPrevContainerInSection() const { if(getPrev()) { return static_cast<fp_Container *>(getPrev()); } fl_ContainerLayout * pCL = static_cast<fl_ContainerLayout *>(getSectionLayout()); fl_ContainerLayout * pPrev = pCL->getPrev(); while(pPrev && pPrev->getContainerType() == FL_CONTAINER_ENDNOTE) { pPrev = pPrev->getPrev(); } if(pPrev) { return pPrev->getLastContainer(); } return NULL; }
int TrackList::GetHeight() const { int height = 0; if (!empty()) { auto track = getPrev( getEnd() ).first->get(); height = track->GetY() + track->GetHeight(); } return height; }
Track *TrackList::DoAdd(const std::shared_ptr<Track> &t) { push_back(t); auto n = getPrev( getEnd() ); t->SetOwner(shared_from_this(), n); t->SetId( TrackId{ ++sCounter } ); RecalcPositions(n); AdditionEvent(n); return back().get(); }
/* all unused linked fbc fe must be unlinked! */ void eFBCTunerManager::unset(eDVBRegisteredFrontend *fe) { bool simulate = fe->m_frontend->is_simulate(); if (isRootFe(fe)) return; if(checkUsed(fe, simulate)) return; if(isUnicable(fe)) return; eFecDebug(" [*][eFBCTunerManager::unset] fe id : %p(%d) %s", fe, FE_SLOT_ID(fe), simulate?"(simulate)":""); // printLinks(fe); eDVBRegisteredFrontend *linked_prev_fe = getPrev(fe); eDVBRegisteredFrontend *linked_next_fe = getNext(fe); if (!linked_prev_fe) { eDebug("[*][eFBCTunerManager::unset] ERROR! can not found prev linked frontend (fe_id : %d)", FE_SLOT_ID(fe)); return; } if (linked_next_fe) { int res = disconnectLink(fe, linked_prev_fe, linked_next_fe, simulate); if (res) { eDebug("[*][eFBCTunerManager::unset] ERROR! disconnect link failed! (%d->%d->%d)", FE_SLOT_ID(linked_prev_fe), FE_SLOT_ID(fe), FE_SLOT_ID(linked_next_fe)); return; } } else { int res = disconnectLink(fe, linked_prev_fe, simulate); if (res) { eDebug("[*][eFBCTunerManager::unset] ERROR! disconnect link failed! (%d->%d)", FE_SLOT_ID(linked_prev_fe), FE_SLOT_ID(fe)); return; } } /* set proc fbc_id (skip) */ /* remove slot mask*/ updateLNBSlotMask(FE_SLOT_ID(fe), FE_SLOT_ID(linked_prev_fe), true); // printLinks(fe); }
bool eFBCTunerManager::canLink(eDVBRegisteredFrontend *fe) { if(isRootFe(fe)) return false; if(getPrev(fe) || getNext(fe)) return false; if(isUnicable(fe)) return false; return true; }
/********************************************************** * rmFromFreeList * This function will remove the free block from the free list * it will ensure that prev block and cur block of the bp * will be linked up **********************************************************/ void rmFromFreeList(void *bp) { //printf(" rm "); if ((getNext(bp) == NULL) && (getPrev(bp)== NULL)){ //printf(" 1"); flhead = NULL; } else if (bp == flhead && getPrev(bp) == NULL) { //printf(" 2"); flhead = getNext(bp); if (flhead != NULL){ putPrev(flhead, NULL); } putPrev(bp, NULL); putNext(bp, NULL); } else if (getNext(bp) == NULL){ //printf(" 3"); void * prev = getPrev(bp); if (prev != NULL) { putNext(prev,NULL); } putNext(bp, NULL); putPrev(bp, NULL); } else { //printf(" 4"); void * prev = getPrev(bp); void * next = getNext(bp); putPrev(bp, NULL); putNext(bp, NULL); putNext(prev, next); putPrev(next, prev); } //printf("\n"); }
/*! * Return the block that contains this Embedded layout */ fl_BlockLayout * fl_EmbedLayout::getContainingBlock(void) { fl_ContainerLayout * pCL = getPrev(); while(pCL && pCL->getContainerType() != FL_CONTAINER_BLOCK) { pCL = pCL->getPrev(); } if(pCL == NULL) return NULL; fl_BlockLayout * pBL = static_cast<fl_BlockLayout *>(pCL); while(pBL && pBL->getPosition(true) > getDocPosition()) pBL = pBL->getPrevBlockInDocument(); return pBL; }
void TabList::logic(bool allow_keyboard) { if (locked) return; if (NO_MOUSE || allow_keyboard) { if (scrolltype == VERTICAL || scrolltype == TWO_DIRECTIONS) { if (inpt->pressing[DOWN] && !inpt->lock[DOWN]) { inpt->lock[DOWN] = true; getNext(); } else if (inpt->pressing[UP] && !inpt->lock[UP]) { inpt->lock[UP] = true; getPrev(); } } if (scrolltype == HORIZONTAL || scrolltype == TWO_DIRECTIONS) { if (inpt->pressing[MV_LEFT] && !inpt->lock[MV_LEFT]) { inpt->lock[MV_LEFT] = true; getPrev(false); } else if (inpt->pressing[MV_RIGHT] && !inpt->lock[MV_RIGHT]) { inpt->lock[MV_RIGHT] = true; getNext(false); } } if (inpt->pressing[ACTIVATE] && !inpt->lock[ACTIVATE]) { inpt->lock[ACTIVATE] = true; deactivatePrevious(); //Deactivate previously activated item activate(); // Activate the currently infocus item } } // If mouse is clicked, defocus current tabindex item if (inpt->pressing[MAIN1] && !inpt->lock[MAIN1] && current_is_valid() && !isWithin(widgets[getCurrent()]->pos, inpt->mouse)) { defocus(); } }
//does not print the value of the varible, only sets up the screen with the title and prev/next indicators void PrintHPS::printHeaders() { oled->clearDisplay(); oled->setTextColor(WHITE, BLACK); oled->setCursor(0,0); oled->setTextSize(2); oled->println(data[index].name_of_variable); oled->setCursor(0,56); oled->setTextSize(1); oled->print("< "); oled->print(data[getPrev()].name_of_variable); oled->print(" "); oled->print(data[getNext()].name_of_variable); oled->print(" >"); oled->display(); }
long MyTabItem::onKeyPress(FXObject*o, FXSelector sel, void*p) { FXEvent*ev=(FXEvent*)p; if (ev && ev->code==KEY_Tab) { if (ev->state&SHIFTMASK) { if (getPrev()) { FXTabBook*tb=(FXTabBook*)getParent(); tb->setCurrent(tb->getCurrent()-1); } } else { getNext()->setFocus(); if (getNext()->getFirst()) { getNext()->getFirst()->setFocus(); } } return 1; } return FXTabItem::onKeyPress(o,sel,p); }
void fp_TOCContainer::deleteBrokenAfter(bool bClearFirst) { if (!isThisBroken()) { if (getFirstBrokenTOC()) { return getFirstBrokenTOC()->deleteBrokenAfter(bClearFirst); } return; } if (bClearFirst) { clearScreen(); getMasterTOC()->clearBrokenContainers(); } fp_TOCContainer * pBroke = static_cast<fp_TOCContainer *>(getNext()); fp_TOCContainer * pNext = NULL; while(pBroke) { pNext = static_cast<fp_TOCContainer *> (pBroke->getNext()); if (pBroke->getContainer()) { UT_sint32 i = pBroke->getContainer()->findCon(pBroke); if (i >= 0) { pBroke->getContainer()->deleteNthCon(i); pBroke->setContainer(NULL); } } delete pBroke; pBroke = pNext; } setNext(NULL); if (!getPrev()) { getMasterTOC()->setNext(NULL); } getMasterTOC()->setLastBrokenTOC(this); setYBottom(getTotalTOCHeight()); }
SPMeshRow* SPMeshRow::getPrevMeshRow() { SPMeshRow *result = 0; for (SPObject* obj = getPrev(); obj; obj = obj->getPrev()) { // The closest previous SPObject that is an SPMeshRow *should* be ourself. if (SP_IS_MESHROW(obj)) { SPMeshRow* meshrow = SP_MESHROW(obj); // Sanity check to ensure we have a proper sibling structure. if (meshrow->getNextMeshRow() == this) { result = meshrow; } else { g_warning("SPMeshRow previous/next relationship broken"); } break; } } return result; }