コード例 #1
0
ファイル: treeview.cpp プロジェクト: lijinkun/smalltool
TreeView::TreeView(QWidget *parent) :
    QTreeView(parent)
{

    deleteNodeAction= new QAction("&Delete",this);
    insertNodeAction= new QAction("&insert",this);
    addNodeAction= new QAction("&add node",this);
    debugPaneAction = new QAction("debug",this);
    deleteRootAction= new QAction("&Delete",this);
    insertRootAction= new QAction("&insert",this);
    addRootAction= new QAction("&add Root",this);



    QObject::connect(this->deleteRootAction, SIGNAL(triggered()), this,
                     SLOT(deleteRoot()));
    QObject::connect(this->insertRootAction, SIGNAL(triggered()), this,
                     SLOT(insertRoot()));

    QObject::connect(this->addRootAction, SIGNAL(triggered()), this,
                     SLOT(addRoot()));
    QObject::connect(this->deleteNodeAction, SIGNAL(triggered()), this,
                     SLOT(deleteNode()));
    QObject::connect(this->insertNodeAction, SIGNAL(triggered()), this,
                     SLOT(insertNode()));

    QObject::connect(this->addNodeAction, SIGNAL(triggered()), this,
                     SLOT(addNode()));

    QObject::connect(this->debugPaneAction, SIGNAL(triggered()), this,
                     SLOT(debugNode()));
}
コード例 #2
0
ファイル: MCHeap.c プロジェクト: sunpaq/monkc4iOS
method(MCHeap, MCArray*, copySortAscend, voida)
{
    MCHeap* hcopy = MCHeap_initWithCopy(new(MCHeap), obj);
    MCArray* array = MCArray_initWithMaxCount(new(MCArray), obj->maxcount);
    while (hcopy->count > 0) {
        MCArray_addItem(array, deleteRoot(hcopy));
    }
    release(hcopy);
    return array;
}
コード例 #3
0
//========================removeHelper================================
// Removes one occurance of the item from this BSTree. If it is the 
// last occurence, the Object is removed.
// 
// Preconditions: the_item is a reference to a non NULL 
//		  object. 
//
// Postconditions: Returns true if the item is found and an occurance
//		   of it is removed. If it is the last occurence the 
//		   Object is removed. False is returned if the
//		   item is not found. 
//====================================================================
bool BSTree::removeHelper (Node *&root, const Object &the_item)
{
	if (root == NULL) return false;

	else if (the_item == *root->item) {
		// More than one occurance, so decrment one.
		if (root->occurances > 1) 
			root->occurances--;
			
		// Otherwise, there's one occurance, so delete it.
		else 	
			deleteRoot (root);

		// We decremented the occurance or deleted the node.	
		return true; 
	}

	else if (the_item < *root->item) 
		return removeHelper (root->left, the_item);
	else 
		return removeHelper (root->right, the_item);	
}