本文整理汇总了C++中ObjList::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjList::insert方法的具体用法?C++ ObjList::insert怎么用?C++ ObjList::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjList
的用法示例。
在下文中一共展示了ObjList::insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insert
// Insert a record into a list in the proper location
// Order records ascending by their order
// Look at ascPref for records with the same order
bool DnsRecord::insert(ObjList& list, DnsRecord* rec, bool ascPref)
{
if (!rec || list.find(rec))
return false;
XDebug(DebugAll,"DnsRecord::insert(%p) order=%d pref=%d",rec,rec->order(),rec->pref());
ObjList* o = list.skipNull();
for (; o; o = o->skipNext()) {
DnsRecord* crt = static_cast<DnsRecord*>(o->get());
if (rec->order() > crt->order())
continue;
if (rec->order() == crt->order()) {
for (; o; o = o->skipNext()) {
DnsRecord* crt = static_cast<DnsRecord*>(o->get());
if (crt->order() != rec->order())
break;
if (crt->pref() == rec->pref())
continue;
if (ascPref == (rec->pref() < crt->pref()))
break;
}
}
break;
}
if (o)
o->insert(rec);
else
list.append(rec);
return true;
}
示例2: install
bool MessageDispatcher::install(MessageHandler* handler)
{
DDebug(DebugAll,"MessageDispatcher::install(%p)",handler);
if (!handler)
return false;
Lock lock(this);
ObjList *l = m_handlers.find(handler);
if (l)
return false;
unsigned p = handler->priority();
int pos = 0;
for (l=&m_handlers; l; l=l->next(),pos++) {
MessageHandler *h = static_cast<MessageHandler *>(l->get());
if (!h)
continue;
if (h->priority() < p)
continue;
if (h->priority() > p)
break;
// at the same priority we sort them in pointer address order
if (h > handler)
break;
}
m_changes++;
if (l) {
XDebug(DebugAll,"Inserting handler [%p] on place #%d",handler,pos);
l->insert(handler);
}
else {
XDebug(DebugAll,"Appending handler [%p] on place #%d",handler,pos);
m_handlers.append(handler);
}
handler->m_dispatcher = this;
if (handler->null())
Debug(DebugInfo,"Registered broadcast message handler %p",handler);
return true;
}
示例3: pushOne
void ExpEvaluator::pushOne(ObjList& stack, ExpOperation* oper)
{
if (oper)
stack.insert(oper);
}