本文整理汇总了C++中ChildList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ ChildList::push_back方法的具体用法?C++ ChildList::push_back怎么用?C++ ChildList::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ChildList
的用法示例。
在下文中一共展示了ChildList::push_back方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddChildren
virtual bool AddChildren(OWNERSHIP SContainer<T>* child)
{
if (std::find(children.begin(), children.end(), child)
!= children.end())
{
return false;
}
children.push_back(child);
return true;
}
示例2: deserialize
void ChildListType::deserialize(ChildList& list, const ArchiveNode& node, IUniverse& universe) const {
if (node.is_array()) {
for (size_t i = 0; i < node.array_size(); ++i) {
const ArchiveNode& child = node[i];
ObjectPtr<> ptr = deserialize_object(child, universe);
if (ptr != nullptr) {
list.push_back(std::move(ptr));
}
}
}
}
示例3: flatten
void SceneNode::flatten()
{
ChildList children;
for(auto child : m_children)
{
child->set_transform(m_trans * child->m_trans);
child->flatten();
for(auto gchild : child->m_children)
{
children.push_back(gchild);
}
child->m_children.clear();
children.push_back(child);
}
m_children.swap(children);
}
示例4: if
std::tuple<ChildList,ChildList, ChildList> AttendanceSheets::assignToRooms(std::vector<Child> childrenInNursery, int month, int year) {
ChildList poosRoos;
ChildList piglets;
ChildList tiggers;
for (auto child: childrenInNursery) {
// Get middle of month
int daysInMonth = TimeUtils::daysInMonth(month, year);
system_clock::time_point middleOfMonth = TimeUtils::dateToTimePoint(daysInMonth/2, month, year);
int ageOnDate = getAgeOnDate(child.dob, middleOfMonth);
if (ageOnDate < 2) poosRoos.push_back(child);
else if (ageOnDate < 3) piglets.push_back(child);
else tiggers.push_back(child);
}
auto listsByRooms = std::make_tuple (poosRoos, piglets, tiggers);
return listsByRooms;
}
示例5: getChildList
TreeLeaf::ChildList TreeLeaf::getChildList ()
{
ChildList childs;
//
for (int i = 0; i < this->childCount(); i++)
{
TreeLeaf* ptr_actual = (TreeLeaf*) this->child(i);
Q_ASSERT ( ptr_actual );
//
childs.push_back(ptr_actual);
};
//
return childs;
}
示例6: AddChild
bool DeltaDrawablePrivate::AddChild(DeltaDrawable* child, DeltaDrawable* parent)
{
if (!CanBeChild(child))
{
Log::GetInstance().LogMessage(Log::LOG_WARNING, __FILE__,
"DeltaDrawable: '%s' cannot be added as a child to '%s'",
child->GetName().c_str(), parent->GetName().c_str());
return false;
}
child->SetParent(parent);
mChildList.push_back(child);
if (mParentScene)
{
child->AddedToScene(mParentScene);
}
return true;
}
示例7: noDuplicateNodes
// Compares all pairs of children, finding and removing duplicate BTERMs
void noDuplicateNodes( ChildList &l )
{
//This is shallow!
//ONLY SAFE WHEN DELETING BTERMS for now (note is prev to Aug 2009)
// BK Aug 21, 2009: seems to be deep compare and deep delete
ChildList dups;
CLIter n1 = l.begin();
CLIter n2 = ++(l.begin());
CLIter end = l.end();
while( n1 != end ){
//assert((*n1)->t == BTERM);
while( n2 != end ){
//Comparison
if( (*n1)->equals(*n2) ){
dups.push_back(*n2);
}
n2++;
}
n1++;
n2 = n1;
n2++;
}
dups.sort();
dups.unique();
for(n2 = dups.begin(); n2 != dups.end(); n2++){
for(n1 = l.begin(); n1 != l.end(); n1++){
if(*n1 == *n2){
(*n1)->destroyTree();
l.erase(n1);
break;
}
}
}
dups.clear();
}
示例8: traverse
bool Importer::traverse(NodeHandler *handler, void *n, void *c, Core::BaseObject *target) {
xmlNodePtr node = reinterpret_cast<xmlNodePtr>(n);
xmlNodePtr childs = reinterpret_cast<xmlNodePtr>(c);
ChildList remaining;
TagSet mandatory;
handler->init(target, n, mandatory);
bool result = true;
for ( xmlNodePtr child = childs; child != NULL; child = child->next ) {
if ( child->type != XML_ELEMENT_NODE ) continue;
handler->propagate(NULL, false, true);
try {
handler->get(target, child);
}
catch ( std::exception &e ) {
if ( handler->isOptional )
SEISCOMP_WARNING("(optional) %s.%s: %s", node->name, child->name, e.what());
else
throw e;
}
if ( !handler->isOptional )
mandatory.erase((const char*)child->name);
if ( handler->object == NULL && handler->isAnyType ) {
if ( _any.get(target, child) ) {
handler->object = _any.object;
handler->childHandler = _any.childHandler;
handler->newInstance = _any.newInstance;
}
}
Core::BaseObject *newTarget = handler->object;
MemberNodeHandler *memberHandler = handler->memberHandler;
NodeHandler *childHandler = handler->childHandler;
bool newInstance = handler->newInstance;
bool optional = handler->isOptional;
if ( newTarget ) {
if ( childHandler == NULL ) {
childHandler = _typemap->getHandler(newTarget->className());
if ( childHandler == NULL ) {
SEISCOMP_WARNING("No class handler for %s", newTarget->className());
if ( newInstance )
delete newTarget;
handler->object = NULL;
newTarget = NULL;
childHandler = &_none;
}
}
}
else
childHandler = &_none;
try {
if ( traverse(childHandler, child, child->children, handler->object) ) {
if ( newTarget && newInstance && !memberHandler )
remaining.push_back(newTarget);
}
else {
if ( newTarget && newInstance )
delete newTarget;
newTarget = NULL;
if ( optional )
SEISCOMP_INFO("Invalid %s element: ignoring", child->name);
else {
SEISCOMP_WARNING("%s is not optional within %s", child->name, node->name);
result = false;
}
}
}
catch ( std::exception &e ) {
SEISCOMP_WARNING("%s: %s", child->name, e.what());
if ( newTarget ) {
if ( newInstance )
delete newTarget;
if ( !optional ) {
SEISCOMP_WARNING("%s is not optional within %s", child->name, node->name);
result = false;
}
else
SEISCOMP_WARNING("%s: ignoring optional member %s: invalid", node->name, child->name);
newTarget = NULL;
}
}
if ( memberHandler ) {
if ( !memberHandler->finalize(target, newTarget) ) {
if ( newTarget && newInstance )
remaining.push_back(newTarget);
}
}
}
//.........这里部分代码省略.........
示例9: distribute
///////////////////
// Post-conditions (memory management):
// Every node listed in bterms is either affixed to this node or deleted.
//
// Distributes a conjunction of clauses.
//
int SymNode::distribute(){
if(t != SAND){
cerr << "distribute called on a non \"and\" node"<<endl;
assert(t != SAND);
}
debout("d1");
//Ensure that there are no ANDs as children
removeParens();
debout("d1.1");
CLIter current;
ChildList * bterms = new ChildList();
current = children.begin();
// Separate the complex terms from the BTerms;
// children will contain only complex terms (i.e. ORs)
while( current != children.end() ){
if((*current)->t == BTERM){
bterms->push_back(*current);
current = children.erase(current);
}else{
current++;
}
}
debout("d2");
// Continue to call distr(Node,Node) until all of my children are
// distributed. Recall that children contain ONLY complex nodes.
while(children.size() > 1 ){
debout( "d3.1");
SymNode *result = distr( *(children.begin()), *(++children.begin()) );
// BK 8/21/2009 cull to save run-time
if (result->t != SAND){
for(CLIter rc = result->children.begin(); rc != result->children.end(); ){
if( (*rc)->cullNode2() ){
rc++;
}else{
rc = result->children.erase(rc);
}
}
}
// END BK 8/21/2009
children.pop_front();
children.pop_front();
debout("d3.2\nresult tree");
deb(result->printTree(0));
debout("d3.2.1");
//MARK added this
assert(result!=0);
if(result->t == SAND){
// Result is an AND node, so add its children to the bterms list
debout("result->t == SAND)");
bterms->splice(bterms->begin(),result->children);
noDuplicateNodes(*bterms);
delete result;
debout("leave result->t == SAND");
debout("bterms size: ");
deboutnn(bterms->size());
}else if( result->t == SOR ){
// Result being an OR, means we added to the children list
noDuplicateNodes(result->children);
addChild(result);
}else if(result->t == BTERM){
bterms->push_back(result);
}else if(result->t == FTYPE){
delete result;
}else{
cerr << "a returned result was not an \"and\" or an \"or\" or a BTERM" <<endl;
assert(0);
}
}
debout("d4");
if( children.size() == 0 && bterms->size() == 1 ){
cerr << "not possible yet.1" <<endl;
assert(0);
this->t = BTERM;
this->bt = (*(bterms->begin()))->bt;
delete bterms; // BK fixed unreachable leak
return 1;
}else if( children.size() == 0 && bterms->size() > 1){
//I stay an AND, but if we culled the ORs then I should be culled as well
//That scenario isn't implemented yet
children.swap(*bterms);
delete bterms;
return 1;
}else if( children.size() == 0 && bterms->size() == 0){
cerr << "not possible yet." <<endl;
assert(0);
}
// Distribute the leaf bterms into the remaining complex term.
debout("d5");
if( children.size() == 1 ){
//.........这里部分代码省略.........
示例10: toDNF
///////////////////////
// Post-condition (memory management):
// Always return a pointer to this node.
//
SymNode* SymNode::toDNF(){
debout("toDNF");
CLIter iter,end,dup;
if( t == BTERM || t == FTYPE || t == ETYPE || t == TTYPE){
debout("p:isLiteral");
return this;
}
//Ensure all of the clauses are in DNF
iter = children.begin();
end = children.end();
ChildList *newList = new ChildList();
while( iter != end ){
debout("loop:p1");
SymNode *returned;
returned = (*iter)->toDNF();
if( returned != NULL ){
newList->push_back(*iter);
}
iter++;
}
debout("p2");
this->children.swap( *newList );
newList->clear();
delete newList;
deboutnn( "toDNF: children.size(): ");
debout(children.size() );
//All chilren are false if they have been pruned by DNF
if( children.empty() ){
debout("p:shouldn\'t be happening");
assert(0);
this->destroyTree();
return new SymNode(FTYPE,-1);
}
debout("p3");
if( t == SOR ){
debout("p3.1");
//Then we are fine because all of the clauses are in DNF
this->removeParens();
//noDuplicateNodes(this->children);
return this;
} else if( t == SAND ){
debout("p4");
//We need to distribute "and" over the clauses that are in DNF already
//It's exponential time!!!!!!!!!
//TEMP MARK
// BK: this never happens, because distribute has not line: return 0;
if( this->distribute() == 0 ){
assert(0); //Shouldn't be happening
debout("p6 this->distribute() == 0");
//The children are false according to our restrictions and so this is false and therefor useless
this->destroyTree(); // BK fixed possible leak
delete this;
return new SymNode(FTYPE,-1);
}
debout("p5");
//noDuplicateNodes(this->children);
return this;
}else{
//raise exception "not" is not implemented
assert(0);
}
return NULL;
}