本文整理汇总了C++中List::Count方法的典型用法代码示例。如果您正苦于以下问题:C++ List::Count方法的具体用法?C++ List::Count怎么用?C++ List::Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类List
的用法示例。
在下文中一共展示了List::Count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Parse
bool StringPropertySet::Parse(const StringRef& str)
{
RETURN_TRUE_IF_EMPTY(str);
//Key=Value,...
List<StringRef> outPairs;
StringParser::Split(str, ",", outPairs);
List<StringRef> keyValuePair;
for (auto& optionPair : outPairs)
{
keyValuePair.Clear();
StringParser::Split(optionPair, "=", keyValuePair);
if (keyValuePair.Count() == 2)
{
Add(keyValuePair[0], keyValuePair[1]);
}
else if (keyValuePair.Count() == 1)
{
Add(keyValuePair[0], HeapString::Empty);
}
else
{
Log::FormatError("Invalid attribute str:{} in {}", optionPair.c_str(), str.c_str());
return false;
}
}
return true;
}
示例2: TestList
void TestList() {
List<int> a;
a.Add(3);
a.Add(5);
assert(a.Count() == 2);
assert(a.Contains(3));
assert(a.Contains(5));
assert(a[0] == 3);
List<int> b(a);
b.Add(a);
assert(b.Count() == 4);
a.Remove(3);
assert(a.Count() == 1);
assert(a.Contains(3) == false);
assert(a[0] = 5);
a.Insert(4, 0);
a.Insert(6, 1);
a.Insert(7, a.Count() - 1);
assert(a[0] == 4);
assert(a[1] == 6);
assert(a[2] == 7);
a.Remove(6);
assert(a[2] == 5);
}
示例3: Serialize
//
// Serialization.
//
virtual void Serialize(Stream &stream) const {
// Only the actions are saved.
stream.Write(actions_.Count());
for(size_t i = 0; i < actions_.Count(); i++) {
stream.Write((int)actions_[i]->Type());
stream.Write(*actions_[i]);
}
}
示例4: SearchDescendantClasses
void SearchDescendantClasses(ParsingSymbol* parent, ParsingSymbolManager* manager, List<ParsingSymbol*>& children)
{
vint start = children.Count();
SearchChildClasses(parent, manager->GetGlobal(), manager, children);
vint end = children.Count();
for (vint i = start; i < end; i++)
{
SearchDescendantClasses(children[i], manager, children);
}
}
示例5: WriteErrors
void WriteErrors(GuiResourceError::List& errors, const WString& resourceName)
{
auto outputPath = FilePath(GetTestOutputPath()) / (resourceName + L".txt");
auto baselinePath = FilePath(GetTestResourcePath()) / (resourceName + L".txt");
List<WString> output;
GuiResourceError::SortAndLog(errors, output, GetTestResourcePath());
File(outputPath).WriteAllLines(output, false, BomEncoder::Utf8);
List<WString> baseline;
File(baselinePath).ReadAllLinesByBom(baseline);
if (baseline.Count() > 0 && baseline[baseline.Count() - 1] == L"")
{
baseline.RemoveAt(baseline.Count() - 1);
}
vint count = output.Count();
if (count < baseline.Count())
{
count = baseline.Count();
}
for (vint i = 0; i < count; i++)
{
TEST_ASSERT(output.Count() > i);
TEST_ASSERT(baseline.Count() > i);
TEST_ASSERT(output[i] == baseline[i]);
}
}
示例6: Insert
void SkylineBinPack::Insert(List<Size2U> &sizes, List<Rect2U> &outRects, LevelChoiceHeuristic method)
{
while (sizes.Count() > 0)
{
Rect2U bestRect;
Size2U bestSize(Math::IntMaxValue, Math::IntMaxValue);
int bestSkylineIndex = -1;
int bestRectIndex = -1;
for (size_t i = 0; i < sizes.Count(); ++i)
{
Rect2U newRect;
Size2U outBestSize;
int outBestIndex = 0;
switch (method)
{
case LevelChoiceHeuristic::LevelBottomLeft:
newRect = FindPositionForNewNodeBottomLeft(sizes[i], outBestSize, outBestIndex);
break;
case LevelChoiceHeuristic::LevelMinWasteFit:
newRect = FindPositionForNewNodeMinWaste(sizes[i], outBestSize.Height, outBestSize.Width, outBestIndex);
break;
default:
assert(false);
break;
}
if (newRect.Size.Height != 0)
{
if (outBestSize.Width < bestSize.Width || (outBestSize.Width == bestSize.Width && outBestSize.Height < bestSize.Height))
{
bestRect = newRect;
bestSize = outBestSize;
bestSkylineIndex = outBestIndex;
bestRectIndex = (int)i;
}
}
}
if (bestRectIndex == -1)
return;
// Perform the actual packing.
AddSkylineLevel(bestSkylineIndex, bestRect);
mUsedSurfaceArea += (sizes[bestRectIndex]).Area();
sizes.RemoveAt(bestRectIndex);
outRects.Add(bestRect);
}
}
示例7: ShowDialog
bool GuiSaveFileDialog::ShowDialog()
{
List<WString> fileNames;
auto service = GetCurrentController()->DialogService();
if (!service->ShowFileDialog(
GetHostWindow()->GetNativeWindow(),
fileNames,
filterIndex,
(enabledPreview ? INativeDialogService::FileDialogSavePreview : INativeDialogService::FileDialogSave),
title,
fileName,
directory,
defaultExtension,
filter,
options))
{
return false;
}
if (fileNames.Count() > 0)
{
fileName = fileNames[0];
FileNameChanged.Execute(GuiEventArgs());
FilterIndexChanged.Execute(GuiEventArgs());
}
return true;
}
示例8: Append
// Override of the List interface
List* Append( VALUE elem ) {
#ifdef USE_CONS_OPTIMIZATIONS
List* tail = this;
while (!tail->Rest().IsEmpty() ) {
tail = tail->Rest().GetList();
}
if (tail->RefCount < 2 && tail->Rest().IsEmpty()) {
// We can optimize things as we can reuse this materalization.
// Nobody is referencing it.
if (tail->AttemptDirtyAdd(elem)) {
return this;
};
}
#endif
int originalCount = Count();
int last = Count()-1;
List* c = VALUE(QParenthesis,elem).GetList();
while (last >= 0) {
c = c->Prepend( GetAt(last) );
last--;
}
int newCount = c->Count();
assert( newCount == originalCount + 1 );
// std::cout << "\nBefore:" << LIST(this).Print();
// std::cout << "\nAdded:" << elem.Print();
// std::cout << "\nAfter:" << LIST(c).Print() << "\n";
return c;
}
示例9: Dispose
void Application::Dispose()
{
{
List<BaseForm *> forms;
for (auto & c : *components)
{
if (c.Value)
{
BaseForm * ctrl = dynamic_cast<BaseForm*>(c.Value);
if (ctrl)
{
forms.Add(ctrl);
}
c.Value = 0;
}
}
for (int i=0; i<forms.Count(); i++)
delete forms[i];
delete components;
delete cmdLine;
delete objMap;
delete onMainLoop;
}
GdiplusShutdown(gdiToken);
_CrtDumpMemoryLeaks();
}
示例10: FindFile
const FileEntry* FileStorage::FindFile(const StringRef& path, const DirectoryEntry* parent/* = nullptr*/) const
{
if (parent == nullptr)
{
parent = &mRootDir;
}
if (Path::IsPath(path))
{
List<HeapString> paths;
RETURN_NULL_IF_FALSE(Path::Split(path, paths));
const DirectoryEntry* dir = parent;
for (uint i = 0; i < paths.Count() - 1; ++i)
{
dir = dir->FindDirectory(paths[i]);
RETURN_NULL_IF_NULL(dir);
}
return dir->FindFile(paths.Last());
}
else
{
return parent->FindFile(path);
}
}
示例11: EvalFunctionReferenceClosure
void SymbolTable::EvalFunctionReferenceClosure()
{
for (auto & func : Functions)
{
List<String> funcList;
EnumerableHashSet<String> funcSet;
for (auto & ref : func.Value->ReferencedFunctions)
{
funcList.Add(ref);
funcSet.Add(ref);
}
for (int i = 0; i < funcList.Count(); i++)
{
RefPtr<FunctionSymbol> funcSym;
if (Functions.TryGetValue(funcList[i], funcSym))
{
for (auto rfunc : funcSym->ReferencedFunctions)
{
if (funcSet.Add(rfunc))
funcList.Add(rfunc);
}
}
}
func.Value->ReferencedFunctions = _Move(funcSet);
}
}
示例12: FindOrCreateFileEntry
FileEntry* FileStorage::FindOrCreateFileEntry(const StringRef& path, DirectoryEntry* parent /*= nullptr*/)
{
if (parent == nullptr)
{
parent = &mRootDir;
}
FileEntry* fileEntry = nullptr;
if (Path::IsPath(path))
{
List<HeapString> paths;
RETURN_NULL_IF_FALSE(Path::Split(path, paths));
DirectoryEntry* dir = parent;
for (uint i = 0; i < paths.Count() - 1; ++i)
{
dir = dir->FindOrCreateDirectoryEntry(paths[i]);
RETURN_NULL_IF_NULL(dir);
}
fileEntry = dir->FindOrCreateFileEntry(paths.Last());
}
else
{
fileEntry = parent->FindOrCreateFileEntry(path);
}
return fileEntry;
}
示例13: ClearActions
void ClearActions() {
for(size_t i = 0; i < actions_.Count(); i++) {
delete actions_[i];
}
actions_.Clear();
}
示例14: TryParse
bool Version::TryParse(const StringRef& versionString, Version& outVersion)
{
outVersion = Version::Zero;
List<HeapString> parts;
StringParser::Split(versionString, StringRef("."), parts);
uint length = (uint)parts.Count();
RETURN_FALSE_IF(length < 2 || length>4);
long outMajor;
if (parts[0].TryParseInt(outMajor))
{
outVersion.SetMajor((uint)outMajor);
}
else
{
return false;
}
long outMinor;
if (parts[1].TryParseInt(outMinor))
{
outVersion.SetMinor((uint)outMinor);
}
else
{
return false;
}
length -= 2;
if (length > 0)
{
long outBuild;
if (parts[2].TryParseInt(outBuild))
{
outVersion.SetBuild((uint)outBuild);
}
else
{
return false;
}
--length;
if (length > 0)
{
long outRevision;
if (parts[3].TryParseInt(outRevision))
{
outVersion.SetRevision((uint)outRevision);
}
else
{
return false;
}
}
}
return true;
}
示例15:
List<Vec4> ChoiceForm::ReadFrameData(GL::Texture2D tex)
{
List<Vec4> rs;
int w, h;
tex.GetSize(w, h);
rs.SetSize(w*h);
tex.GetData(0, DataType::Float4, rs.Buffer(), rs.Count()*sizeof(Vec4));
return rs;
}