本文整理汇总了C++中AList::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ AList::Add方法的具体用法?C++ AList::Add怎么用?C++ AList::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AList
的用法示例。
在下文中一共展示了AList::Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CanBeStartingCity
int ARegion::CanBeStartingCity( ARegionArray *pRA )
{
if(type == R_OCEAN) return 0;
if (!IsCoastal()) return 0;
if (town && town->pop == 5000) return 0;
int regs = 0;
AList inlist;
AList donelist;
ARegionPtr * temp = new ARegionPtr;
temp->ptr = this;
inlist.Add(temp);
while(inlist.Num()) {
ARegionPtr * reg = (ARegionPtr *) inlist.First();
for (int i=0; i<NDIRS; i++) {
ARegion * r2 = reg->ptr->neighbors[i];
if (!r2) continue;
if (r2->type == R_OCEAN) continue;
if (GetRegion(&inlist,r2->num)) continue;
if (GetRegion(&donelist,r2->num)) continue;
regs++;
if (regs>20) return 1;
ARegionPtr * temp = new ARegionPtr;
temp->ptr = r2;
inlist.Add(temp);
}
inlist.Remove(reg);
donelist.Add(reg);
}
return 0;
}
示例2: ListUsers
void ADVBConfig::ListUsers(AList& list) const
{
AHash users(10);
AList userpatterns;
AString filepattern = GetUserPatternsPattern();
AString filepattern_parsed = ParseRegex(filepattern);
AString _users = GetConfigItem("users");
AStdFile fp;
uint_t i, n = _users.CountColumns();
//debug("Reading users from config %s\n", config.GetFilename().str());
for (i = 0; i < n; i++) {
AString user = _users.Column(i).Words(0);
if (!users.Exists(user)) {
users.Insert(user, 0);
list.Add(new AString(user));
}
}
if (fp.open(GetPatternsFile())) {
AString line;
while (line.ReadLn(fp) >= 0) {
AString user;
int p;
if ((p = line.PosNoCase(" user:=")) >= 0) user = line.Mid(p + 7).Word(0).DeQuotify();
else if (line.PosNoCase("user:=") == 0) user = line.Mid(6).Word(0).DeQuotify();
if (user.Valid() && !users.Exists(user)) {
users.Insert(user, 0);
list.Add(new AString(user));
}
}
fp.close();
}
::CollectFiles(filepattern.PathPart(), filepattern.FilePart(), 0, userpatterns);
const AString *file = AString::Cast(userpatterns.First());
while (file) {
AString user;
ADataList regions;
if (MatchRegex(*file, filepattern_parsed, regions)) {
const REGEXREGION *region = (const REGEXREGION *)regions[0];
if (region) {
user = file->Mid(region->pos, region->len);
if (!users.Exists(user)) {
users.Insert(user, 0);
list.Add(new AString(user));
}
}
}
file = file->Next();
}
list.Sort(&AString::AlphaCompareCase);
}
示例3: AGetName
//.........这里部分代码省略.........
rnd = getrandom(tSyll);
for (syllables = 0; rnd >= syllprob[syllables]; syllables++)
rnd -= syllprob[syllables];
syllables++;
temp[0] = 0;
trail = 0;
while (syllables-- > 0) {
if (!syllables) {
// Might replace the last syllable with a
// terrain specific suffix
rnd = getrandom(400);
similar = TerrainDefs[reg->type].similar_type;
// Use forest names for underforest
if (similar == R_UFOREST)
similar = R_FOREST;
// ocean (water) names for lakes
if (similar == R_LAKE)
similar = R_OCEAN;
// and plains names for cavern
if (similar == R_CAVERN)
similar = R_PLAIN;
for (u = 0; u < sizeof(ts) / sizeof(ts[0]); u++) {
if (ts[u].terrain == similar ||
ts[u].terrain == -1 ||
(ts[u].town && town) ||
(ts[u].port && port)) {
if (rnd >= ts[u].prob)
rnd -= ts[u].prob;
else {
if (trail) {
switch(ts[u].word[0]) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
strcat(temp, "'");
break;
default:
break;
}
}
strcat(temp, ts[u].word);
break;
}
}
}
if (u < sizeof(ts) / sizeof(ts[0]))
break;
}
if (getrandom(5) > 0) {
// 4 out of 5 syllables start with a consonant sequence
rnd = getrandom(tIC);
for (i = 0; rnd >= ic[i].prob; i++)
rnd -= ic[i].prob;
strcat(temp, ic[i].word);
} else if (trail) {
// separate adjacent vowels
strcat(temp, "'");
}
// All syllables have a vowel sequence
rnd = getrandom(tV);
for (i = 0; rnd >= v[i].prob; i++)
rnd -= v[i].prob;
strcat(temp, v[i].word);
if (getrandom(5) > 1) {
// 3 out of 5 syllables end with a consonant sequence
rnd = getrandom(tFC);
for (i = 0; rnd >= fc[i].prob; i++)
rnd -= fc[i].prob;
strcat(temp, fc[i].word);
trail = 0;
} else {
trail = 1;
}
}
temp[0] = toupper(temp[0]);
unique = 1;
forlist(®ionnames) {
name = (AString *) elem;
if (*name == temp) {
unique = 0;
break;
}
}
if (strlen(temp) > 12)
unique = 0;
}
nnames++;
if (town)
ntowns++;
else
nregions++;
name = new AString(temp);
regionnames.Add(name);
return regionnames.Num();
}