本文整理汇总了C++中IQ::push方法的典型用法代码示例。如果您正苦于以下问题:C++ IQ::push方法的具体用法?C++ IQ::push怎么用?C++ IQ::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IQ
的用法示例。
在下文中一共展示了IQ::push方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: topo_sort
void topo_sort(IV &in, IV &order) {
IQ q;
for (int i = 0; i < n; ++i) if (in[i] == 0) q.push(i);
order.clear();
while (! q.empty()) {
int v = q.front(); q.pop();
order.push_back(v);
cFor (EL, e, adj[v])
if (--in[e->v] == 0) q.push(e->v);
}
}
示例2: main
int main() {
const map<string, constants> comands = { { "add", constants::add },{ "get", constants::get },{ "del", constants::del } };
wstring libName;
wcin >> libName;
LPCWSTR wLibName = libName.c_str();
HINSTANCE lib = LoadLibrary(wLibName);
if (!lib) {
cout << "Library not found" << endl;
return 0;
}
int n;
cin >> n;
string line, word;
IQ<> *(*getQueue)() = (IQ<> *(*)())GetProcAddress(lib, "GetSomeIQ");
if (!getQueue)
return 0;
IQ<> *pQueue = getQueue();
if (!pQueue)
return 0;
cin.get();
for (int i = 0; i < n; ++i) {
getline(cin, line);
istringstream ss(line);
ss >> word;
try {
switch (comands.at(word)) {
case constants::add:
int value;
ss >> value;
pQueue->push(value);
break;
case constants::get:
try {
cout << pQueue->top() << endl;
}
catch (...) {
cout << "Queue is empty" << endl;
}
break;
case constants::del:
pQueue->pop();
break;
}
}
catch (...) {
cout << "Unknown command" << endl;
}
}
FreeLibrary(lib);
system("pause");
return 0;
}