当前位置: 首页>>代码示例>>C++>>正文


C++ Array::push_back方法代码示例

本文整理汇总了C++中common::Array::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::push_back方法的具体用法?C++ Array::push_back怎么用?C++ Array::push_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common::Array的用法示例。


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

示例1: bringWordtoTop

void bringWordtoTop(char *str, int wordnum) {
	// This function reorders the words on the given pred.dic line
	// by moving the word at position 'wordnum' to the front (that is, right behind
	// right behind the numerical code word at the start of the line).
	Common::Array<Common::String> words;
	char buf[MAXLINELEN];

	if (!str)
		return;
	strncpy(buf, str, MAXLINELEN);
	buf[MAXLINELEN - 1] = 0;
	char *word = strtok(buf, " ");
	if (!word) {
		debug("Invalid dictionary line");
		return;
	}

	words.push_back(word);
	while ((word = strtok(NULL, " ")) != NULL)
		words.push_back(word);
	words.insert_at(1, words.remove_at(wordnum + 1));

	Common::String tmp;
	for (uint8 i = 0; i < words.size(); i++)
			tmp += words[i] + " ";
	tmp.deleteLastChar();
	memcpy(str, tmp.c_str(), strlen(str));
}
开发者ID:St0rmcrow,项目名称:scummvm,代码行数:28,代码来源:predictive.cpp

示例2: init

void TestbedExitDialog::init() {
	_xOffset = 25;
	_yOffset = 0;
	Common::String text = "Thank you for using ScummVM testbed! Here are yor summarized results:";
	addText(450, 20, text, Graphics::kTextAlignCenter, _xOffset, 15);
	Common::Array<Common::String> strArray;
	GUI::ListWidget::ColorList colors;

	for (Common::Array<Testsuite *>::const_iterator i = _testsuiteList.begin(); i != _testsuiteList.end(); ++i) {
		strArray.push_back(Common::String::format("%s :", (*i)->getDescription()));
		colors.push_back(GUI::ThemeEngine::kFontColorNormal);
		if ((*i)->isEnabled()) {
			strArray.push_back(Common::String::format("Passed: %d  Failed: %d Skipped: %d", (*i)->getNumTestsPassed(), (*i)->getNumTestsFailed(), (*i)->getNumTestsSkipped()));
		} else {
			strArray.push_back("Skipped");
		}
		colors.push_back(GUI::ThemeEngine::kFontColorAlternate);
	}

	addList(0, _yOffset, 500, 200, strArray, &colors);
	text = "More Details can be viewed in the Log file : " + ConfParams.getLogFilename();
	addText(450, 20, text, Graphics::kTextAlignLeft, 0, 0);
	if (ConfParams.getLogDirectory().size()) {
		text = "Directory : " + ConfParams.getLogDirectory();
	} else {
		text = "Directory : .";
	}
	addText(500, 20, text, Graphics::kTextAlignLeft, 0, 0);
	_yOffset += 5;
	addButtonXY(_xOffset + 80, _yOffset, 120, 24, "Rerun test suite", kCmdRerunTestbed);
	addButtonXY(_xOffset + 240, _yOffset, 60, 24, "Close", GUI::kCloseCmd);
}
开发者ID:AlbanBedel,项目名称:scummvm,代码行数:32,代码来源:testbed.cpp

示例3:

Common::Array<Common::String> SavesSyncRequest::getFilesToDownload() {
	Common::Array<Common::String> result;
	for (uint32 i = 0; i < _filesToDownload.size(); ++i)
		result.push_back(_filesToDownload[i].name());
	if (_currentDownloadingFile.name() != "")
		result.push_back(_currentDownloadingFile.name());
	return result;
}
开发者ID:86400,项目名称:scummvm,代码行数:8,代码来源:savessyncrequest.cpp

示例4:

Common::Array<const ASTCommand *> ASTLoop::listCommands(uint16 index) const {
	Common::Array<const ASTCommand *> list;

	if (condition) {
		list.push_back(condition->listCommands(index));
	}
	list.push_back(loopBlock->listCommands(index));

	return list;
}
开发者ID:Botje,项目名称:residualvm,代码行数:10,代码来源:abstractsyntaxtree.cpp

示例5:

Common::Array<Resources::Script *> Console::listAllLocationScripts() const {
	Common::Array<Resources::Script *> scripts;

	Resources::Level *level = StarkGlobal->getCurrent()->getLevel();
	Resources::Location *location = StarkGlobal->getCurrent()->getLocation();
	scripts.push_back(level->listChildrenRecursive<Resources::Script>());
	scripts.push_back(location->listChildrenRecursive<Resources::Script>());

	return scripts;
}
开发者ID:Botje,项目名称:residualvm,代码行数:10,代码来源:console.cpp

示例6: talkTxtNoDialog

