本文整理汇总了C++中Link::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Link::add方法的具体用法?C++ Link::add怎么用?C++ Link::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Link
的用法示例。
在下文中一共展示了Link::add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
// nを名前の辞書式順序で正しい位置に挿入し、先頭要素を返す
template<class T> Link<T>* Link<T>::add_ordered(Link* n){
if(n == nullptr || n->value.key() == "") return this;
Link* p = this;
if(p->value.key() > n->value.key()) return p->insert(n);
do{
p = p->succ;
if(p->value.key() > n->value.key()){
p->insert(n);
return this;
}
} while(p->succ != nullptr);
p->add(n);
return this;
}
示例2: generate
Link* Link::generate()
{
Link* n = new Link();
n->value = randint(1, 10);
n->level = 1;
Link* p = this;
if (p->find_total(n) != 0) // Если есть элемент на уровне ниже, то уже добавляем новый элемент слоем выше него.
{
p = p->find_lower(n);
n->level++;
if (p->find_total(n) != 0) // Есть уже элемент n->level 2
{
p = p->find_lower(n); // p это копия элемента n->level 2
n->level++; // Если есть - добавляем n на третий элемент, n->level стал 3
}
if (make_decision(100 / (n->level - 0.6))) // При решении добавить элемент.
{
cout << "Decision true on p value: " << n->value << ", level: " << n->level << " #" << cnt << '\n';
p = p->add(n);
cnt++;
}
else
{
cout << "Decision false on p value: " << n->value << " level: " << n->level << '\n';
return this;
}
p = p->set_neighbours();
return p;
}
if (p->find_total(n) != 0)
{
if (p->level + 1 < system_levels)
return this;
}
}
示例3: generate
Link* Link::generate()
{
Link* n = new Link();
n->value = randint(1, 10);
n->level = 1;
Link* p = this;
while (p->find_total(n)) // Если есть элемент на уровне ниже, то уже добавляем новый элемент слоем выше него.
{
p = p->find_total(n);
n->level++;
if (n->level == system_levels && n->level == 1 || n->level > system_levels)
{
n->level--; // n->level - 1, потому-что счётчик накручивает 5й элемент автоматом
cout << "Element already exists;" << setw(4) << " value: " << n->value << ", level: " << n->level << " string: " << str_cnt << '\n';
return this;
}
}
if (make_decision(100 / (n->level - 0.6))) // При решении добавить элемент.
{
cout << "Decision true on p " << setw(12) << "value: " << n->value << ", level: " << n->level << " #" << cnt << " string: " << str_cnt << '\n';
p = p->add(n);
cnt++;
str_cnt++;
}
else
{
cout << "Decision false on p " << setw(11) << "value: " << n->value << ", level: " << n->level << " string: " << str_cnt << '\n';
str_cnt++;
return this;
}
p = p->set_neighbours();
return p;
}
示例4: locker
pair<Bridge::shared_ptr, bool> LinkRegistry::declare(const std::string& name,
Link& link,
bool durable,
const std::string& src,
const std::string& dest,
const std::string& key,
bool isQueue,
bool isLocal,
const std::string& tag,
const std::string& excludes,
bool dynamic,
uint16_t sync,
uint32_t credit,
Bridge::InitializeCallback init,
const std::string& queueName,
const std::string& altExchange
)
{
Mutex::ScopedLock locker(lock);
// Durable bridges are only valid on durable links
if (durable && !link.isDurable()) {
QPID_LOG(error, "Can't create a durable route '" << name << "' on a non-durable link '" << link.getName());
return pair<Bridge::shared_ptr, bool>(Bridge::shared_ptr(), false);
}
if (dynamic) {
Exchange::shared_ptr exchange = broker->getExchanges().get(src);
if (exchange.get() == 0) {
QPID_LOG(error, "Exchange not found, name='" << src << "'" );
return pair<Bridge::shared_ptr, bool>(Bridge::shared_ptr(), false);
}
if (!exchange->supportsDynamicBinding()) {
QPID_LOG(error, "Exchange type does not support dynamic routing, name='" << src << "'");
return pair<Bridge::shared_ptr, bool>(Bridge::shared_ptr(), false);
}
}
BridgeMap::iterator b = bridges.find(name);
if (b == bridges.end())
{
_qmf::ArgsLinkBridge args;
Bridge::shared_ptr bridge;
args.i_durable = durable;
args.i_src = src;
args.i_dest = dest;
args.i_key = key;
args.i_srcIsQueue = isQueue;
args.i_srcIsLocal = isLocal;
args.i_tag = tag;
args.i_excludes = excludes;
args.i_dynamic = dynamic;
args.i_sync = sync;
args.i_credit = credit;
bridge = Bridge::shared_ptr
(new Bridge (name, &link, link.nextChannel(),
boost::bind(&LinkRegistry::destroyBridge, this, _1),
args, init, queueName, altExchange));
bridges[name] = bridge;
link.add(bridge);
if (durable && store && !broker->inRecovery())
store->create(*bridge);
QPID_LOG(debug, "Bridge '" << name <<"' declared on link '" << link.getName() <<
"' from " << src << " to " << dest << " (" << key << ")");
return std::pair<Bridge::shared_ptr, bool>(bridge, true);
}
return std::pair<Bridge::shared_ptr, bool>(b->second, false);
}