Example #1
0
 void N::deleteChildren(N *node) {
     if (N::isLeaf(node)) {
         return;
     }
     switch (node->getType()) {
         case NTypes::N4: {
             auto n = static_cast<N4 *>(node);
             n->deleteChildren();
             return;
         }
         case NTypes::N16: {
             auto n = static_cast<N16 *>(node);
             n->deleteChildren();
             return;
         }
         case NTypes::N48: {
             auto n = static_cast<N48 *>(node);
             n->deleteChildren();
             return;
         }
         case NTypes::N256: {
             auto n = static_cast<N256 *>(node);
             n->deleteChildren();
             return;
         }
     }
     assert(false);
     __builtin_unreachable();
 }
Example #2
0
NodeBase::~NodeBase()
{
	deleteChildren();

	if (next != 0)
		next->previous = previous;
	if (previous != 0)
		previous->next = next;
	if (parent != 0)
	{
		if (parent->firstChild == this)
			parent->firstChild = next;
		if (parent->lastChild == this)
			parent->lastChild = previous;
	}

	// Delete outgoing edges.
	// TODO: Renders ingoing edges invalid. Assume or assert that all nodes on the same level are deleted?
	for (NodeBase::edge_iterator outEdgeIt(begin_outEdge());
			outEdgeIt != end_outEdge(); ++outEdgeIt)
	{
		delete *outEdgeIt;
	}

	--s_nodeCount;
	DEBUG_EXEC(
	if (s_nodeCount == 0)
		std::cout << "Deleted all tree nodes!" << std::endl;
	);
Example #3
0
 Json&Json::operator=(JsonConst jsonConst)
 {
     deleteChildren();
     switch (jsonConst) {
     case JsonConst::EmptyObject:
         mType = JsonType::Object;
         entries = new Map<Json>();
         break;
     case JsonConst::EmptyArray:
         mType = JsonType::Array;
         elements = new std::vector<Json>();
         break;
     case JsonConst::TRUE:
         mType = JsonType::Boolean;
         boolean = true;
         break;
     case JsonConst::FALSE:
         mType = JsonType::Boolean;
         boolean = false;
         break;
     case JsonConst::Null:
         mType = JsonType::Null;
         break;
     }
     return *this;
 }
Example #4
0
 Json& Json::operator=(Json&& other)
 {
     deleteChildren();
     memcpy(this, &other, sizeof(Json));
     memset(&other, 0, sizeof(Json));
     return *this;
 }
Example #5
0
void sLinsysRoot::sync()
{
  //delete children
  deleteChildren();
  //assert(false);

  //delete local stuff
  if( nxupp + nxlow > 0 ) {
    delete dd; 
    delete dq; 
  }
  delete nomegaInv;
  delete rhs;
  if (solver) delete solver;
  if (kkt)    delete kkt;


  //allocate
//  if( nxupp + nxlow > 0 ) {
    //dd      = OoqpVectorHandle(stochNode->newPrimalVector());
    //dq      = OoqpVectorHandle(stochNode->newPrimalVector());
    dd = stochNode->newPrimalVector();
    dq = stochNode->newPrimalVector();
    data->getDiagonalOfQ( *dq );
//  }
  nomegaInv   = stochNode->newDualZVector();
  rhs         = stochNode->newRhs();


  data->getLocalSizes(locnx, locmy, locmz);
  createChildren(data);

  kkt = createKKT(data);
  solver = createSolver(data, kkt);
}
Example #6
0
void deleteChildren(QTreeWidgetItem *item)
{
  while(item->childCount() > 0)
  {
    QTreeWidgetItem *child = item->takeChild(0);
    deleteChildren(child);
    delete child;
  }
}
Example #7
0
File: fs.cpp Project: KDE/kio-stash
void StashFileSystem::deleteChildren(StashNodeData nodeData)
{
    if (nodeData.children != nullptr) {
        Q_FOREACH (auto data, nodeData.children->values()) {
            deleteChildren(data);
        }
        delete nodeData.children;
        nodeData.children = nullptr;
    }
Example #8
0
TwObject::~TwObject()
{
    if (m_guardPtr->hasPtr())
    {
        m_guardPtr->clearGuardObject( this);
    }
    delete m_guardPtr;
    m_guardPtr = nullptr;

    deleteChildren();
    setParent(nullptr);
}
Example #9
0
void CExecPN::pop()
{
	if( m_cmd != NULL )
	{
		//cout << m_id << " " ;
		// execute the command
		m_cmd -> Exec( this ) ;
		// delete decendents
		deleteChildren();
		
		//cout << " **-> " << g_byte_cnt << endl;
	}
}
Example #10
0
// ------------------------------------------------------------------------------------------------------------------------------
bool Node::InitEmptyChildren(unsigned int numChildren) {
    if (numChildren == 0) {
        LOG_WARNING << "Initialize an empty children array with 0 elements";

        return false;
    }

    deleteChildren();
    NumChildren = numChildren;
    Children.resize(NumChildren);

    LOG_DEBUG << "Create an empty children! " << "NumChildren: " << NumChildren;
    return true;
}
Example #11
0
bool MorphTarget::loadFromFile(const QString &filename)
{
    QFile   file(filename);
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
        return false;
    QFileInfo fileInfo(filename);
    BasicTokenizer  tokenizer(&file);
    if (!_load(tokenizer)) {
        deleteChildren();
        file.close();
        qDebug() << "Invalid file";
        return false;
    }
    QFileInfo info(filename);
    setName(info.baseName());
    file.close();
    return true;
}
Example #12
0
// Reimplemented 
void QmvItem::setOpen( bool b )
{
    
        // State consistent already
    if ( b == open )
	return;
    open = b;

        // Add the children
    if ( open ) {
        createChildren();
        initChildren();
    } else {
        deleteChildren();
    }
    
    qApp->processEvents();
    listview->updateEditorSize();
}
Example #13
0
void Variable::setChildValues(const QVariantMap& data)
{
    deleteChildren();
    QMapIterator<QString, QVariant> i(data);
    while (i.hasNext()) {
        i.next();
        kDebug() << i.key() << i.value();
        KDevelop::Variable* xvar = currentSession()->variableController()->
            createVariable(model(), this,
                            i.key());
        Variable* var = static_cast<Variable*>(xvar);
        var->setTopLevel(false);
        appendChild(var);
        if (i.value().canConvert(QVariant::Map)) {
            var->setCrossfireValue(i.value().toMap());
        } else {
            var->setValue(i.value().toString());
        }
    }
}
Example #14
0
void intersectTrees(Node* root, char* p, Node* root2, char* p2)
{
	while(true)
	{
		if(p == root->last && p2 == root2->last)
		{
			 // intersect all possible subtrees
	 		int i;
			for(i=0; i<26; i++)
				if(root->suffix[i] != NULL && root2->suffix[i] != NULL)
					intersectTrees(root->suffix[i], root->suffix[i]->first, root2->suffix[i], root2->suffix[i]->first);
				else if(root->suffix[i] != NULL) // only tree 1 has child nodes -> we don't need them any more
				{
					deleteNode(root->suffix[i]);
					root->suffix[i] = NULL;
				}
			return;
		}
		else if(p == root->last) // move down in the first tree if possible
		{
			// we can forget about all other branches
			Node* child = root->suffix[*p2-97];
			root->suffix[*p2-97] = NULL;
			deleteChildrenExcept(root, child);
			if(child == NULL)
				return;
				
			if(root->parent != NULL) // merge this lonely node with its only child node
			{
				int strlen = root->last - root->first;
				// prepend string of this node
				child->first -= strlen; 
				// relink children
				root->parent->suffix[*(child->first)-97] = child;
				child->parent = root->parent;
				// finally get rid of this node
				deleteNode(root);
			}
				
			root = child;
			p = root->first;
		}
		else if (p2 == root2->last) // move down in the second tree if possible
		{
			if(root2->suffix[*p-97] == NULL)
			{
				// no further going down in tree 2 -> also forget about child nodes of tree 1
				deleteChildren(root);
				root->last = p;
				return;
			}
			root2 = root2->suffix[*p-97];
			p2 = root2->first;
		}
		else if(*p != *p2) // end of branch matching
		{
			deleteChildren(root);
			root->last = p;
			return;
		}
		else // match strings of local nodes
		{
			p++;
			p2++;
		}
	}
}
Example #15
0
/*!
 */
InnerNode::~InnerNode()
{
    deleteChildren();
    removeFromRelated();
}
Example #16
0
FileTreeItem::~FileTreeItem()
{
  deleteChildren();
}
Example #17
0
	void FastXmlDocument::unload() {
		if(loaded) {
			while(children.size()>0) deleteChildren();
			loaded = false;
		}
	}
Example #18
0
 Json::~Json()
 {
     deleteChildren();
 }
SceneNode::~SceneNode() {
	deleteChildren();
	SceneManager::instance()->delNode(this);
}
Example #20
0
File: fs.cpp Project: KDE/kio-stash
StashFileSystem::~StashFileSystem()
{
    deleteChildren(root);
}