void PackPrince::talkTxtNoDialog() {
	byte c;
	std::string line;
	Common::Array<TalkTxt> normalLinesArray;
	TalkTxt tempNormalLine;
	while (1) {
		// Special dialog data
		line.clear();
		while ((c = _databank.readByte()) != '\r') {
			line += c;
		}
		_databank.readByte(); // skip '\n'

		if (!line.compare("#HERO")) {
			tempNormalLine._dialogData = 1;
		} else if (!line.compare("#OTHER")) {
			tempNormalLine._dialogData = 4;
		} else if (!line.compare("#OTHER2")) {
			tempNormalLine._dialogData = 5;
		} else if (!line.compare("#PAUSE")) {
			tempNormalLine._dialogData = 254;
			tempNormalLine._txt.clear();
			normalLinesArray.push_back(tempNormalLine);
			continue;
		} else if (!line.compare("#END")) {
			break;
		}

		// Line of text
		tempNormalLine._txt.clear();
		while ((c = _databank.readByte()) != '\r') {
			c = correctPolishLetter(c); // temporary
			if (c == '|') {
				c = 10;
			}
			tempNormalLine._txt += c;
		}
		c = 0;
		tempNormalLine._txt += c;
		_databank.readByte(); // skip '\n'

		normalLinesArray.push_back(tempNormalLine);
	}

	// Offset counting and packing:
	for (uint i = 0; i < normalLinesArray.size(); i++) {
		_fFiles.writeByte(normalLinesArray[i]._dialogData);
		for (uint j = 0; j < normalLinesArray[i]._txt.size(); j++) {
			_fFiles.writeByte(normalLinesArray[i]._txt[j]);
		}
	}
	_fFiles.writeByte(255);
}
开发者ID:criezy,项目名称:scummvm-tools,代码行数:53,代码来源:pack_prince.cpp

示例7:

Common::Array<reg_t> ListTable::listAllOutgoingReferences(reg_t addr) const {
	Common::Array<reg_t> tmp;
	if (!isValidEntry(addr.offset)) {
		error("Invalid list referenced for outgoing references: %04x:%04x", PRINT_REG(addr));
	}

	const List *list = &(_table[addr.offset]);

	tmp.push_back(list->first);
	tmp.push_back(list->last);
	// We could probably get away with just one of them, but
	// let's be conservative here.

	return tmp;
}
开发者ID:rkmarvin,项目名称:scummvm,代码行数:15,代码来源:segment.cpp

示例8: computeVisibilityMatrix

void WalkRegion::computeVisibilityMatrix() {
	// Initialize visibility matrix
	_visibilityMatrix = Common::Array< Common::Array <int> >();
	for (uint idx = 0; idx < _nodes.size(); ++idx) {
		Common::Array<int> arr;
		for (uint idx2 = 0; idx2 < _nodes.size(); ++idx2)
			arr.push_back(Infinity);

		_visibilityMatrix.push_back(arr);
	}

	// Calculate visibility been vertecies
	for (uint j = 0; j < _nodes.size(); ++j) {
		for (uint i = j; i < _nodes.size(); ++i)   {
			if (isLineOfSight(_nodes[i], _nodes[j])) {
				// There is a line of sight, so save the distance between the two
				int distance = _nodes[i].distance(_nodes[j]);
				_visibilityMatrix[i][j] = distance;
				_visibilityMatrix[j][i] = distance;
			} else {
				// There is no line of sight, so save Infinity as the distance
				_visibilityMatrix[i][j] = Infinity;
				_visibilityMatrix[j][i] = Infinity;
			}
		}
	}
}
开发者ID:dergunov,项目名称:scummvm,代码行数:27,代码来源:walkregion.cpp

示例9:

Common::Array<reg_t> Script::listObjectReferences() const {
	Common::Array<reg_t> tmp;

	// Locals, if present
	if (_localsSegment)
		tmp.push_back(make_reg(_localsSegment, 0));

	// All objects (may be classes, may be indirectly reachable)
	ObjMap::iterator it;
	const ObjMap::iterator end = _objects.end();
	for (it = _objects.begin(); it != end; ++it) {
		tmp.push_back(it->_value.getPos());
	}

	return tmp;
}
开发者ID:BenCastricum,项目名称:scummvm,代码行数:16,代码来源:script.cpp

示例10: loadState

bool BuriedEngine::loadState(Common::SeekableReadStream *saveFile, Location &location, GlobalFlags &flags, Common::Array<int> &inventoryItems) {
    byte header[9];
    saveFile->read(header, kSavedGameHeaderSize);

    // Only compare the first 6 bytes
    // Win95 version of the game output garbage as the last two bytes
    if (saveFile->eos() || memcmp(header, s_savedGameHeader, kSavedGameHeaderSizeAlt) != 0)
        return false;

    Common::Serializer s(saveFile, 0);

    if (!syncLocation(s, location))
        return false;

    if (saveFile->eos())
        return false;

    if (!syncGlobalFlags(s, flags))
        return false;

    if (saveFile->eos())
        return false;

    uint16 itemCount = saveFile->readUint16LE();

    if (saveFile->eos())
        return false;

    inventoryItems.clear();
    for (uint16 i = 0; i < itemCount; i++)
        inventoryItems.push_back(saveFile->readUint16LE());

    return !saveFile->eos();
}
开发者ID:project-cabal,项目名称:cabal,代码行数:34,代码来源:saveload.cpp

