// When pos is 0, it means the node will be added right after root, 1 means 1 position after that and so on // -1 or any negative number means it'll make it the head, i.e. it'll append it to the end of the list void add(int value, int pos) { struct node *newNode, *prev, *next; int i = 0, hasNext = 0; newNode = (struct node*)malloc(sizeof(struct node)); newNode->value = value; newNode->link = NULL; setHead(); if (pos < 0) { head->link = newNode; return; } prev = root; while (i < pos) { if (prev->link == NULL) { printf("Overflow. Ignoring call.\n"); return; } prev = prev->link; i++; } if (prev->link != NULL) { next = prev->link; hasNext = 1; } prev->link = newNode; if (hasNext == 1) { newNode->link = next; } setHead(); }
int rem(int pos) { struct node *prev, *next; int i = 0; int val = -1; setHead(); val = head->value; if (root->link == NULL) { return -1; } prev = root; while (i < pos) { if (prev->link == NULL) { printf("Overflow. Can't remove node.\n"); return; } prev = prev->link; i++; } if (prev->link != NULL && prev->link->link != NULL) { val = prev->link->value; next = prev->link->link; prev->link = next; } else { prev->link = NULL; } setHead(); return val; }
void DoubleList03::transferToList(NODE* root) { if (m_Head == NULL&&root != NULL&&root->left == NULL) { DoubleNode03* node = new DoubleNode03(); node->setValue(root->num); node->setPrev(NULL); node->setNext(NULL); setHead(node); setTail(node); setPreNode(node); } if (!root) return; transferToList(root->left); if (root->num != m_Head->getValue()) { DoubleNode03* newNode = new DoubleNode03(); newNode->setValue(root->num); newNode->setPrev(preNode); newNode->setNext(NULL); preNode->setNext(newNode); setTail(newNode); setPreNode(newNode); } transferToList(root->right); }
/* * Writes the page to the buffer and increments the head pointer */ void RingBuffer::writePage(uint16_t framAddr, uint16_t pageSize, uint8_t page[], size_t size) { for (int i = 0; i < min(size,pageSize); i++) { fram.write8(framAddr + i, page[i]); } setHead(framAddr + pageSize); }
void SingleList::addHead(int value) { SingleNode *N = new SingleNode(); N->setValue(value); N->setNext(head); setHead(N); }
void StatBar::SetContent( EChesses* aec ) { //CCLog(">[StatBar] SetContent."); if(!aec){ m_ec = aec; setVisible(false); return; } //CCLog(">[StatBar] SetContent. | None Null Pass."); if(m_ec == aec){ setVisible(true); return; } //CCLog(">[StatBar] SetContent. | New Stat Calculate."); m_ec = aec; CCLog(">[StatBar] setContent | Name: %s", m_ec->m_pChara->m_sName.c_str()); msb_SoulBall->setSum(m_ec->m_pChara->getSHP()); mb_BloodOne->revalue(m_ec->m_pChara->getvalue("hp")); setHead(m_ec->m_pChara->msBHead.c_str()); RefreshAll(); SetNullAct(); setVisible(true); }
int updateHook(CReportHookList *pCReportHookList) { int retval = 0; if (pCReportHookList->m_pPrev != NULL) { disconnect(pCReportHookList); setHead(pCReportHookList); retval = pCReportHookList->m_Refcount++; } else { setHead(pCReportHookList); retval = pCReportHookList->m_Refcount = 1; } return retval; }
void Outfit::resetClothes() { setHead(0); setBody(0); setLegs(0); setFeet(0); }
boolean RingBuffer::write(uint8_t page[], size_t size) { uint16_t head = getHead(); uint16_t tail = getTail(); uint16_t pageSize = getPageSize(); boolean retVal = false; // check, if we wrapped if (getFlipMarker() == 0) { if (head + pageSize > bootSectorStart) { // we reached the end of the memory, go to start and flip marker head = startData; setHead(head); setFlipMarker(0xFF); if (head + pageSize < tail) { // there is some space, write the page writePage(head,pageSize,page,size); retVal = true; } } else { // there is some space, write the page writePage(head,pageSize,page,size); retVal = true; } } else { if (head < tail) { // we have some sapace left writePage(head,pageSize,page,size); retVal = true; } } return retVal; }
bool EFXFixture::loadXML(const QDomElement& root) { if (root.tagName() != KXMLQLCEFXFixture) { qWarning("EFX Fixture node not found!"); return false; } GroupHead head; head.head = 0; /* New file format contains sub tags */ QDomNode node = root.firstChild(); while (node.isNull() == false) { QDomElement tag = node.toElement(); if (tag.tagName() == KXMLQLCEFXFixtureID) { /* Fixture ID */ head.fxi = tag.text().toInt(); } else if (tag.tagName() == KXMLQLCEFXFixtureHead) { /* Fixture Head */ head.head = tag.text().toInt(); } else if (tag.tagName() == KXMLQLCEFXFixtureMode) { /* Fixture Mode */ setMode ((Mode) tag.text().toInt()); } else if (tag.tagName() == KXMLQLCEFXFixtureDirection) { /* Direction */ Function::Direction dir = Function::stringToDirection(tag.text()); setDirection(dir); } else if (tag.tagName() == KXMLQLCEFXFixtureStartOffset) { /* Start offset */ setStartOffset(tag.text().toInt()); } else if (tag.tagName() == KXMLQLCEFXFixtureIntensity) { /* Intensity */ setFadeIntensity(uchar(tag.text().toUInt())); } else { qWarning() << "Unknown EFX Fixture tag:" << tag.tagName(); } node = node.nextSibling(); } if (head.fxi != Fixture::invalidId()) setHead(head); return true; }
void test_setHead_to_NULL_should_set_Head_to_NULL() { LinkedList *Head ; setHead(&Head,NULL); TEST_ASSERT_NULL(Head); }
grove::_LogError &grove::_LogError::operator()(const std::string &_HEAD) { // Dump into Debug LogDebug(_HEAD); loghead = setHead(_HEAD); return *this; }
void test_setHead_to_list_should_set_Head_to_the_target_List() { LinkedList *list = listCreate(0x200) ; LinkedList *Head ; setHead(&Head,list); TEST_ASSERT_EQUAL(list,Head); listDestroy(list); }
void Skeleton::setJoint(Joint joint) { string jointType = joint.getType(); if (jointType == "ThumbRight") { setThumbRight(joint); } else if (jointType == "SpineBase") { setSpineBase(joint); } else if (jointType == "SpineMid") { setSpineMid(joint); } else if (jointType == "Neck") { setNeck(joint); } else if (jointType == "Head") { setHead(joint); } else if (jointType == "ShoulderLeft") { setShoulderLeft(joint); } else if (jointType == "ElbowLeft") { setElbowLeft(joint); } else if (jointType == "WristLeft") { setWristLeft(joint); } else if (jointType == "HandLeft") { setHandLeft(joint); } else if (jointType == "ShoulderRight") { setShoulderRight(joint); } else if (jointType == "ElbowRight") { setElbowRight(joint); } else if (jointType == "WristRight") { setWristRight(joint); } else if (jointType == "HandRight") { setHandRight(joint); } else if (jointType == "HipLeft") { setHipLeft(joint); } else if (jointType == "KneeLeft") { setKneeLeft(joint); } else if (jointType == "AnkleLeft") { setAnkleLeft(joint); } else if (jointType == "FootLeft") { setFootLeft(joint); } else if (jointType == "HipRight") { setHipRight(joint); } else if (jointType == "KneeRight") { setKneeRight(joint); } else if (jointType == "AnkleRight") { setAnkleRight(joint); } else if (jointType == "FootRight") { setFootRight(joint); } else if (jointType == "SpineShoulder") { setSpineShoulder(joint); } else if (jointType == "HandTipLeft") { setHandTipLeft(joint); } else if (jointType == "ThumbLeft") { setThumbLeft(joint); } else if (jointType == "HandTipRight") { setHandTipRight(joint); } }
MigrationArrow::MigrationArrow(double start, double end, double time, const QColor &color, QCustomPlot *parent): QCPItemLine(parent) { QPen pen; QCPItemLine::start->setCoords(time, start); QCPItemLine::end->setCoords(time, end); pen.setColor(color); setPen(pen); setHead(QCPLineEnding::esFlatArrow); }
/** * is_internal is TRUE when called from wdjCallOldProc, that is to * say, when we're auto-unhooking. In that case, unhook no matter * what the ref_count is. */ static BOOL internal_unhook( WNDPROC id, HWND hwnd, BOOL is_internal ) { SUBCLASSING *pHead = getHead( hwnd ); SUBCLASSING *pThis = find( id, hwnd ); WNDPROC expected = 0; SUBCLASSING *pPrev = 0; if ( 0 == pThis ) { tracef( _T( "wdjUnhook: Subclassing %#x not found for hwnd %#x" ), id, hwnd ); DebugBreak(); return FALSE; //*** FUNCTION EXIT POINT } if ( !is_internal && 0 < --pThis->ref_count ) { tracef( _T( "wdjUnhook: " ) _T( "Decreasing ref_count for %#x (hwnd=%#x) to %d" ), pThis->wndProc, hwnd, pThis->ref_count ); return TRUE; //*** FUNCTION EXIT POINT } // Figure out what we're expecting as the saved proc if ( pHead == pThis ) { expected = getWndProc( hwnd ); } else { pPrev = findPrev( pHead, pThis ); expected = pPrev->wndProcSaved; } // Are we blocked? if ( expected != id ) { tracef( _T( "wdjUnhook: Subclassing %#x for %#x blocked by %#x" ), id, hwnd, expected ); return FALSE; //*** FUNCTION EXIT POINT } // OK, unlink if ( pHead == pThis ) { assert( 0 == pPrev ); tracef( _T( "wdjUnhook: Removing head of list wndproc %#x from window %#x" ), pThis->wndProc, hwnd ); SubclassWindow( hwnd, pThis->wndProcSaved ); setHead( hwnd, pThis->pNext ); } else { assert( 0 != pPrev ); tracef( _T( "wdjUnhook: Unlinking wndproc %#x from window %#x" ), pThis->wndProcSaved, hwnd ); pPrev->pNext = pThis->pNext; pPrev->wndProcSaved = pThis->wndProcSaved; } free( pThis ); releasePropertyName(); return TRUE; //*** FUNCTION EXIT POINT }
void add( TNode *node ) { if ( NULL == _head) { setHead( node ) ; } else { _end->_next = node ; _end = node ; } ++_count ; }
//烈焰战车700007 SoldierLyzc::SoldierLyzc( int id ) : Soldier(id) { auto data = SoldierData::getSoldierData(id); int type = data->type / 100; char sType[10]; sprintf(sType,"%d",type); _head = nullptr; setHead(Armature::create(sType)); _currentIndex = 0; _degreeIndex = 0; _head = nullptr; }
FFEvent* TimeTable::getUpcomingEvent(){ FFEvent* upEvent = head; if ( size() > 1 ) { setHead(head->getNext()); decrement(); } else if ( size() == 1 ) { // this is the only event left decrement(); } else { // no events left to be treated (size=0) cout << "ForeFire simulation ended with no more event to be treated" << endl; upEvent = 0; } return upEvent; }
BOOL wdjSubclass( WNDPROC wndProc, HWND hwnd, void *pData ) { SUBCLASSING *pHead = getHead( hwnd ); SUBCLASSING *pThis = find( wndProc, hwnd ); WNDPROC curr = getWndProc( hwnd ); // If this subclassing has been applied before, just increase // the reference count and smile. It won't be called twice in // the chain, it won't be moved to the front of the chain, // and it won't be unhooked until wdjUnhook() has been called // the same number of times that wdjSubclass() was called. if ( 0 != pThis ) { assert( pData == pThis->pData ); ++pThis->ref_count; tracef( _T( "wdjSubclass: Increasing ref_count for " ) _T( "%#x (hwnd=%#x) to %d" ), pThis->wndProc, hwnd, pThis->ref_count ); return TRUE; //*** FUNCTION EXIT POINT } // Applying the current window function as a subclassing is // almost certainly an error, so don't. (If the new and current // window function are the same because of previous subclassing, // it's OK, and caught by the previous test for 0 != pThis. if ( curr == wndProc ) { tracef( _T( "wdjSubclass: Attempting to apply current wndproc " ) _T( "%#x to %#x refused" ), pThis->wndProc, hwnd ); DebugBreak(); return FALSE; //*** FUNCTION EXIT POINT } // We have a spankin' new subclassing for this window: if ( allocPropertyName() ) { if ( 0 != (pThis = malloc( sizeof( *pThis ) ) ) ) { if ( initNode( hwnd, pThis, wndProc, pData, pHead ) ) { if ( setHead( hwnd, pThis ) ) { tracef( _T( "wdjSubclass: Adding new wndproc %#x " ) _T( "to window %#x" ), pThis->wndProc, hwnd ); return TRUE; //*** FUNCTION EXIT POINT } SubclassWindow( hwnd, pThis->wndProcSaved ); } free( pThis ); } releasePropertyName(); } return FALSE; //*** FUNCTION EXIT POINT }
void tuhoa_solmu(henkilo *h) { char enimi[50], snimi[50]; strcpy(enimi, h->enimi); strcpy(snimi, h->snimi); henkilo* edellinen = haeEdellinen(enimi, snimi); if(h->next != NULL && edellinen != NULL) { edellinen->next = h->next; free(h); } else if(h->next == NULL && edellinen != NULL) { edellinen->next = NULL; free(h); } else { setHead(h->next); free(h); } }
CMD_CODE its_dns(char *www , unsigned int dns, char *ip) { unsigned char buf[MAX_SIZE_DNS]; /* socket发送的数据 */ char *DN=www; /* 将要解析的域名(www.xxx.xxx) */ char name[MAX_SIZE_DNS]; /* 转换为符合DNS报文格式的域名 */ char recvMsg[MAX_SIZE_DNS]; /* 接收的数据 */ int len; /* socket发送数据的长度 */ int len_recvMsg; int ret =-1; sys_log(FUNC, LOG_DBG, " www=%s, dns=0x%08x, ip=%s", www, dns, ip); len = changeDN(DN,name); setHead(buf); setQuery(name,buf,len); len += 16; //sys_log(FUNC, LOG_DBG, " %s", "---->1"); len_recvMsg = sendDNSPacket(buf,len,recvMsg, dns); //sys_log(FUNC, LOG_DBG, " %s", "---->2"); ret = resolve(recvMsg,len,len_recvMsg, ip); //sys_log(FUNC, LOG_DBG, "---->3 ret=%d",ret); return ret; }
grove::_LogDebug &grove::_LogDebug::operator()(const std::string &_HEAD) { loghead = setHead(_HEAD); return *this; }
Edge::Edge(Node *tail, Node *head): tail_(nullptr), head_(nullptr) { setTail(tail); setHead(head); }
bool RestartLayer::init() { bool bRet = false; do { CC_BREAK_IF(!NavigatorLayer::init()); CCSize size = CCDirector::sharedDirector()->getWinSize(); // 1.头像 setHead(CCSprite::create()); m_pHead->initWithFile("Navigator_lose_image_1.png"); m_pHead->setPosition(ccp(150, 150)); m_pTV->addChild(m_pHead, 2); // 2.文字 CCSprite* pTitle = CCSprite::create(); pTitle->initWithFile("Navigator_lose_text.png"); pTitle->setPosition(ccp(350, 238)); m_pTV->addChild(pTitle, 2); // 3.重新开始的按钮 CCMenuItemImage *pRestartItem = CCMenuItemImage::create( "Btn_replay.png", "Btn_replay_pressed.png", "Btn_replay.png", this, menu_selector(RestartLayer::restartCallback)); CC_BREAK_IF(! pRestartItem); pRestartItem->setPosition(ccp(355, 80)); CCMenu* pMenu = CCMenu::create(pRestartItem, NULL); pMenu->setPosition(CCPointZero); CC_BREAK_IF(! pMenu); m_pTV->addChild(pMenu, 1); // 4.显示IQ数 CCString* str = CCString::createWithFormat("IQ: %d", m_nIQ); setIQLabel(CCLabelTTF::create(str->getCString(), "Arial", 30)); m_pIQLabel->setColor(ccBLACK); m_pIQLabel->setPosition(ccp(357, 160)); m_pIQLabel->getTexture()->setAliasTexParameters(); m_pTV->addChild(m_pIQLabel, 10); // init action CCAnimation* animation = CCAnimation::create(); animation->addSpriteFrameWithFileName("Navigator_lose_image_1.png"); animation->addSpriteFrameWithFileName("Navigator_lose_image_2.png"); animation->addSpriteFrameWithFileName("Navigator_lose_image_3.png"); animation->setDelayPerUnit(0.2f); CCAnimate* animate = CCAnimate::create(animation); setFlickerAction(CCRepeatForever::create(animate)); #if CC_TARGET_PLATFORM == CC_PLATFORM_IOS // 3.提示的按钮, 如果本关卡有提示点,才需要显示出来 setPromptItem(CCMenuItemImage::create( "Navigator_prompt.png", "Navigator_prompt_pressed.png", "Navigator_prompt.png", this, menu_selector(RestartLayer::promptCallback))); CC_BREAK_IF(! m_pPromptItem); m_pPromptItem->setPosition(ccp(235, 5)); pMenu->addChild(m_pPromptItem, 10); #endif bRet = true; }while(0); return bRet; }
int DriveStatus(BYTE_WIDE drive, WORD_WIDE* buf){ int i; unsigned erroria=0; IDESoftReset(); erroria=setHead(drive); //LBA access! delayShort(); if (erroria&ERR){ return READ_ERROR; //error reading } //delayCIA(); i=20000; TF_COMMAND=ATA_IDENTIFY_DRIVE; delayShort(); erroria=TF_ALTERNATE_STATUS; delayShort(); while (erroria&BSY!=0&&i>0 ) { erroria = TF_ALTERNATE_STATUS; delayShort(); i--; }; erroria = TF_STATUS; //an atapi drive reports 0 here! if (erroria&ERR){ return READ_ERROR; //error reading } if (erroria&DWF){ return WRITE_ERROR; //error writing } if (erroria==0 ){ //atapi drive TF_COMMAND=ATA_IDENTIFY_PACKET_DEVICE; i=20000; erroria=TF_ALTERNATE_STATUS; delayShort(); while (erroria&BSY!=0&&i>0 ) { erroria = TF_ALTERNATE_STATUS; delayShort(); i--; }; if(i>0){ return DriveType(buf); } else{ return TIME_OUT; } } if (i<=0){ //time out return TIME_OUT; } else{ return DriveType(buf); } }
void Inventory::add(string itemID, string itemName, int attack, int itemAmount) { string ID = itemID; Item *temp2 = head; Item *newNode = new Item; newNode->setID(ID); //cout << "ID set correctly" << endl; newNode->setName(itemName); //cout << "Name set correctly" << endl; newNode->setWepAtk(attack); //cout << "Attack set correctly" << endl; newNode->setAmount(itemAmount); //cout << "Amount set correctly" << endl; newNode->setNext(NULL); cout << "Head set correctly" << endl; if(temp2 != NULL) { cout << "Temp isn't null so adding another" << endl; cout << "Adding something" << endl; do { if(temp2->getID() == newNode->getID() && temp2->getNext() == NULL) { cout << "Adding duplicate item" << endl; int counter = temp2->getAmount(); counter = counter+itemAmount; temp2->setAmount(counter); delete newNode; return; } if(temp2->getID() == newNode->getID()) { cout << "Adding duplicate item" << endl; int counter = temp2->getAmount(); counter = counter+itemAmount; temp2->setAmount(counter); delete newNode; return; } if(temp2->getNext() == NULL) //something here isn't working... set it after? { temp2->setNext(newNode); newNode->setNext(NULL); return; } else { //cout << "Looping temp inventory" << endl; temp2 = temp2->getNext(); } } while(temp2 != NULL); return; } else //temp is equal to NULL { cout << "List empty, adding new entry to head" << endl; setHead(newNode); return; } }