本文整理汇总了C++中common::Array::insert_at方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::insert_at方法的具体用法?C++ Array::insert_at怎么用?C++ Array::insert_at使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::Array
的用法示例。
在下文中一共展示了Array::insert_at方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Cmd_DumpKnowledge
bool Console::Cmd_DumpKnowledge(int argc, const char **argv) {
Resources::Level *level = StarkGlobal->getCurrent()->getLevel();
Resources::Location *location = StarkGlobal->getCurrent()->getLocation();
Common::Array<Resources::Knowledge *> knowledge = level->listChildrenRecursive<Resources::Knowledge>();
knowledge.insert_at(knowledge.size(), location->listChildrenRecursive<Resources::Knowledge>());
Common::Array<Resources::Knowledge *>::iterator it;
for (it = knowledge.begin(); it != knowledge.end(); ++it) {
(*it)->print();
}
return true;
}
示例3: Cmd_ChangeKnowledge
bool Console::Cmd_ChangeKnowledge(int argc, const char **argv) {
uint index = 0;
char type = 0;
if (argc >= 4) {
index = atoi(argv[1]);
type = argv[2][0];
if (type == 'b' || type == 'i') {
Resources::Level *level = StarkGlobal->getCurrent()->getLevel();
Resources::Location *location = StarkGlobal->getCurrent()->getLocation();
Common::Array<Resources::Knowledge *> knowledgeArr = level->listChildrenRecursive<Resources::Knowledge>();
knowledgeArr.insert_at(knowledgeArr.size(), location->listChildrenRecursive<Resources::Knowledge>());
if (index < knowledgeArr.size() ) {
Resources::Knowledge *knowledge = knowledgeArr[index];
if (type == 'b') {
knowledge->setBooleanValue(atoi(argv[3]));
} else if (type == 'i') {
knowledge->setIntegerValue(atoi(argv[3]));
}
return true;
} else {
debugPrintf("Invalid index %d, only %d indices available\n", index, knowledgeArr.size());
}
} else {
debugPrintf("Invalid type: %c, only b and i are available\n", type);
}
} else {
debugPrintf("Too few args\n");
}
debugPrintf("Change the value of some knowledge. Use dumpKnowledge to get an id\n");
debugPrintf("Usage :\n");
debugPrintf("changeKnowledge [id] [type] [value]\n");
debugPrintf("available types: b(inary), i(nteger)\n");
return true;
}