static void doubleRotate(TLDNode *k1, TLDNode *k2, TLDNode *k3, TLDNode *p, int isLeftChild, TLDList *tld) { if (p == NULL) { tld->root = k2; k2->parent = NULL; } else if (isLeftChild) { p->left = k2; k2->parent = p; } else { p->right = k2; k2->parent = p; } k3->left = k2->right; updateParent(k3, k2->right); k1->right = k2->left; updateParent(k1, k2->left); k2->left = k1; k2->right = k3; k1->parent = k2; k3->parent = k2; updateHeight(k1); updateHeight(k3); }
static AVLNode *insertNode(AVLNode *node, const void* key, const void *value,Comparator comp){ if (node == nullptr){ // tree is empty node = new AVLNode(key,value); assert(node != nullptr); node->setHeight(0); return node; } if(comp(key,node->key()) < 0){ // key is to the left node->setLeft(insertNode(node->left(),key,value,comp)); // insert left node->left()->setParent(node); // connecting to parent updateHeight(node); // re-calculating node height after change return rebalanceNode(node); } if(comp(node->key(),key) < 0){ // key is to the right node->setRight(insertNode(node->right(),key,value,comp));// right node->right()->setParent(node); // connecting to parent updateHeight(node); // re-calculating node height after change return rebalanceNode(node); // returning initial node following update } node->set(value); // < and > have failed: duplicate keys return node; // returning initial node with new value }
static TreeNode * balanceNode(TreeNode * node) { int loadBalance = calcLoadBalance(node->left, node->right); if(isUnbalanced(loadBalance) == RIGHTHEAVY) { int rightChildBalance = calcLoadBalance(node->right->left, node->right->right); if(rightChildBalance > 0) { node->right = rightRotateTree(node->right); updateHeight(node->right); } node = leftRotateTree(node); } if(isUnbalanced(loadBalance) == LEFTHEAVY) { int leftChildBalance = calcLoadBalance(node->left->left, node->left->right); if(leftChildBalance < 0) { node->left = leftRotateTree(node->left); updateHeight(node->left); } node = rightRotateTree(node); } return node; }
static int tldlist_insert(char *tldStr, TLDNode *node, TLDList *tld) { int comparison = strcmp(tldStr, node->tld); if (comparison == 0) { node->count++; free(tldStr); return 2; //tld already is in the tree } else if (comparison < 0 && node->left == NULL) { node->left = tldnode_create(node, tldStr, 1); if (node->left == NULL) return 0; updateHeight(node->left); restoreBalance(node->left, tld); return 1;//TODO height } else if (comparison < 0 && node->left != NULL) return tldlist_insert(tldStr, node->left, tld); else if (comparison > 0 && node->right == NULL) { node->right = tldnode_create(node, tldStr, 1); if (node->right == NULL) return 0; updateHeight(node->right); restoreBalance(node->right, tld); return 1; } else if (comparison > 0 && node->right != NULL) return tldlist_insert(tldStr, node->right, tld); return 0; }
void AVLTree::leftLeft(AVLNode *& node) { cout << "leftLeft" << endl; AVLNode * temp; temp = node; node = node->left; temp->left = node->right; node->right = temp; updateHeight(node->right); updateHeight(node); }
static AVLNode *deleteNode(AVLNode *node, const void* key, Comparator comp){ if(node == nullptr) return nullptr; // nothing to do on empty tree if(comp(key,node->key()) < 0){ // key is to the left AVLNode *temp = deleteNode(node->left(),key, comp);// left delete node->setLeft(temp); // linking new left child if(temp != nullptr) temp->setParent(node); // parent link if applicable updateHeight(node); // re-calc height after change of child return rebalanceNode(node); // return original node after modification } if(comp(node->key(),key) < 0){ // key is to the right AVLNode *temp = deleteNode(node->right(),key,comp);//right delete node->setRight(temp); // linking new right child if(temp != nullptr) temp->setParent(node); // parent link if applicable updateHeight(node); // re-calc height after change of child return rebalanceNode(node); // return original node after modification } // key to be deleted is equal to node key if(node->left() == nullptr){ // left child does not exist AVLNode *temp = node->right(); // candidate for tree after deletion if(temp != nullptr) temp->setParent(nullptr); // new root delete node; // just free memory for root node which is deleted node = nullptr; // for safety reasons return temp; } if(node->right() == nullptr){ // left child does exist, but not right child AVLNode *temp = node->left(); temp->setParent(nullptr); // no need to check for null pointer now delete node; // just free memory for root node which is deleted node = nullptr; // for safety reasons return temp; } // both left and right child exist, while root needs to be deleted // we arbitrarily choose to promote successor as new root AVLNode *temp = rootMinNode(node->right()); temp->setLeft(node->left()); // gluing initial left child temp->left()->setParent(temp); // not forgetting parent link updateHeight(temp); // re-calc height after change of child delete node; // just free memory for root node which is deleted node = nullptr; // for safety reasons return rebalanceNode(temp); }
static TreeNode * insertIntoTree(AVLTree * tree, TreeNode * node, void * data, Boolean * success) { if(node == NULL) return newTreeNode(data); int comparision = tree->compare(data, node->data); if(comparision == 0) { *success = false; return node; } int direction = comparision > 0 ? RIGHT : LEFT; if(direction == RIGHT) { node->right = insertIntoTree(tree, node->right, data, success); } else { node->left = insertIntoTree(tree, node->left, data, success); } updateHeight(node); node = balanceNode(node); return node; }
OverlayImageDisplay::OverlayImageDisplay() : Display(), width_(128), height_(128), left_(128), top_(128), alpha_(0.8), is_msg_available_(false), require_update_(false) { // setup properties update_topic_property_ = new rviz::RosTopicProperty( "Topic", "", ros::message_traits::datatype<sensor_msgs::Image>(), "sensor_msgs::Image topic to subscribe to.", this, SLOT( updateTopic() )); keep_aspect_ratio_property_ = new rviz::BoolProperty("keep aspect ratio", false, "keep aspect ratio of original image", this, SLOT(updateKeepAspectRatio())); width_property_ = new rviz::IntProperty("width", 128, "width of the image window", this, SLOT(updateWidth())); height_property_ = new rviz::IntProperty("height", 128, "height of the image window", this, SLOT(updateHeight())); left_property_ = new rviz::IntProperty("left", 128, "left of the image window", this, SLOT(updateLeft())); top_property_ = new rviz::IntProperty("top", 128, "top of the image window", this, SLOT(updateTop())); alpha_property_ = new rviz::FloatProperty("alpha", 0.8, "alpha belnding value", this, SLOT(updateAlpha())); }
void Plotter2DDisplay::onInitialize() { static int count = 0; rviz::UniformStringStream ss; ss << "Plotter2DDisplayObject" << count++; overlay_.reset(new OverlayObject(ss.str())); updateBufferSize(); onEnable(); updateShowValue(); updateWidth(); updateHeight(); updateLeft(); updateTop(); updateFGColor(); updateBGColor(); updateFGAlpha(); updateBGAlpha(); updateLineWidth(); updateUpdateInterval(); updateShowBorder(); updateAutoColorChange(); updateMaxColor(); updateShowCaption(); updateTextSize(); updateAutoScale(); updateMinValue(); updateMaxValue(); overlay_->updateTextureSize(width_property_->getInt(), height_property_->getInt() + caption_offset_); }
void BSTree::insert(int x) { Node *parent = nullptr, *current = root; while (current != nullptr) { parent = current; if (x < current->value) current = current->left; else current = current->right; } Node *newNode = new Node(x, parent); if (parent) { if (x < parent->value) parent->left = newNode; else parent->right = newNode; } else{ root = newNode; newNode->height = 1; } for (Node *it = newNode; it != nullptr; it = it->parent){ it = updateHeight(it); } countOfElements++; }
sbGroup::sbGroup(ofXML & xml,bGroup * destin):ofInterObj(){ dest=destin; string font=xml.getCurrentTag().getAttribute("font"); xml.setCurrentTag(";blocks"); ofTag & tag=xml.getCurrentTag(); for (unsigned int i=0; i<tag.size(); i++) { if (tag[i].getLabel()=="bar") { string col=tag[i].getAttribute("color"); unsigned long colTrip=strtol(col.c_str(),NULL,0); ofColor color(colTrip); cout << tag[i].getAttribute("name") + " " + tag[i].getLabel() <<endl; unsigned int curBar=bars.size(); bars.push_back( sideBar(-20,50+40*i,260,40,tag[i].getAttribute("name"),color)); for (unsigned int j=0; j<tag[i].size(); j++) { if (tag[i][j].getLabel()=="block") { bars[curBar].blocks.push_back(block(tag[i][j],color,j*45)); } } } } bars.push_back( sideBar(-20,50+40*bars.size(),260,40,"Filler",ofColor(0,0,0))); if (bars.size()) { y=bars[0].y; x=0; w=bars[0].w; } updateHeight(); if(bars.size()>=2) bars[bars.size()-2].Open=true; for (unsigned int i=0; i<bars.size(); i++) { //updateBlocks(i); } }
FootstepDisplay::FootstepDisplay() { alpha_property_ = new rviz::FloatProperty( "Alpha", 0.5, "0 is fully transparent, 1.0 is fully opaque.", this, SLOT( updateAlpha() )); show_name_property_ = new rviz::BoolProperty( "Show Name", true, "Show name of each footstep", this, SLOT(updateShowName())); use_group_coloring_property_ = new rviz::BoolProperty( "Use Group Coloring", false, "Use footstep_group field to colorize footsteps", this, SLOT(updateUseGroupColoring())); width_property_ = new rviz::FloatProperty( "Width", 0.15, "width of the footstep, it's not used if the dimensions is specified in Footstep message.", this, SLOT( updateWidth() )); height_property_ = new rviz::FloatProperty( "height", 0.01, "height of the footstep, it's not used if the dimensions is specified in Footstep message.", this, SLOT( updateHeight() )); depth_property_ = new rviz::FloatProperty( "depth", 0.3, "depth of the footstep, it's not used if the dimensions is specified in Footstep message.", this, SLOT( updateDepth() )); }
TemporalConstraintPresenter::TemporalConstraintPresenter( const TemporalConstraintViewModel& cstr_model, QGraphicsObject *parentobject, QObject* parent) : AbstractConstraintPresenter {"TemporalConstraintPresenter", cstr_model, new TemporalConstraintView{*this, parentobject}, parent} { connect(::view(this), &TemporalConstraintView::constraintHoverEnter, this, &TemporalConstraintPresenter::constraintHoverEnter); connect(::view(this), &TemporalConstraintView::constraintHoverLeave, this, &TemporalConstraintPresenter::constraintHoverLeave); if(viewModel(this)->isRackShown()) { on_rackShown(viewModel(this)->shownRack()); } ::view(this)->setLabel(cstr_model.model().metadata.label()); connect(&cstr_model.model().metadata, &ModelMetadata::labelChanged, ::view(this), &TemporalConstraintView::setLabel); connect(&cstr_model.model().metadata, &ModelMetadata::colorChanged, ::view(this), &TemporalConstraintView::setLabelColor); updateHeight(); }
void pluginDescWidget::leaveEvent( QEvent * _e ) { m_mouseOver = false; m_targetHeight = 24; updateHeight(); QWidget::leaveEvent( _e ); }
void pluginDescWidget::enterEvent( QEvent * _e ) { m_mouseOver = true; m_targetHeight = height() + 1; updateHeight(); QWidget::enterEvent( _e ); }
void OverlayTextDisplay::updateOvertakePositionProperties() { if (!overtake_position_properties_ && overtake_position_properties_property_->getBool()) { updateTop(); updateLeft(); updateWidth(); updateHeight(); updateTextSize(); require_update_texture_ = true; } overtake_position_properties_ = overtake_position_properties_property_->getBool(); if (overtake_position_properties_) { top_property_->show(); left_property_->show(); width_property_->show(); height_property_->show(); text_size_property_->show(); } else { top_property_->hide(); left_property_->hide(); width_property_->hide(); height_property_->hide(); text_size_property_->hide(); } }
void GuiGameListMenuCtrl::enforceConstraints() { if (hasValidProfile()) { ((GuiGameListMenuProfile *)mProfile)->enforceConstraints(); } updateHeight(); }
void ConstraintPresenter::on_rackShown(const Id<RackModel>& rackId) { clearRackPresenter(); createRackPresenter(m_viewModel.model().racks.at(rackId)); m_header->setState(ConstraintHeader::State::RackShown); updateHeight(); }
void ConstraintPresenter::on_noRacks() { m_header->hide(); clearRackPresenter(); m_header->setState(ConstraintHeader::State::Hidden); updateHeight(); }
void User::setHeight(double height) { if(myHeight != height) { myHeight = height; updateHeight(height); calculateBMI(); calculateBMR(); emit heightChanged(); } }
ITNode(Key *k, const ITNode* lptr, const ITNode* hptr) : key(k), lesser(lptr), greater(hptr) { assert(false); lesser = new(Key) (*lptr); *lesser = *lptr; greater = new(Key) (*hptr); *greater = *hptr; updateHeight(); }
void sbGroup::update() { for (unsigned int i=0; i<bars.size(); i++) { for (unsigned int j=0; j<bars[i].size(); j++) { if(bars[i][j].updateSize()) updateHeight(); bars[i][j].updatePositions(); } } }
GridDisplay::GridDisplay() : Display() { frame_property_ = new TfFrameProperty( "Reference Frame", TfFrameProperty::FIXED_FRAME_STRING, "The TF frame this grid will use for its origin.", this, 0, true ); cell_count_property_ = new IntProperty( "Plane Cell Count", 10, "The number of cells to draw in the plane of the grid.", this, SLOT( updateCellCount() )); cell_count_property_->setMin( 1 ); height_property_ = new IntProperty( "Normal Cell Count", 0, "The number of cells to draw along the normal vector of the grid. " " Setting to anything but 0 makes the grid 3D.", this, SLOT( updateHeight() )); height_property_->setMin( 0 ); cell_size_property_ = new FloatProperty( "Cell Size", 1.0f, "The length, in meters, of the side of each cell.", this, SLOT( updateCellSize() )); cell_size_property_->setMin( 0.0001 ); style_property_ = new EnumProperty( "Line Style", "Lines", "The rendering operation to use to draw the grid lines.", this, SLOT( updateStyle() )); style_property_->addOption( "Lines", Grid::Lines ); style_property_->addOption( "Billboards", Grid::Billboards ); line_width_property_ = new FloatProperty( "Line Width", 0.03, "The width, in meters, of each grid line.", style_property_, SLOT( updateLineWidth() ), this ); line_width_property_->setMin( 0.001 ); line_width_property_->hide(); color_property_ = new ColorProperty( "Color", Qt::gray, "The color of the grid lines.", this, SLOT( updateColor() )); alpha_property_ = new FloatProperty( "Alpha", 0.5f, "The amount of transparency to apply to the grid lines.", this, SLOT( updateColor() )); alpha_property_->setMin( 0.0f ); alpha_property_->setMax( 1.0f ); plane_property_ = new EnumProperty( "Plane", "XY", "The plane to draw the grid along.", this, SLOT( updatePlane() )); plane_property_->addOption( "XY", XY ); plane_property_->addOption( "XZ", XZ ); plane_property_->addOption( "YZ", YZ ); offset_property_ = new VectorProperty( "Offset", Ogre::Vector3::ZERO, "Allows you to offset the grid from the origin of the reference frame. In meters.", this, SLOT( updateOffset() )); }
static TreeNode * removeNode(AVLTree * tree, TreeNode * node, void * data, void ** removedData) { if(node == NULL) return NULL; int comparision = tree->compare(data, node->data); if(comparision > 0) { node->right = removeNode(tree, node->right, data, removedData); } if(comparision < 0) { node->left = removeNode(tree, node->left, data, removedData); } if(comparision == 0) { *removedData = node->data; if(node->left == NULL && node->right == NULL) /*leaf node*/ { destroyNode(node); node = NULL; return node; } else if(node->left != NULL && node->right != NULL) { node->data = replaceWithData(node->left, data); node->left = removeNode(tree, node->left, data, removedData); } else if(node->left != NULL) /*only left node*/ { TreeNode * leftNode = node->left; *removedData = node->data; destroyNode(node); node = leftNode; } else /*only right node*/ { TreeNode * rightNode = node->right; *removedData = node->data; destroyNode(node); node = rightNode; } } updateHeight(node); node = balanceNode(node); return node; }
static AVLNode *rootMaxNode(AVLNode *node){ if(node == nullptr) return nullptr; // no impact on empty tree if(node->right() == nullptr){ // no right child, max node already root node->setParent(nullptr); // returning a root node return node; } else { // right child does exist AVLNode *temp = rootMaxNode(node->right()); // recursive call node->setRight(temp->left()); // new right child without the max if(node->right() != nullptr) node->right()->setParent(node); updateHeight(node); // re-calc height after change of child temp->setLeft(node); // node getting to the left of max node->setParent(temp); // not forgetting parent link updateHeight(temp); // re-calc height after change of child return temp; // returning max node } }
void AVLTree::rightLeft(AVLNode *& node) { cout << "rightLeft" << endl; AVLNode * temp; temp = node->right; node->right = temp->left; temp->left = 0; node->right->right = temp; updateHeight(node->right->right); updateHeight(node->right); rightRight(node); return; }
ITNode& operator=(const ITNode& n) { assert(false); key = n.key; if(lesser != NULL) delete(lesser); lesser = new(ITNode) (*n.lesser); *lesser = *n.lesser; if(greater != NULL) delete(greater); greater = new(ITNode) (*n.greater); *lesser = *n.greater; updateHeight(); }
void LaconicaConversationTimelineWidget::slotConversationFetched(Choqok::Account* theAccount, const ChoqokId& convId, QList< Choqok::Post* > posts) { if( currentAccount() == theAccount && convId == this->conversationId){ setWindowTitle(i18n("Conversation")); addNewPosts(posts); foreach(Choqok::UI::PostWidget* post, postWidgets()){ post->setReadWithSignal(); } QTimer::singleShot(0, this, SLOT(updateHeight())); }
void FootstepDisplay::onInitialize() { MFDClass::onInitialize(); scene_node_ = scene_manager_->getRootSceneNode()->createChildSceneNode(); line_ = new rviz::BillboardLine(context_->getSceneManager(), scene_node_); updateShowName(); updateWidth(); updateHeight(); updateDepth(); updateAlpha(); updateUseGroupColoring(); }
void BSTree::remove(Tree::Node *node) { if (!node) return; Node *current = nullptr; Node *child = nullptr; if (node->right != nullptr) current = minimum(node->right); else current = node; if (current->left != nullptr) child = current->left; else child = current->right; if (current == root) { delete current; root = nullptr; return; } if (child != nullptr) { if (current->parent == nullptr) root = child; child->parent = current->parent; } if (current->parent != nullptr) { if (current->parent->left == current) current->parent->left = child; else current->parent->right = child; } node->value = current->value; current->left = nullptr; current->right = nullptr; for (Node *it = current; it != nullptr; it = it->parent){ it = updateHeight(it); } delete current; countOfElements--; }