本文整理汇总了C++中WStrVec::RemoveAtFast方法的典型用法代码示例。如果您正苦于以下问题:C++ WStrVec::RemoveAtFast方法的具体用法?C++ WStrVec::RemoveAtFast怎么用?C++ WStrVec::RemoveAtFast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WStrVec
的用法示例。
在下文中一共展示了WStrVec::RemoveAtFast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RandomizeFiles
// Select random files to test. We want to test each file type equally, so
// we first group them by file extension and then select up to maxPerType
// for each extension, randomly, and inter-leave the files with different
// extensions, so their testing is evenly distributed.
// Returns result in <files>.
static void RandomizeFiles(WStrVec& files, int maxPerType)
{
WStrVec fileExts;
Vec<WStrVec *> filesPerType;
for (size_t i = 0; i < files.Count(); i++) {
const WCHAR *file = files.At(i);
const WCHAR *ext = path::GetExt(file);
CrashAlwaysIf(!ext);
int typeNo = fileExts.FindI(ext);
if (-1 == typeNo) {
fileExts.Append(str::Dup(ext));
filesPerType.Append(new WStrVec());
typeNo = (int)filesPerType.Count() - 1;
}
filesPerType.At(typeNo)->Append(str::Dup(file));
}
for (size_t j = 0; j < filesPerType.Count(); j++) {
WStrVec *all = filesPerType.At(j);
WStrVec *random = new WStrVec();
for (int n = 0; n < maxPerType && all->Count() > 0; n++) {
int idx = rand() % all->Count();
WCHAR *file = all->At(idx);
random->Append(file);
all->RemoveAtFast(idx);
}
filesPerType.At(j) = random;
delete all;
}
files.Reset();
bool gotAll = false;
while (!gotAll) {
gotAll = true;
for (size_t j = 0; j < filesPerType.Count(); j++) {
WStrVec *random = filesPerType.At(j);
if (random->Count() > 0) {
gotAll = false;
WCHAR *file = random->At(0);
files.Append(file);
random->RemoveAtFast(0);
}
}
}
for (size_t j = 0; j < filesPerType.Count(); j++) {
delete filesPerType.At(j);
}
}