Beispiel #1
0
void  Map<KEY,T>::copyCode(Elem* &newRoot, Elem* origRoot){
    if (origRoot == 0)
        newRoot = 0;
    else{
        newRoot = new Elem(origRoot->key, origRoot->data, 0, 0, origRoot->height, origRoot->rightThread);
        newRoot->key = origRoot->key;
        newRoot->data = origRoot->data;
        newRoot->height = origRoot->height;
        newRoot->rightThread = origRoot->rightThread;
        copyCode(newRoot->left, origRoot->left);
        if (!origRoot->rightThread)
            copyCode(newRoot->right, origRoot->right);
    }
}
Beispiel #2
0
// overloaded assignment opertor
Set& Set::operator=(const Set &rhs){
    if(this != &rhs){
        destructCode(_root);
        _root = copyCode(rhs._root);
    }
    return *this;
}
Beispiel #3
0
// overloaded operator assignment
SkipList& SkipList::operator=(const SkipList &rhs){
    if (this != &rhs) {
        destructCode();
        copyCode(rhs);
    }
    return *this;
}
Beispiel #4
0
Map<KEY, T>& Map<KEY,T>::operator=(const Map &rhs) {
    if (this != &rhs) {
        if (&rhs != 0) {
            if(_size != 0)
                destructCode(_root->left);
            
            delete _root;
            
            // create a dummy root node
            _root = new Elem(KEY(), T(), _root, 0, 0, false);
            _size = 0;
            
            copyCode(_root->left, rhs._root->left);
            copyThread(_root, rhs._root);
            
            _size = rhs.size();
        } else {
            if(_size != 0)
                destructCode(_root->left);
            
            delete _root;
            
            // create a dummy root node
            _root = new Elem(KEY(), T(), _root, 0, 0, false);
            _size = 0;
        }
    }
    
    return * this;
}
Beispiel #5
0
Map<KEY, T>::Map(const Map<KEY,T> &v){
    // if empty tree
    if (v._root == v._root->left){
        _root = new Elem(KEY(), T(), _root, 0, 0, false);
        _size = 0;
    } else {
        _root = new Elem(KEY(), T(), _root, 0, 0, false);
        copyCode(_root->left, v._root->left); // to deep copy the tree without dummy nodes
        copyThread(_root, v._root); // to copy the threading; must pass dummy nodes to complete the threads
        _size = v._size;
    }
}
RKStandardComponentGUI::RKStandardComponentGUI (RKStandardComponent *component, RKComponentPropertyCode *code_property, bool enslaved) {
	RK_TRACE (PLUGIN);

	toggle_code_button = 0;

	RKStandardComponentGUI::component = component;
	RKStandardComponentGUI::code_property = code_property;
	connect (code_property, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (codeChanged (RKComponentPropertyBase *)));
	connect (RKWardMainWindow::getMain(), SIGNAL (aboutToQuitRKWard()), this, SLOT (cancel()));

	RKStandardComponentGUI::enslaved = enslaved;

	// code update timer
	code_update_timer = new QTimer (this);
	code_update_timer->setSingleShot (true);
	connect (code_update_timer, SIGNAL (timeout ()), this, SLOT (updateCodeNow ()));

	if (!enslaved) {
		KActionCollection *action_collection = new KActionCollection (this);
		action_collection->addAction (KStandardAction::Copy, this, SLOT (copyCode()));
	}
}
Beispiel #7
0
Set::Set(const Set& rhs){
    _root = copyCode(rhs._root);
}
Beispiel #8
0
// common copy code for copying a tree recursively
Set::Elem* Set::copyCode(Elem *node){
    if (node)
        return new Elem(node->info, copyCode(node->left), copyCode(node->right), node->height);
    else
        return 0;
}
Beispiel #9
0
// copy constructor
SkipList::SkipList(const SkipList& v): _probability(v._probability), _maxHeight(v._maxHeight), _curHeight(v._curHeight){
    copyCode(v);
}
Beispiel #10
0
// copy constructor
Set::Set(const Set &v){
    copyCode(v);
}