本文整理汇总了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));
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
}
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}
示例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;
}
示例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++;
}
}
示例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;
}