• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ std::list类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中std::list的典型用法代码示例。如果您正苦于以下问题:C++ list类的具体用法?C++ list怎么用?C++ list使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了list类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1:

		/*
		  I'm not sure what is the point of this function.
		  Checked
		*/
		std::list<BookData>::iterator BookCollection::displayIsbn(std::list<BookData>::iterator iter,
			int num)
		{
			char rightBook = 'Y';  // Is this the right book
			std::string input;		// to hold user input

			/// a book?
			if (iter == bookList.end())
			{
				std::cout << "   Not a valid ISBN number." << std::endl;
			} // end if
			else
			{
				iter->bookInfo();

				std::cout << "   Is this the right book? (y/n)" << std::endl;
				std::getline(std::cin, input);
				rightBook = input.at(0);

				// if it is the add the book to the users total
				if (rightBook == 'Y' || rightBook == 'y')
				{
					if (booksAvailable(iter, num))
					{
						return iter;
					} // end if
					else
					{
						std::cout << "Not enough books available."  << std::endl;
						return bookList.end();
					} // end if
					//// check to see if there are books available
					//if (books->operator[](pos).getQuantity() > numBooks)
					//{
					//	std::cout << "   Adding book" << endl;
					//	// Add the book to the vector
					//	buyMe.push_back(books->operator[](pos));
					//	numB.push_back(numBooks);

					//	int newQ = books->operator[](pos).getQuantity()
					//		- numBooks;
					//	books->operator[](pos).setQuantity(newQ);
					//} // end if
					//else
					//{
					//	std::cout << "Not enough books available."  << std::endl;
					//} // end else
					
				} // end if

			} // end else

			
			//// To hold the position of the found book
			//std::list<BookData>::iterator pos = bookList.begin();

			//for (unsigned int index = 0; index < bookList.size(); index++)
			//{
			//	std::cout << std::left << std::setw(WIDTH) << "Title: " 
			//		<< pos->getTitle() << std::endl;
			//	std::cout << std::left << std::setw(WIDTH) << "ISBN: " 
			//		<< pos->getIsbn() << std::endl;
			//	std::cout << std::endl;

			//	pos++;

			//} // end for
			return bookList.end();
			std::cout << std::endl;

		} // end function displayIsbn
开发者ID:jtdarkly,项目名称:Serenity-Now,代码行数:75,代码来源:BookCollection.cpp


示例2: output_html_results

