本文整理匯總了C++中Collection::Count方法的典型用法代碼示例。如果您正苦於以下問題:C++ Collection::Count方法的具體用法?C++ Collection::Count怎麽用?C++ Collection::Count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Collection
的用法示例。
在下文中一共展示了Collection::Count方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: ControlsEnumFocusable
Control *XWindow::ControlGetFocused()
{
Collection<Control *> focusables = ControlsEnumFocusable();
for (int i=0; i<focusables.Count(); i++)
if (focusables[i]->IsFocused())
return focusables[i];
return focusables.Count() > 0 ? focusables[0] : NULL;
}
示例2: ControlFocusPrevious
void XWindow::ControlFocusPrevious()
{
Collection<Control *> focusables = ControlsEnumFocusable();
if (focusables.Count() == 0) return;
Control *focused = ControlGetFocused();
if (focused != NULL) focused->SetFocus(false);
int ix = focused == NULL ? 0 : controls->FindFirstIx(focused);
if (ix == -1) return;
ix += controls->Count() - 1;
ix = ix % controls->Count();
(*controls)[ix]->SetFocus(true);
}
示例3: Perform
int TestDictionary::Perform()
{
Dictionary<Text *, int> d1(Text::COMPARER);
d1.SetKey(new Text("Luis"), 10);
d1.SetKey(new Text("Pedro"), 4);
d1.SetKey(new Text("Alvaro"), 20);
d1.SetKey(new Text("Luis"), 12);
d1.SetKey(new Text("Zacarias"), 23);
d1.SetKey(new Text("Armando"), 15);
int iAux = 0;
Collection<Text *> keys = d1.Keys();
Collection<int> values = d1.Values();
for (int i=0; i<keys.Count(); i++) {
if (!d1.GetKey(keys[i], iAux)) {
StdOut::PrintLine("Dictionary<K, V>::GetKey didn't work!!!");
return -1;
}
if (iAux != values[i]) {
StdOut::PrintLine("Dictionary<K, V>::Values didn't work!!!");
return -1;
}
StdOut::PrintLine(*keys[i] + " " + iAux);
}
Text t = "Luis";
d1.ClearKey(&t);
if (d1.ExistsKey(&t)) {
StdOut::PrintLine("ClearKey and ExistsKey doesn't work!!!");
return -1;
}
NObjectDictionary d2;
d2.SetKey(new Text("Octubre"), new Text("Rojo"));
d2.SetKey(new Text("Manolo"), new Text("Machado"));
d2.SetKey(new Text("Carmen"), new Text("Chacon"));
d2.SetKey(new Text("Felipe"), new Text("González"));
NObject *oaux = NULL;
Collection<NObject *> d2keys = d2.Keys();
for (int i=0; i<d2keys.Count(); i++) {
if (d2.GetKey(d2keys[i], oaux)) continue;
StdOut::PrintLine("NObjectDictionary error!!!");
return -1;
}
StdOut::PrintLine(d2.ToText());
d2.DeleteAndClear();
try {
d2.SetKey(NULL, new Text("aaa"));
StdOut::PrintLine("Exception should have been raised.");
return -1;
} catch (Exception *e) {
delete e;
}
try {
d2.SetKey(new Text("aaa"), NULL);
StdOut::PrintLine("Exception should have been raised.");
return -1;
} catch (Exception *e) {
delete e;
}
return 0;
}