示例11: updateState

void Inventory::updateState() {
	Common::Array<uint16> items;
	for (ItemList::iterator it = _inventory.begin(); it != _inventory.end(); it++)
		items.push_back(it->var);

	_vm->_state->updateInventory(items);
}
开发者ID:agharbi,项目名称:residual,代码行数:7,代码来源:inventory.cpp

示例12: listSavegames

void listSavegames(Common::Array<SavegameDesc> &saves) {
	Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();

	// Load all saves
	Common::StringList saveNames = saveFileMan->listSavefiles(((SciEngine *)g_engine)->getSavegamePattern());

	for (Common::StringList::const_iterator iter = saveNames.begin(); iter != saveNames.end(); ++iter) {
		Common::String filename = *iter;
		Common::SeekableReadStream *in;
		if ((in = saveFileMan->openForLoading(filename))) {
			SavegameMetadata meta;
			if (!get_savegame_metadata(in, &meta)) {
				// invalid
				delete in;
				continue;
			}
			delete in;

			SavegameDesc desc;
			desc.id = strtol(filename.end() - 3, NULL, 10);
			desc.date = meta.savegame_date;
			desc.time = meta.savegame_time;
			debug(3, "Savegame in file %s ok, id %d", filename.c_str(), desc.id);

			saves.push_back(desc);
		}
	}

	// Sort the list by creation date of the saves
	qsort(saves.begin(), saves.size(), sizeof(SavegameDesc), _savegame_index_struct_compare);
}
开发者ID:havlenapetr,项目名称:Scummvm,代码行数:31,代码来源:kfile.cpp

示例13:

Common::Array<AgeData> Database::loadAges(Common::ReadStreamEndian &s)
{
	Common::Array<AgeData> ages;

	for (uint i = 0; i < 10; i++) {
		AgeData age;

		if (_vm->getPlatform() == Common::kPlatformPS2) {
			// Really 64-bit values
			age.id = s.readUint32LE();
			s.readUint32LE();
			age.disk = s.readUint32LE();
			s.readUint32LE();
			age.roomCount = s.readUint32LE();
			s.readUint32LE();
			age.roomsOffset = s.readUint32LE() - _executableVersion->baseOffset;
			s.readUint32LE();
			age.labelId = s.readUint32LE();
			s.readUint32LE();
		} else {
			age.id = s.readUint32();
			age.disk = s.readUint32();
			age.roomCount = s.readUint32();
			age.roomsOffset = s.readUint32() - _executableVersion->baseOffset;
			age.labelId = s.readUint32();
		}

		ages.push_back(age);
	}

	return ages;
}
开发者ID:Harrypoppins,项目名称:grim_mouse,代码行数:32,代码来源:database.cpp

示例14: loadRoomNodeScripts

void Database::loadRoomNodeScripts(Common::SeekableSubReadStreamEndian *file, Common::Array<NodePtr> &nodes) {
	uint zipIndex = 0;
	while (1) {
		int16 id = file->readUint16();

		// End of list
		if (id == 0)
			break;

		if (id <= -10)
			error("Unimplemented node list command");

		if (id > 0) {
			// Normal node
			NodePtr node = NodePtr(new NodeData());
			node->id = id;
			node->zipBitIndex = zipIndex;
			node->scripts = loadCondScripts(*file);
			node->hotspots = loadHotspots(*file);

			nodes.push_back(node);
		} else {
			// Several nodes sharing the same scripts
			Common::Array<int16> nodeIds;

			for (int i = 0; i < -id; i++) {
				nodeIds.push_back(file->readUint16());
			}

			Common::Array<CondScript> scripts = loadCondScripts(*file);
			Common::Array<HotSpot> hotspots = loadHotspots(*file);

			for (int i = 0; i < -id; i++) {
				NodePtr node = NodePtr(new NodeData());
				node->id = nodeIds[i];
				node->zipBitIndex = zipIndex;
				node->scripts = scripts;
				node->hotspots = hotspots;

				nodes.push_back(node);
			}
		}

		zipIndex++;
	}
}
开发者ID:JoseJX,项目名称:residualvm,代码行数:46,代码来源:database.cpp

示例15:

Common::Array<uint32> Archive::getResourceTypeList() const {
	Common::Array<uint32> typeList;

	for (TypeMap::const_iterator it = _types.begin(); it != _types.end(); it++)
		typeList.push_back(it->_key);

	return typeList;
}
开发者ID:bSr43,项目名称:scummvm,代码行数:8,代码来源:resource.cpp


注:本文中的common::Array::push_back方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。