void output_html_results(bool show_description, const std::string& tagname)
{
   std::stringstream os;
   if(result_list.size())
   {
      //
      // start by outputting the table header:
      //
      os << "<table border=\"1\" cellspacing=\"1\">\n";
      os << "<tr><td><strong>Expression</strong></td>";
      if(show_description)
         os << "<td><strong>Text</strong></td>";
#if defined(BOOST_HAS_GRETA)
      if(time_greta == true)
         os << "<td><strong>GRETA</strong></td>";
      if(time_safe_greta == true)
         os << "<td><strong>GRETA<BR>(non-recursive mode)</strong></td>";
#endif
      if(time_boost == true)
         os << "<td><strong>Boost</strong></td>";
      if(time_localised_boost == true)
         os << "<td><strong>Boost + C++ locale</strong></td>";
#if defined(BOOST_HAS_POSIX)
      if(time_posix == true)
         os << "<td><strong>POSIX</strong></td>";
#endif
#ifdef BOOST_HAS_PCRE
      if(time_pcre == true)
         os << "<td><strong>PCRE</strong></td>";
#endif
#ifdef BOOST_HAS_XPRESSIVE
      if(time_xpressive == true)
         os << "<td><strong>Dynamic Xpressive</strong></td>";
#endif
      os << "</tr>\n";

      //
      // Now enumerate through all the test results:
      //
      std::list<results>::const_iterator first, last;
      first = result_list.begin();
      last = result_list.end();
      while(first != last)
      {
         os << "<tr><td><code>" << html_quote(first->expression) << "</code></td>";
         if(show_description)
            os << "<td>" << html_quote(first->description) << "</td>";
#if defined(BOOST_HAS_GRETA)
         if(time_greta == true)
         {
            print_result(os, first->greta_time, first->factor);
            if(first->greta_time > 0)
            {
               greta_total += first->greta_time / first->factor;
               ++greta_test_count;
            }
         }
         if(time_safe_greta == true)
         {
            print_result(os, first->safe_greta_time, first->factor);
            if(first->safe_greta_time > 0)
            {
               safe_greta_total += first->safe_greta_time / first->factor;
               ++safe_greta_test_count;
            }
         }
#endif
#if defined(BOOST_HAS_POSIX)
         if(time_boost == true)
         {
            print_result(os, first->boost_time, first->factor);
            if(first->boost_time > 0)
            {
               boost_total += first->boost_time / first->factor;
               ++boost_test_count;
            }
         }
#endif
         if(time_localised_boost == true)
         {
            print_result(os, first->localised_boost_time, first->factor);
            if(first->localised_boost_time > 0)
            {
               locale_boost_total += first->localised_boost_time / first->factor;
               ++locale_boost_test_count;
            }
         }
         if(time_posix == true)
         {
            print_result(os, first->posix_time, first->factor);
            if(first->posix_time > 0)
            {
               posix_total += first->posix_time / first->factor;
               ++posix_test_count;
            }
         }
#if defined(BOOST_HAS_PCRE)
         if(time_pcre == true)
         {
            print_result(os, first->pcre_time, first->factor);
//.........这里部分代码省略.........
开发者ID:KerwinMa,项目名称:AerothFlyffSource,代码行数:101,代码来源:command_line.cpp


示例3: bringToFront

void ofxWidget::bringToFront(std::list<weak_ptr<ofxWidget>>::iterator it_)
{
	if (it_->expired())
		return;

	// ---------| invariant: element is valid

	auto element = it_->lock();

	// We're conservative with re-ordering.
	// Let's move the iterator backward to see if we are actually 
	// already sorted.
	// If the list were already sorted, then moving back from the current
	// iterator by the number of its children would bring us 
	// to the beginning of sAllWidgets. Then, there is no need to re-order.
	if (std::prev(it_, element->mNumChildren) == sAllWidgets.begin())
		return;

	// ----------| invariant: element (range) not yet at front.

	/*
	Algorithm:

	while current object range has a parent, put current object
	range to the front of parent range make parent range current
	object range.

	As soon as there is no parent anymore, put last object range
	to the front of the list

	Heuristic: parent iterator's position always to be found
	after current iterator.
	*/

	auto parent = element->mParent.lock();
	auto elementIt = it_;

	while (parent) {

		auto itParent = findIt(element->mParent, std::next(elementIt), sAllWidgets.end()); // start our search for parent after current element.

		// if element has parent, bring element range to front of parent range.
		if (std::prev(elementIt, element->mNumChildren) != std::prev(itParent, parent->mNumChildren)) {
			sAllWidgets.splice(
				std::prev(itParent, parent->mNumChildren), 					// where to move elements to -> front of parent range
				sAllWidgets, 												// where to take elements from
				std::prev(elementIt, element->mNumChildren),
				std::next(elementIt));		// range of elements to move -> range of current element and its children
		}

		// because sAllWidgets is a list, splice will only invalidate iterators 
		// before our next search range.

		elementIt = itParent;
		element = elementIt->lock();
		parent = element->mParent.lock();
	}

	// now move the element range (which is now our most senior parent element range) to the front fo the list.

	if (std::prev(elementIt, element->mNumChildren) != sAllWidgets.begin()) {
		sAllWidgets.splice(
			sAllWidgets.begin(),
			sAllWidgets,
			std::prev(elementIt, element->mNumChildren), // from the beginning of our now most senior parent element range
			std::next(elementIt));						 // to the end of our now most senior parent element range
	}

	ofxWidget::bVisibleListDirty = true;
}
开发者ID:tgfrerer,项目名称:ofxWidget,代码行数:70,代码来源:ofxWidget.cpp


示例4: loadMonster

bool Monsters::loadMonster(const std::string& file, const std::string& monsterName, std::list<std::pair<MonsterType*, std::string>>& monsterScriptList, bool reloading /*= false*/)
{
	MonsterType* mType = nullptr;
	bool new_mType = true;

	pugi::xml_document doc;
	pugi::xml_parse_result result = doc.load_file(file.c_str());
	if (!result) {
		printXMLError("Error - Monsters::loadMonster", file, result);
		return false;
	}

	pugi::xml_node monsterNode = doc.child("monster");
	if (!monsterNode) {
		std::cout << "[Error - Monsters::loadMonster] Missing monster node in: " << file << std::endl;
		return false;
	}

	pugi::xml_attribute attr;
	if (!(attr = monsterNode.attribute("name"))) {
		std::cout << "[Error - Monsters::loadMonster] Missing name in: " << file << std::endl;
		return false;
	}

	if (reloading) {
		mType = getMonsterType(monsterName);
		if (mType != nullptr) {
			new_mType = false;
			mType->reset();
		}
	}

	if (new_mType) {
		mType = &monsters[asLowerCaseString(monsterName)];
	}

	mType->name = attr.as_string();

	if ((attr = monsterNode.attribute("nameDescription"))) {
		mType->nameDescription = attr.as_string();
	} else {
		mType->nameDescription = "a " + mType->name;
		toLowerCaseString(mType->nameDescription);
	}

	if ((attr = monsterNode.attribute("race"))) {
		std::string tmpStrValue = asLowerCaseString(attr.as_string());
		uint16_t tmpInt = pugi::cast<uint16_t>(attr.value());
		if (tmpStrValue == "venom" || tmpInt == 1) {
			mType->race = RACE_VENOM;
		} else if (tmpStrValue == "blood" || tmpInt == 2) {
			mType->race = RACE_BLOOD;
		} else if (tmpStrValue == "undead" || tmpInt == 3) {
			mType->race = RACE_UNDEAD;
		} else if (tmpStrValue == "fire" || tmpInt == 4) {
			mType->race = RACE_FIRE;
		} else if (tmpStrValue == "energy" || tmpInt == 5) {
			mType->race = RACE_ENERGY;
		} else {
			std::cout << "[Warning - Monsters::loadMonster] Unknown race type " << attr.as_string() << ". " << file << std::endl;
		}
	}

	if ((attr = monsterNode.attribute("experience"))) {
		mType->experience = pugi::cast<uint64_t>(attr.value());
	}

	if ((attr = monsterNode.attribute("speed"))) {
		mType->baseSpeed = pugi::cast<int32_t>(attr.value());
	}

	if ((attr = monsterNode.attribute("manacost"))) {
		mType->manaCost = pugi::cast<uint32_t>(attr.value());
	}

	if ((attr = monsterNode.attribute("skull"))) {
		mType->skull = getSkullType(attr.as_string());
	}

	if ((attr = monsterNode.attribute("script"))) {
		monsterScriptList.emplace_back(mType, attr.as_string());
	}

	pugi::xml_node node;
	if ((node = monsterNode.child("health"))) {
		if ((attr = node.attribute("now"))) {
			mType->health = pugi::cast<int32_t>(attr.value());
		} else {
			std::cout << "[Error - Monsters::loadMonster] Missing health now. " << file << std::endl;
		}

		if ((attr = node.attribute("max"))) {
			mType->healthMax = pugi::cast<int32_t>(attr.value());
		} else {
			std::cout << "[Error - Monsters::loadMonster] Missing health max. " << file << std::endl;
		}
	}

	if ((node = monsterNode.child("flags"))) {
		for (auto flagNode : node.children()) {
//.........这里部分代码省略.........
开发者ID:Codex-NG,项目名称:TFS-Flash,代码行数:101,代码来源:monsters.cpp


示例5: FilterTargets

 void FilterTargets(std::list<Unit*>& unitList)
 {
     unitList.remove_if (OrientationCheck(GetCaster()));
 }
开发者ID:Kr4v3n5,项目名称:Core,代码行数:4,代码来源:boss_argent_challenge.cpp


示例6: get_pages_for_range

bool Vma::get_pages_for_range(const RangePtr &mrange,
			      std::list<PartialPageInfo> &ppinfo)
{
    ppinfo.clear();
    
    if (mrange->size() <= 0) {
	warn << "Vma::get_pages_for_range - invalid range\n";
	return false;
    }
    if (!range()->contains(mrange)) {
	warn << "Vma::get_pages_for_range - range "
	    << mrange->to_string() << " outside vma " << to_string() << "\n";
	return false;
    }

    unsigned int start_pgnum, end_pgnum;
    if (!addr_to_pgnum(mrange->start(), start_pgnum)) {
	warn << "Vma::get_pages_for_range - can't get start pgnum\n";
	return false;
    }
    if (!addr_to_pgnum(mrange->end() - 1, end_pgnum)) {
	warn << "Vma::get_pages_for_range - can't get end pgnum\n";
	return false;
    }
    if (start_pgnum > end_pgnum) {
	warn << "start_pgnum greater than end: "
	     << start_pgnum << ", " << end_pgnum << "\n";
	return false;
    }
    if (start_pgnum >= _pages.size()) {
	warn << "Vma::get_pages_for_range - start pgnum out of range: "
	     << start_pgnum << ", " << _pages.size() << " " << _fname << "\n";
	return false;
    }
    if (end_pgnum >= _pages.size()) {
	warn << "Vma::get_pages_for_range - end pgnum out of range: "
	     << end_pgnum << ", " << _pages.size() << "\n";
	return false;
    }

    if (start_pgnum == end_pgnum) {
	ppinfo.push_back(PartialPageInfo(_pages[start_pgnum], mrange->size()));
	return true;
    }

    Address bytes = Elf::page_size()
	- (mrange->start() - Elf::page_align_down(mrange->start()));
    ppinfo.push_back(PartialPageInfo(_pages[start_pgnum], bytes));

    bytes = mrange->end() - Elf::page_align_down(mrange->end() - 1);
    if (bytes > 0) {
	ppinfo.push_back(PartialPageInfo(_pages[end_pgnum], bytes));
    }

    bytes = Elf::page_size();
    for (unsigned int pgnum = start_pgnum + 1; pgnum < end_pgnum; ++pgnum) {
	ppinfo.push_back(PartialPageInfo(_pages[pgnum], bytes));
    }

    return true;
}
开发者ID:jbert,项目名称:exmap,代码行数:61,代码来源:Exmap.cpp


示例7: new

void M3U8Parser::parseSegments(vlc_object_t *p_obj, Representation *rep, const std::list<Tag *> &tagslist)
{
    SegmentList *segmentList = new (std::nothrow) SegmentList(rep);

    rep->setTimescale(100);
    rep->b_loaded = true;

    mtime_t totalduration = 0;
    mtime_t nzStartTime = 0;
    mtime_t absReferenceTime = VLC_TS_INVALID;
    uint64_t sequenceNumber = 0;
    bool discontinuity = false;
    std::size_t prevbyterangeoffset = 0;
    const SingleValueTag *ctx_byterange = NULL;
    SegmentEncryption encryption;
    const ValuesListTag *ctx_extinf = NULL;

    std::list<Tag *>::const_iterator it;
    for(it = tagslist.begin(); it != tagslist.end(); ++it)
    {
        const Tag *tag = *it;
        switch(tag->getType())
        {
            /* using static cast as attribute type permits avoiding class check */
            case SingleValueTag::EXTXMEDIASEQUENCE:
            {
                sequenceNumber = (static_cast<const SingleValueTag*>(tag))->getValue().decimal();
            }
            break;

            case ValuesListTag::EXTINF:
            {
                ctx_extinf = static_cast<const ValuesListTag *>(tag);
            }
            break;

            case SingleValueTag::URI:
            {
                const SingleValueTag *uritag = static_cast<const SingleValueTag *>(tag);
                if(uritag->getValue().value.empty())
                {
                    ctx_extinf = NULL;
                    ctx_byterange = NULL;
                    break;
                }

                HLSSegment *segment = new (std::nothrow) HLSSegment(rep, sequenceNumber++);
                if(!segment)
                    break;

                segment->setSourceUrl(uritag->getValue().value);
                if((unsigned)rep->getStreamFormat() == StreamFormat::UNKNOWN)
                    setFormatFromExtension(rep, uritag->getValue().value);

                if(ctx_extinf)
                {
                    if(ctx_extinf->getAttributeByName("DURATION"))
                    {
                        const mtime_t nzDuration = CLOCK_FREQ * ctx_extinf->getAttributeByName("DURATION")->floatingPoint();
                        segment->duration.Set(ctx_extinf->getAttributeByName("DURATION")->floatingPoint() * (uint64_t) rep->getTimescale());
                        segment->startTime.Set(rep->getTimescale().ToScaled(nzStartTime));
                        nzStartTime += nzDuration;
                        totalduration += nzDuration;

                        if(absReferenceTime > VLC_TS_INVALID)
                        {
                            segment->utcTime = absReferenceTime;
                            absReferenceTime += nzDuration;
                        }
                    }
                    ctx_extinf = NULL;
                }

                segmentList->addSegment(segment);

                if(ctx_byterange)
                {
                    std::pair<std::size_t,std::size_t> range = ctx_byterange->getValue().getByteRange();
                    if(range.first == 0)
                        range.first = prevbyterangeoffset;
                    prevbyterangeoffset = range.first + range.second;
                    segment->setByteRange(range.first, prevbyterangeoffset);
                    ctx_byterange = NULL;
                }

                if(discontinuity)
                {
                    segment->discontinuity = true;
                    discontinuity = false;
                }

                if(encryption.method != SegmentEncryption::NONE)
                    segment->setEncryption(encryption);
            }
            break;

            case SingleValueTag::EXTXTARGETDURATION:
                rep->targetDuration = static_cast<const SingleValueTag *>(tag)->getValue().decimal();
                break;

//.........这里部分代码省略.........
开发者ID:anutakay,项目名称:vlc-for-krasview,代码行数:101,代码来源:Parser.cpp


示例8: addWaitingPeople

void Floor::addWaitingPeople(const std::list<HumanPtr>& people) {
	containedPeople_.insert(containedPeople_.end(), people.begin(), people.end());
}
开发者ID:jkatghub,项目名称:tud-cpp-lecture,代码行数:3,代码来源:Floor.cpp


示例9: FilterTargets

 void FilterTargets(std::list<WorldObject*>& unitList)
 {
     unitList.remove_if(Trinity::ObjectGUIDCheck(GetCaster()->GetChannelObjectGuid()));
 }
开发者ID:AwkwardDev,项目名称:RE,代码行数:4,代码来源:spell_priest.cpp


示例10: FilterTargets

 void FilterTargets(std::list<Unit*>& unitList)
 {
     unitList.remove_if(SanctumSentryCheck());
 }
开发者ID:Elevim,项目名称:ChaosCore,代码行数:4,代码来源:boss_auriaya.cpp


示例11: countValueDuplicators

int countValueDuplicators(const std::list<TemplateBase<DuplicatorType> >& values)
{
    return values.size();
}
开发者ID:ethanhs,项目名称:shiboken2-android,代码行数:4,代码来源:photon.cpp


示例12: while

void GameState_BasePlayable::HandleSFEvents(std::list<sf::Event>& sfEvents) {
	mMenuStateMachine->RefreshStack();

	if (inoutFader != 0) {
		if (cancelNavMapGenBtn)
			cancelNavMapGenBtn->HandleSFEvents(sfEvents);

		std::list<sf::Event>::iterator itSfEvent = sfEvents.begin();
		while (itSfEvent != sfEvents.end()) {
			switch (itSfEvent->Type) {
				case sf::Event::Closed:
					Game->GetRenderWindow()->Close();
				break;
				default:
				break;
			}

			++itSfEvent;
		}

		return;
	}

	if (!mMenuStateMachine->IsEmpty())
		mMenuStateMachine->HandleSFEvents(sfEvents);

	std::list<sf::Event>::iterator itSfEvent = sfEvents.begin();
	while (itSfEvent != sfEvents.end()) {
		switch (itSfEvent->Type) {
			case sf::Event::Closed:
				Game->GetRenderWindow()->Close();
			break;
			case sf::Event::KeyPressed:
				switch (itSfEvent->Key.Code) {
					case sf::Key::Escape:
						if (!finished) {
							if (!mMenuStateMachine->IsEmpty())
								OnPause(false);
							else
								OnPause(true);
						}
					break;
					case sf::Key::Space:
						if (HUD) {
							GameObject* interactee = HUD->GetInteractee();
							if (interactee) {
								if (interactee == chest && chest) {
									goldPickedUp += MyMagicNumbers::goldValue_chest;

									for (unsigned int i = 0; i != 2; ++i) {
										if (objectives[i] == chest) {
											OnObjectiveCompleted(i);
											objectives[i] = 0;
										}
									}
									PopWorldSpace(chest);
									delete chest;
									chest = 0;

									SoundEffect* coinJingle = new SoundEffect("Content/Audio/coin.wav");
									coinJingle->oneShot = true;
									Sounds->RefreshVol_Effect_Of(coinJingle);
									coinJingle->Play();

									HUD->SetAmountGold(goldPickedUp);

									HUD->SetInteractContextNote(0);
								}
								else if (/*interactee == princess && */princess) {
									princess->StartFollowing(princess->IsFollowingAnyone() ?
																0 : player);

									HUD->SetInteractContextNote(0);


									// if following than it's considered completed..
									if (princess->IsFollowingAnyone()) {
										for (unsigned int i = 0; i != 2; ++i) {
											// if it was the active objective
											if (objectives[i] == princess
													&& objectives[i]->objectiveState == ACTIVE) {
												OnObjectiveCompleted(i);
											}
										}
									}
									else {
										// However..
										for (unsigned int i = 0; i != 2; ++i) {
											// if the active objective is a goal
											if (objectives[i]
													&& objectives[i]->objectiveState == ACTIVE
													&& objectives[i]->entityType == ID_GOAL) {

												// looking backwards
												for (int j = i - 1; j >= 0; --j) {
													// j represents the last objective

													// if it was this princess
													if (objectives[j] == princess) {
														// then that princess should have been brought here
//.........这里部分代码省略.........
开发者ID:matyicsapo,项目名称:Infiltrator,代码行数:101,代码来源:GameState_BasePlayable.cpp


示例13: startAutoWalk

void Creature::startAutoWalk(const std::list<Direction>& listDir)
{
	listWalkDir = listDir;
	addEventWalk(listDir.size() == 1);
}
开发者ID:HeavenIsLost,项目名称:ChronusServer,代码行数:5,代码来源:creature.cpp


示例14: MouseTest

void MouseTest( GLFWwindow* window, GameObjectBird *pBird, ScreenLine* pLine1, ScreenLine* pLine2, std::list<GameObject *>  gameObjectList  )
{

	// Quick and dirty test, if these work the rest do.
	// --> try move the mouse inside the window, click right, click left
	if (!pBird)
		return;
	
	if (pBird->bState==SLING)
	{
		pBird->pBody->SetActive(false);
		b2Vec2 newPos( PixelToMeter((float)slingX), PixelToMeter((float)slingY) );
		pBird->pBody->SetTransform( newPos, 0.0f );
	}

	double xpos;
	double ypos;

	static float lastXPos;
	static float lastYPos;
	// get mouse position
	glfwGetCursorPos( window, &xpos, &ypos);
	Camera *pCam = Camera::Instance();
	pCam;
	// correct for origin
	double t = ypos / 600.0;
	ypos = 600.0 + t * (-600.0);


	MouseState			mState = NONE;
	PositionState		pState = UNKNOWN;

	GameObject* b = pBird;
	Matrix viewMatrix = pCam->getViewMatrix();
	Matrix projMatrix = pCam->getProjMatrix();
	Matrix worldMatrix = b->pGameSprite->returnWorld();
	Vect vout = Vect(0.0f,0.0f,0.0f) * worldMatrix * viewMatrix * projMatrix; 
	float zoom = vout[w];
	
	vout[x] = vout[x]/vout[w];
	vout[y] = vout[y]/vout[w];

	float X = (vout[x]+1.0f)*(pCam->viewport_width/2.0f);
	float Y= (vout[y]+1.0f)*(pCam->viewport_height/2.0f);

	Vect birdPos(pBird->pos.x, pBird->pos.y,0.0f);
	Vect mousePos((float ) xpos,(float ) ypos, 0.0f);
	
	Vect local( X, Y, 0.0f);
	Vect Dist = mousePos - local;
	
	if ( Dist.mag() < (10.0f / zoom) )
	{
		pState = INSIDE;
	}
	else
	{
		pState = OUTSIDE;
	}
	//printf("%f - %f", Dist[x],Dist[y] );
	//printf("  |  %f - %f", X, Y );
	//xpos = xpos + Dist[x]*zoom;
	//ypos = ypos + Dist[y]*zoom;
	//printf("%f - %f ",xpos, ypos);
	mState = NONE;
	if( glfwGetMouseButton (window, GLFW_MOUSE_BUTTON_RIGHT ) == GLFW_PRESS)
	{
		mState = RIGHT;
	}

	if( glfwGetMouseButton (window, GLFW_MOUSE_BUTTON_LEFT ) == GLFW_PRESS)
	{
		
		mState = LEFT;
	}

	if (mState == LEFT && pBird->bState == NORMAL1)
	{
		pBird->bState = NORMAL2;
		pBird->onMouseAction();
		
	}

// Enter MOVING state
	if( mState == LEFT && pState == INSIDE)
	{
		;
		pBird->bState = MOVING;
		pBird->pBody->SetActive(false);
	}
	
	// small sublty here, once moving, left dictates mode
	if ( pBird->bState == MOVING)
	{
		if( mState == LEFT )//this drags the bird around
		{
			/*b2Vec2 newPos( PixelToMeter((float)xpos), PixelToMeter((float)ypos) );
			pBird->pBody->SetTransform( newPos, 0.0f );
			
			pLine1->posB=B;
//.........这里部分代码省略.........
开发者ID:TylerStewart,项目名称:GrumpyAvians,代码行数:101,代码来源:Input.cpp


示例15: readLevelEdit

void levelClass::readLevelEdit(std::string nameLevel, std::list<infoEvent>& listEvent, std::list<characterClass*>& listEnemy, std::map<std::pair<int, int>, itemClass*>& mapLevel, int& endOfLevel, int& heightLevel, std::string& typeLevel)
{
    std::ifstream file(nameLevel.c_str());

    if(file.is_open())
    {
        std::string line;
        std::string typeLine = "END";
        while(std::getline(file, line))
        {
            if(line == "END")
            {
                if(typeLine == "SPAWN_ENEMY" || typeLine == "CHANGE_MAP")
                    typeLine = "EVENT";
                else
                    typeLine = "END";
            }
            if(typeLine == "MAP")
            {
                std::string name = line.substr(0, line.find(' '));
                line.erase(0, line.find(' ') + 1);
                std::string poseX = line.substr(0, line.find(' '));
                line.erase(0, line.find(' ') + 1);
                std::string poseY = line;
                mapLevel.insert(std::pair<std::pair<int, int>, itemClass*>(std::pair<int, int>(std::atoi(poseX.c_str()), std::atoi(poseY.c_str())), new basicBlocClass(name, std::atoi(poseX.c_str()), std::atoi(poseY.c_str()))));
            }
            else if(typeLine == "ENEMY")
            {
                std::string name = line.substr(0, line.find(' '));
                line.erase(0, line.find(' ') + 1);
                std::string poseX = line.substr(0, line.find(' '));
                line.erase(0, line.find(' ') + 1);
                std::string poseY = line;
                if(name == "BOSS")
                    listEnemy.push_back(new bossEnemyClass(std::atoi(poseX.c_str()), std::atoi(poseY.c_str()), name));
                else
                    listEnemy.push_back(new basicEnemyClass(std::atoi(poseX.c_str()), std::atoi(poseY.c_str()), name));
            }
            else if(typeLine == "EVENT")
            {
                std::string name = line.substr(0, line.find(' '));
                line.erase(0, line.find(' ') + 1);
                if(name == "MESSAGE")
                {
                    std::string poseX = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string poseY = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string width = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string height = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string message = line;
                    while(message.find("\\n") != std::string::npos)
                    {
                        message.replace(message.find("\\n"), 2, "&n");
                    }
                    infoEvent tmp;
                    sf::RectangleShape surface;
                    surface.setPosition(std::atoi(poseX.c_str()), std::atoi(poseY.c_str()));
                    surface.setSize(sf::Vector2f(std::atoi(width.c_str()), std::atoi(height.c_str())));
                    surface.setFillColor(sf::Color::Cyan);
                    tmp.name = "MESSAGE";
                    tmp.surface = surface;
                    tmp.valX = 0;
                    tmp.valY = 0;
                    tmp.action.push_back(message);
                    listEvent.push_back(tmp);
                }
                else if(name == "SPAWN_ENEMY")
                {
                    std::string poseX = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string poseY = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string width = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string height = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string newPoseX = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string newPoseY = line;
                    sf::RectangleShape surface;
                    surface.setPosition(std::atoi(poseX.c_str()), std::atoi(poseY.c_str()));
                    surface.setSize(sf::Vector2f(std::atoi(width.c_str()), std::atoi(height.c_str())));
                    surface.setFillColor(sf::Color::Cyan);
                    infoEvent tmp;
                    tmp.name = "SPAWN_ENEMY";
                    tmp.surface = surface;
                    tmp.valX = std::atoi(newPoseX.c_str());
                    tmp.valY = std::atoi(newPoseY.c_str());
                    typeLine = "SPAWN_ENEMY";
                    listEvent.push_back(tmp);
                }
                else if(name == "CHANGE_MAP")
                {
                    std::string poseX = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string poseY = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
//.........这里部分代码省略.........
开发者ID:LEpigeon888,项目名称:ProjectElectricity,代码行数:101,代码来源:level.cpp


示例16: skips

void Stage::execute(StreamPointTable& table, std::list<Stage *>& stages)
{
    std::vector<bool> skips(table.capacity());
    std::list<Stage *> filters;
    SpatialReference srs;

    // Separate out the first stage.
    Stage *reader = stages.front();

    // Build a list of all stages except the first.  We may have a writer in
    // this list in addition to filters, but we treat them in the same way.
    auto begin = stages.begin();
    begin++;
    std::copy(begin, stages.end(), std::back_inserter(filters));

    for (Stage *s : stages)
    {
        s->ready(table);
        srs = s->getSpatialReference();
        if (!srs.empty())
            table.setSpatialReference(srs);
    }

    // Loop until we're finished.  We handle the number of points up to
    // the capacity of the StreamPointTable that we've been provided.

    bool finished = false;
    while (!finished)
    {
        // Clear the spatial reference when processing starts.
        table.clearSpatialReferences();
        PointId idx = 0;
        PointRef point(table, idx);
        point_count_t pointLimit = table.capacity();

        // When we get false back from a reader, we're done, so set
        // the point limit to the number of points processed in this loop
        // of the table.
        for (PointId idx = 0; idx < pointLimit; idx++)
        {
            point.setPointId(idx);
            finished = !reader->processOne(point);
            if (finished)
                pointLimit = idx;
        }
        srs = reader->getSpatialReference();
        if (!srs.empty())
            table.setSpatialReference(srs);

        // When we get a false back from a filter, we're filtering out a
        // point, so add it to the list of skips so that it doesn't get
        // processed by subsequent filters.
        for (Stage *s : filters)
        {
            for (PointId idx = 0; idx < pointLimit; idx++)
            {
                if (skips[idx])
                    continue;
                point.setPointId(idx);
                if (!s->processOne(point))
                    skips[idx] = true;
            }
            srs = s->getSpatialReference();
            if (!srs.empty())
                table.setSpatialReference(srs);
        }

        // Yes, vector<bool> is terrible.  Can do something better later.
        for (size_t i = 0; i < skips.size(); ++i)
            skips[i] = false;
        table.reset();
    }

    for (Stage *s : stages)
        s->done(table);
}
开发者ID:FeodorFitsner,项目名称:PDAL,代码行数:76,代码来源:Stage.cpp


示例17: readLevel

void levelClass::readLevel(std::string nameLevel, std::list<eventClass*>& listEvent, std::list<characterClass*>& listEnemy, std::map<std::pair<int, int>, itemClass*>& mapLevel, int& endOfLevel, int& heightLevel, std::string& typeLevel, int poseXPlayer, lightManagerClass& lightManager)
{
    std::ifstream file(nameLevel.c_str());

    if(file.is_open())
    {
        std::string line;
        std::string typeLine = "END";
        spawnEnemyEventClass* tmpEventSpawn;
        changeMapEventClass* tmpChangeMap;
        while(std::getline(file, line))
        {
            if(line == "END")
            {
                if(typeLine == "SPAWN_ENEMY" || typeLine == "CHANGE_MAP")
                    typeLine = "EVENT";
                else
                    typeLine = "END";
            }
            if(typeLine == "MAP")
            {
                std::string name = line.substr(0, line.find(' '));
                line.erase(0, line.find(' ') + 1);
                std::string poseX = line.substr(0, line.find(' '));
                line.erase(0, line.find(' ') + 1);
                std::string poseY = line;
                mapLevel.insert(std::pair<std::pair<int, int>, itemClass*>(std::pair<int, int>(std::atoi(poseX.c_str()), std::atoi(poseY.c_str())), new basicBlocClass(name, std::atoi(poseX.c_str()), std::atoi(poseY.c_str()))));
            }
            else if(typeLine == "ENEMY")
            {
                std::string name = line.substr(0, line.find(' '));
                line.erase(0, line.find(' ') + 1);
                std::string poseX = line.substr(0, line.find(' '));
                line.erase(0, line.find(' ') + 1);
                std::string poseY = line;
                if(name == "BOSS")
                    listEnemy.push_back(new bossEnemyClass(std::atoi(poseX.c_str()), std::atoi(poseY.c_str()), name));
                else
                    listEnemy.push_back(new basicEnemyClass(std::atoi(poseX.c_str()), std::atoi(poseY.c_str()), name));
            }
            else if(typeLine == "EVENT")
            {
                std::string name = line.substr(0, line.find(' '));
                line.erase(0, line.find(' ') + 1);
                if(name == "MESSAGE")
                {
                    std::string poseX = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string poseY = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string width = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string height = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string message = line;
                    while(message.find("\\n") != std::string::npos)
                    {
                        message.replace(message.find("\\n"), 2, "\n");
                    }
                    if(std::atoi(poseX.c_str()) > poseXPlayer)
                    {
                        sf::RectangleShape surface;
                        surface.setPosition(std::atoi(poseX.c_str()), std::atoi(poseY.c_str()));
                        surface.setSize(sf::Vector2f(std::atoi(width.c_str()), std::atoi(height.c_str())));
                        listEvent.push_back(new messageEventClass(message, surface));
                    }
                }
                else if(name == "SPAWN_ENEMY")
                {
                    std::string poseX = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string poseY = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string width = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string height = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string newPoseX = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string newPoseY = line;
                    sf::RectangleShape surface;
                    surface.setPosition(std::atoi(poseX.c_str()), std::atoi(poseY.c_str()));
                    surface.setSize(sf::Vector2f(std::atoi(width.c_str()), std::atoi(height.c_str())));
                    tmpEventSpawn = new spawnEnemyEventClass(surface, std::atoi(newPoseX.c_str()), std::atoi(newPoseY.c_str()));
                    typeLine = "SPAWN_ENEMY";
                    listEvent.push_back(tmpEventSpawn);
                }
                else if(name == "CHANGE_MAP")
                {
                    std::string poseX = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string poseY = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string width = line.substr(0, line.find(' '));
                    line.erase(0, line.find(' ') + 1);
                    std::string height = line;
                    sf::RectangleShape surface;
                    surface.setPosition(std::atoi(poseX.c_str()), std::atoi(poseY.c_str()));
                    surface.setSize(sf::Vector2f(std::atoi(width.c_str()), std::atoi(height.c_str())));
                    tmpChangeMap = new changeMapEventClass(surface);
//.........这里部分代码省略.........
开发者ID:LEpigeon888,项目名称:ProjectElectricity,代码行数:101,代码来源:level.cpp


示例18: main

int main(int argc, char** argv) {
	int option;
    streamFile = argv[0]; // default
	while ((option = getopt(argc, argv, "zcsm:w:l:r:f:t:i:o:d:x:y:e:")) != -1) {
		switch(option) {
		case 'z':
			useZeroCopy = true;
			break;
        case 'y':
                compressionWithState = true;
                // fall through
		case 'x': {
            char* compArg = optarg;
            
            // http://stackoverflow.com/a/53878/990120
            std::list<std::string> compArgs;
            do {
                const char *begin = compArg;
                while(*compArg ! 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ std::map类代码示例发布时间:2022-05-31
下一篇:
C++ std::istringstream类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap