示例#1
0
void JALOUSIE::updateSHM(int JalNr)
{
    char newValue[16];
    char startTag[16];
    getPosition(JalNr, newValue);
    sprintf(startTag, "<posJal_%d>", JalNr);
    updateHelper(startTag, newValue);
    getDrvState(JalNr, newValue);
    sprintf(startTag, "<drvJal_%d>", JalNr);
    updateHelper(startTag, newValue);
    sendSharedMem();
}
    void updateHelper(SegmentTreeNode *root, const pair<int, int>& i, int val) {
        // Out of range.
        if (root == nullptr ||
            (root->start.first > i.first || root->start.second > i.second) ||
            (root->end.first < i.first || root->end.second < i.second)) {
            return;
        }

        // Change the node's value with [i] to the new given value.
        if ((root->start.first == i.first && root->start.second == i.second) &&
            (root->end.first == i.first && root->end.second == i.second)) {
            root->sum = val;
            return;
        }
        for (auto& node : root->neighbor) {
            updateHelper(node, i, val);
        }

        root->sum = 0;
        for (auto& node : root->neighbor) {
            if (node) {
                root->sum += node->sum;
            }
        }
    }
    void updateHelper(SegmentTreeNode *root, int i, int val) {
        // Out of range.
        if (root == nullptr || root->start > i || root->end < i) {
            return;
        }

        // Change the node's value with [i] to the new given value.
        if (root->start == i && root->end == i) {
            root->sum = val;
            return;
        }

        updateHelper(root->left, i, val);
        updateHelper(root->right, i, val);

        // Update sum.
        root->sum =  (root->left != nullptr ? root->left->sum : 0) +
                     (root->right != nullptr ? root->right->sum : 0);
    }
 void update(int row, int col, int val) {
     if (matrix_[row][col] != val) {
         matrix_[row][col] = val;
         updateHelper(root_, make_pair(row, col), val);
     }
 }
void BaseEditorDocumentParser::update(const WorkingCopy &workingCopy)
{
    QMutexLocker locker(&m_updateIsRunning);
    updateHelper(workingCopy);
}
void RobotStateVisualization::update(const robot_state::RobotStateConstPtr &kinematic_state, const std_msgs::ColorRGBA &default_attached_object_color,
                                         const std::map<std::string, std_msgs::ColorRGBA> &color_map)
{
  updateHelper(kinematic_state, default_attached_object_color, &color_map);
}
void RobotStateVisualization::update(const robot_state::RobotStateConstPtr &kinematic_state,
                                         const  std_msgs::ColorRGBA &default_attached_object_color)
{
  updateHelper(kinematic_state, default_attached_object_color, NULL);
}
void RobotStateVisualization::update(const robot_state::RobotStateConstPtr &kinematic_state)
{
  updateHelper(kinematic_state, default_attached_object_color_, NULL);
}
 void update(int i, int val) {
     if (nums_[i] != val) {
         nums_[i] = val;
         updateHelper(root_, i, val);
     }
 }
void BaseEditorDocumentParser::update(const InMemoryInfo &info)
{
    QMutexLocker locker(&m_updateIsRunning);
    updateHelper(info);
}