• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ rotateLeft函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中rotateLeft函数的典型用法代码示例。如果您正苦于以下问题:C++ rotateLeft函数的具体用法?C++ rotateLeft怎么用?C++ rotateLeft使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了rotateLeft函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: balanceLeft

Tree balanceLeft(Tree t) {

  if(t -> left -> bf == LH) {
    // simple (rotate right)
    t = rotateRight(t);
    t -> bf = EH;
    t -> right -> bf = EH;
  }
  else {
    // double (rotate left and then right)
    t -> left = rotateLeft(t -> left);
    t = rotateRight(t);
    switch(t->bf) {
      case EH:
        t -> left -> bf = EH;
        t -> right -> bf = EH;
        break;
      case RH:
        t -> left -> bf = LH;
        t -> right -> bf = EH;
        break;
      case LH:
        t -> left -> bf = EH;
        t -> right -> bf = RH;
    }
    t -> bf = EH;
  }

  return t;
}
开发者ID:ruimiguelsantos,项目名称:cstructspoc,代码行数:30,代码来源:avlBKP.c


示例2: rotateLeft

void Align::rotatePolar(double angle){

    rotateLeft(3*M_PI/2);    
    double seconds =  ((angle) * ROBOT_DIAMETER * M_PI) / (2 * M_PI * 3.0 * WHEEL_RAD);
	
	seconds = seconds - (9.15*(seconds / 100));

	//stop
	if(seconds < 0.0){
		diffDrive.call(msg_turn_right);
		seconds = seconds * -1;
	}else{
	diffDrive.call(msg_turn_left);
	}



        //sleep until at correct angle
        ros::Duration(seconds).sleep();

        //stop rotating
        diffDrive.call(msg_stop);
        //ros::Duration(3).sleep();
        ready = 1;
	//ROS_INFO("Rotate Position: %d", position);
}
开发者ID:shinroo,项目名称:TUB_Programs,代码行数:26,代码来源:align.cpp


示例3: tr

void MyGallery::setupActions()
{
  p->toolbar->addAction(QIcon::fromTheme("object-rotate-left"),
                  tr("Rotate Left"), p->viewer->obj(), SLOT(rotateLeft()));
  p->toolbar->addAction(QIcon::fromTheme("object-rotate-right"),
                  tr("Rotete Right"), p->viewer->obj(), SLOT(rotateRight()));
}
开发者ID:qidaizhe11,项目名称:QingfengGallery-backup,代码行数:7,代码来源:MyGallery.cpp


示例4: rotateLeft

void AVLTree<K, V>::rotateLeftRight(Node * & t)
{
        *_out << __func__ << endl; // Outputs the rotation name (don't remove this)
        // Implemented for you:
        rotateLeft(t->left);
        rotateRight(t);
}
开发者ID:chrislee0793,项目名称:CS225,代码行数:7,代码来源:avltree.cpp


示例5: Node

void AVLTree<K, V>::insert(Node* & subtree, const K & key, const V & value)
{
        if(subtree == NULL) {
                subtree = new Node(key, value);
                return;
        }      
        if(subtree->key == key) return;
 
        if(key < subtree->key) {
                insert(subtree->left, key, value);
        } else {
                insert(subtree->right, key, value);
        }
        if(heightOrNeg1(subtree->right) - heightOrNeg1(subtree->left) == 2) {
                if(subtree->right != NULL) {
                        if(heightOrNeg1(subtree->right->left) > heightOrNeg1(subtree->right->right)) {
                                rotateRightLeft(subtree);
                        } else if (heightOrNeg1(subtree->right->left) < heightOrNeg1(subtree->right->right)) {
                                rotateLeft(subtree);
                        }
                }
        } else if(heightOrNeg1(subtree->right) - heightOrNeg1(subtree->left) == -2) {
                if(subtree->left != NULL) {
                        if(heightOrNeg1(subtree->left->right) > heightOrNeg1(subtree->left->left)) {
                                rotateLeftRight(subtree);
                        } else if(heightOrNeg1(subtree->left->right) < heightOrNeg1(subtree->left->left)) {
                                rotateRight(subtree);
                        }
                }      
        }
        subtree->height = calculateSubtreeHeight(subtree);
}
开发者ID:chrislee0793,项目名称:CS225,代码行数:32,代码来源:avltree.cpp


示例6: rotateRight

void AVLTree<K, V>::rotateRightLeft(Node * & t)
{
	*_out << __func__ << endl; // Outputs the rotation name (don't remove this)
    // your code here
	rotateRight(t->right);
	rotateLeft(t);
}
开发者ID:killbug2004,项目名称:Snippets,代码行数:7,代码来源:avltree.cpp


示例7: balanceLeft

/*Balanceamento da AVL a esquerda*/
AVL balanceLeft(AVL p) {
	if(p->left->bf==LH) {
		p=rotateRight(p);
		p->bf=EH;
		p->right->bf=EH;
	}
	else {
		p->left=rotateLeft(p->left);
		p=rotateRight(p);
		switch(p->bf) {
		case EH:
			p->left->bf=EH;
			p->right->bf=EH;
			break;
		case RH:
			p->right->bf=EH;
			p->left->bf=LH;
			break;
		case LH:
			p->right->bf=RH;
			p->left->bf=EH;
		}
		p->bf=EH;
	}
	return p;
}
开发者ID:zecarlos94,项目名称:LI3_GZT,代码行数:27,代码来源:avl.c


示例8: FloatFrame

void MainWindow::initButtomBar()
{
    bottomFrame = new FloatFrame(this);
    ///set all the button's focous policy to Qt::NoFocous in 'ui' file.

    contralBar = new ContralBar(bottomFrame);
    bottomFrame->addWidget(contralBar);

    QHBoxLayout *hlayout = new QHBoxLayout(bottomFrame);
    hlayout->setContentsMargins(0,0,0,0);   ///qframe's layout margis default is not 0.
    hlayout->setAlignment(Qt::AlignCenter);
    hlayout->addWidget(contralBar);
    bottomFrame->setLayout(hlayout);

    settingButton = contralBar->settingButton;
    openButton = contralBar->openButton;
    preButton = contralBar->preButton;
    playButton = contralBar->playButton;
    nextButton = contralBar->nextButton;
    rotateLeftButton = contralBar->rotateLeftButton;
    rotateRightButton = contralBar->rotateRightButton;
    deleteButton = contralBar->deleteButton;

    connect(settingButton, SIGNAL(clicked()), SLOT(setting()));
    connect(openButton, SIGNAL(clicked()), SLOT(openFile()));
    connect(preButton, SIGNAL(clicked()), viewer, SLOT(prePic()));
    connect(playButton, SIGNAL(clicked()), SLOT(switchSlideShow()));
    connect(nextButton, SIGNAL(clicked()), viewer, SLOT(nextPic()));
    connect(rotateLeftButton, SIGNAL(clicked()), viewer, SLOT(rotateLeft()));
    connect(rotateRightButton, SIGNAL(clicked()), viewer, SLOT(rotateRight()));
    connect(deleteButton, SIGNAL(clicked()), viewer, SLOT(deleteFileAsk()));

    bottomFrame->installEventFilter(this);
}
开发者ID:404neko,项目名称:ezviewer-1,代码行数:34,代码来源:mainwindow.cpp


示例9: QWidget

FlightPanel::FlightPanel(QWidget *parent):
    QWidget(parent),
    wi(this),
    timer(this)
{
    up.reset(new QPushButton(QIcon(), QString("up"), this));
    down.reset(new QPushButton(QIcon(), QString("down"), this));
    left.reset(new QPushButton(QIcon(), QString("left"), this));
    right.reset(new QPushButton(QIcon(), QString("right"), this));

    up->resize(   controlHeight, controlHeight/2.5);
    down->resize( controlHeight, controlHeight/2.5);
    left->resize( controlHeight, controlHeight/2.5);
    right->resize(controlHeight, controlHeight/2.5);

    QRect rect = QRect(0, 0, this->width(), this->height() - 50);
    wi.setGeometry(rect);
    wi.setVisible(true);

    QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(tick()));

    QObject::connect(up.get(), SIGNAL(clicked()),    &wi, SLOT(rotateUp()));
    QObject::connect(down.get(), SIGNAL(clicked()),  &wi, SLOT(rotateDown()));
    QObject::connect(left.get(), SIGNAL(clicked()),  &wi, SLOT(rotateLeft()));
    QObject::connect(right.get(), SIGNAL(clicked()), &wi, SLOT(rotateRight()));
    timer.setInterval(200);
    timer.start();
}
开发者ID:Andrey-Dubas,项目名称:diploma,代码行数:28,代码来源:flightpanel.cpp


示例10: rotate

void rotate()
{	
	if(speed > 10)
		rotateLeft(MAXSPEED/(speed-10));
	else if(speed < 10)
		rotateRight(MAXSPEED/(10-speed));
}
开发者ID:russellaabuchanan,项目名称:microp_embedded,代码行数:7,代码来源:Thread_LED.c


示例11: switch

int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: openFile(); break;
        case 1: applyChanges(); break;
        case 2: saveFile(); break;
        case 3: exit(); break;
        case 4: effects(); break;
        case 5: zoom(); break;
        case 6: resize(); break;
        case 7: crop(); break;
        case 8: rotateRight(); break;
        case 9: rotateLeft(); break;
        case 10: mirror(); break;
        case 11: reflection(); break;
        case 12: grayScale(); break;
        case 13: xray(); break;
        case 14: sepia(); break;
        default: ;
        }
        _id -= 15;
    }
    return _id;
}
开发者ID:julioce,项目名称:CompGraf,代码行数:28,代码来源:moc_mainwindow.cpp


示例12: print_permutation

void print_permutation(char *wordRa){
	static count;
	char singleWord[2];
	char aheadWord[10],currentwordRa[10];
	int index,wordRalength,i;
	wordRalength=strlen(wordRa);
	if(wordRalength>2){
		
		strcpy(currentwordRa,wordRa);
		for(i=0;i<wordRalength;i++){
			singleWord[0]=currentwordRa[0];
			singleWord[1]='\0';
			strcat(toBePrinted,singleWord);
			strcpy(aheadWord,currentwordRa+1);
			print_permutation(aheadWord);
			index=strlen(toBePrinted)-1;
			toBePrinted[index]='\0';
			rotateLeft(currentwordRa);
		}
		
	}else
	{
		//printf("\n%d)TOBEpTelse=%s",++count,toBePrinted);
		printf("\n%s",toBePrinted);
		printf("%s",wordRa);
		//printf("\n%d)TOBEpTelse=%s",++count,toBePrinted);
		printf("\n%s",toBePrinted);
		printf("%c%c",wordRa[1],wordRa[0]);
	}
}
开发者ID:nebukanezar,项目名称:stringpermutation,代码行数:30,代码来源:2.c


示例13: while

/*
void MovieTree::fixUpAdd(Movie*)

Description:
Private method used to balance the tree after adding a movie.

Example:
MovieTree tree;
tree.addMoviebyTitle("Back to the Future", 1985, 96, 5);

Precondition:
The ends of the tree are nil. The tree is arranged correctly.

Postcondition:
The tree will be balanced.
*/
void MovieTree::fixUpAdd(Movie *x)
{
    x->isRed = true;

    while (x != root && x->parent->isRed) {
        if (x->parent == x->parent->parent->left) {
            Movie *y = x->parent->parent->right;

            if (y->isRed) {
                x->parent->isRed = false;
                y->isRed = false;
                x->parent->parent->isRed = true;
                x = x->parent->parent;
            } else {
                if (x == x->parent->right) {
                    x = x->parent;
                    rotateLeft(x);
                }

                x->parent->isRed = false;
                x->parent->parent->isRed = true;
                rotateRight(x->parent->parent);
            }
        } else {
            Movie *y = x->parent->parent->left;

            if (y->isRed) {
                x->parent->isRed = false;
                y->isRed = false;
                x->parent->parent->isRed = true;
                x = x->parent->parent;
            } else {
                if (x == x->parent->left) {
                    x = x->parent;
                    rotateRight(x);
                }

                x->parent->isRed = false;
                x->parent->parent->isRed = true;
                rotateLeft(x->parent->parent);
            }
        }
    }

    root->isRed = false;
}
开发者ID:AdamEParnes,项目名称:Anderson_CSCI2270_FinalProject,代码行数:62,代码来源:MovieTree.cpp


示例14: fprintf

int AVLTree::ins(AVLNode* &p, FFSObject *e) {
    int deltaH = 0;
    if (p == NULL) {
	p = new AVLNode;
#ifdef _DEBUG_AVL
	AVLTree::tree_cnt++;
#endif
	p->elem = e;
	p->bal = 0;
	p->left = p->right = NULL;
	deltaH = 1;  /* tree hight increased by 1 */
#ifdef _DEBUG_AVL
	fprintf(stderr, "added %s to AVLTree (count %d)\n", 
		e->getName(), count);
#endif
    } else if (compareType == AVL_CMP_NAME
	       ? e->compareName(p->elem) > 0
	       : e->compareAll(p->elem) > 0) {
	if (ins(p->right, e)) {
	    p->bal++; /* height of right subtree increased */
	    if (p->bal == 1) {
		deltaH = 1;
	    } else if (p->bal == 2) {
		if (p->right->bal == -1) {
		    rotateRight(p->right);
		}
		rotateLeft(p);
	    }
	}
    } else /* if (e->compareAll(p->elem) <= 0)*/ {
	if (ins(p->left, e)) {
	    p->bal--;
	    if (p->bal == -1) {
		deltaH = 1;
	    } else if (p->bal == -2) {
		if (p->left->bal == 1) {
		    rotateLeft(p->left);
		}
		rotateRight(p);
	    }
	}
    }
    return deltaH;
}
开发者ID:alaeri,项目名称:3dfm,代码行数:44,代码来源:AVLTree.cpp


示例15: insertSplay

/*
	Notes:
	* tree insertion using splay method
	* produces different results to the visualiser

*/
Link insertSplay(Link n, int value)
{
	if (n == NULL) { return newNode(value); }

	if (value < n->value){ // right rotations
		if (n->left == NULL){ // left branch is NULL
			n->left = newNode(value);
		}

		else if (value < n->left->value){ // zig zig left
			n->left->left = insertSplay(n->left->left, value);
			// n->left = rotateRight(n->left);
			n = rotateRight(n);
		}

		else{ // zig zag left
			n->left->right = insertSplay(n->left->right, value);
			n->left = rotateLeft(n->left);
		}

		n = rotateRight(n);
	}

	if (value > n->value){ // left rotations
		if (n->right == NULL){
			n->right = newNode(value);
		}

		else if (value > n->right->value){ // zig zig right
			n->right->right = insertSplay(n->right->right, value);
			// n->right = rotateLeft(n->right);
			n = rotateLeft(n);
		}

		else{ // zig zag right
			n->right->left = insertSplay(n->right->left, value);
			n->right = rotateRight(n->right);
		}
		
		n = rotateLeft(n);
	}

	return n;
}
开发者ID:matthewT53,项目名称:Data-structures-and-algorithms,代码行数:50,代码来源:splay.c


示例16: strcmp

void C_galgas_type_descriptor::recursiveInsert (C_galgas_type_descriptor * & ioRootPtr,
                                                C_galgas_type_descriptor * inDescriptor,
                                                bool & ioExtension) {
  if (ioRootPtr == NULL) {
    ioExtension = true ;
    ioRootPtr = inDescriptor ;
  }else{
    const int32_t comparaison = strcmp (ioRootPtr->mGalgasTypeName, inDescriptor->mGalgasTypeName) ;
    if (comparaison > 0) {
      recursiveInsert (ioRootPtr->mPreviousType, inDescriptor, ioExtension) ;
      if (ioExtension) {
        ioRootPtr->mBalance++;
        if (ioRootPtr->mBalance == 0) {
          ioExtension = false;
        }else if (ioRootPtr->mBalance == 2) {
          if (ioRootPtr->mPreviousType->mBalance == -1) {
            rotateLeft (ioRootPtr->mPreviousType) ;
          }
          rotateRight (ioRootPtr) ;
          ioExtension = false;
        }
      }
    }else if (comparaison < 0) {
      recursiveInsert (ioRootPtr->mNextType, inDescriptor, ioExtension) ;
      if (ioExtension) {
        ioRootPtr->mBalance-- ;
        if (ioRootPtr->mBalance == 0) {
          ioExtension = false ;
        }else if (ioRootPtr->mBalance == -2) {
          if (ioRootPtr->mNextType->mBalance == 1) {
            rotateRight (ioRootPtr->mNextType) ;
          }
          rotateLeft (ioRootPtr) ;
          ioExtension = false;
        }
      }
    }else{
      ioExtension = false;
      C_String errorMessage ;
      errorMessage << "FATAL ERROR (type '@" << inDescriptor->mGalgasTypeName << "' already defined)" ;
      fatalError (errorMessage, __FILE__, __LINE__) ;
    }
  }
}
开发者ID:jiguosong,项目名称:trampoline,代码行数:44,代码来源:C_galgas_type_descriptor.cpp


示例17: insertAt

	// -1 --- неуспешно включване, елементът вече го има
	// 0  --- успешно включване, но няма промяна във височината
	// 1  --- успешно включване и има увеличение на височината с 1
	int insertAt(P p, T const& x) {
		if (!p) {
			// дъно
			BinaryTree<AVL>::assignFrom(p, AVL(x));
			return 1;
		}
		// p --- валидна позиция
		if ((*p).data() == x)
			// Грешка! x вече го има
			return -1;
		// p && *p != x
		int result;
		if (x < (*p).data()) {
			// вмъкваме наляво
			result = insertAt(-p, x);
			if (result == 1) {
				(*p).balance()--;
				if ((*p).balance() == -2) {
					if ((*-p).balance() == 1)
						rotateLeft(-p);
					rotateRight(p);
					result = 0;
				}
			}
		} else {
			// вмъкваме надясно
			result = insertAt(+p, x);
			if (result == 1) {
				(*p).balance()++;
				if ((*p).balance() == 2) {
					if ((*+p).balance() == -1)
						rotateRight(+p);
					rotateLeft(p);
					result = 0;
				}
			}
		}
		// ако сме вмъкнали успешно и балансът се е получил 0
		// значи нямаме промяна във височината
		if (result >= 0 && (*p).balance() == 0)
			result = 0;
		return result;
	}
开发者ID:triffon,项目名称:sdp-2015-16,代码行数:46,代码来源:avltree.cpp


示例18: while

bool ExpressionTreeUtils::fixExprPrecedence(Expression*& top, Expression* e)
{
	if ( dynamic_cast<Value*> (e)) return false;
	if ( dynamic_cast<Empty*> (e)) return false;

	Operator* op = dynamic_cast<Operator*> (e);

	bool more_iterations_needed = true;
	while (more_iterations_needed)
	{
		more_iterations_needed = false;

		// Fix all children
		for (int operand = 0; operand < op->size(); ++operand)
			more_iterations_needed = fixExprPrecedence(top, op->at(operand)) || more_iterations_needed;
	}

	//Look left
	if (op->descriptor()->prefix().isEmpty())
	{
		Operator* left = dynamic_cast<Operator*> (op->first());
		if (left && left->descriptor()->postfix().isEmpty())
		{
			if (op->descriptor()->precedence() < left->descriptor()->precedence() // Must rotate because of precedence

				 // Must rotate because of associativity. This assumes that the associativity of different operators at the same precedence level is the same.
				 || ( (op->descriptor()->precedence() == left->descriptor()->precedence()) && op->descriptor()->associativity() == OperatorDescriptor::RightAssociative)
				 )
			{
				rotateRight(top, left, op);
				return true;
			}
		}
	}

	//Look right
	if (op->descriptor()->postfix().isEmpty())
	{
		Operator* right = dynamic_cast<Operator*> (op->last());
		if (right && right->descriptor()->prefix().isEmpty())
		{
			if (op->descriptor()->precedence() < right->descriptor()->precedence() // Must rotate because of precedence

				 // Must rotate because of associativity. This assumes that the associativity of different operators at the same precedence level is the same.
				 || ( (op->descriptor()->precedence() == right->descriptor()->precedence()) && op->descriptor()->associativity() == OperatorDescriptor::LeftAssociative)
				 )
			{
				rotateLeft(top, right, op);
				return true;
			}
		}
	}

	return false;
}
开发者ID:helandre,项目名称:Envision,代码行数:55,代码来源:ExpressionTreeUtils.cpp


示例19: main

int main(void)
{
	setupADC();	
	setupStepperMotor();
	startTimer();

	USART_init();
	
	mouse.velocity = 0;
	mouse.maxVelocity = 5000;
	mouse.acceleration = 2000;
	mouse.deceleration = 10000;

	enableDrive(1);
	turnOnTimers(1,1);
	
	for(int i = 0; i < 10; i++)
	{		
		int right = isWallRight();
		int front = isWallFront();
		int left = isWallLeft();
		
		if(!right)
		{
			rotateRight();
		}
		else if(front && !left)
		{
			rotateLeft();
		}
		else if(front)
		{
			moveBackwardsAndCorrect();
		}	
		
		if(left && right)		
			mouse.IR_CORRECT = 20;
		
		moveForwardAndStop();
		
		mouse.IR_CORRECT = 0;
		
		
	}

	
	turnOnTimers(0, 0);
	enableDrive(0);
	
	
	while(1==1)
	{

	}	
}
开发者ID:rohankaps123,项目名称:Micromouse2014,代码行数:55,代码来源:main.c


示例20: malloc

bnode *addNode(bnode *root, char *input)
{
		if (root == NULL)
		{
				bnode *newNode = malloc(sizeof(bnode));
				newNode -> word = malloc(sizeof(char) * strlen(input) + 1);
				strcpy(newNode -> word, input);
				newNode -> freq = 1;
				newNode -> left = NULL;
				newNode -> right = NULL;

				return(newNode);
		}

		match = 0;
		match = strCheck(root, input);

		if (match == 1)
				return(root);

		bnode *parent = root;
		bnode *ptr = root -> left;
		while (ptr != NULL && ptr -> left != NULL)
		{
				if (ptr -> right == NULL)
						break;
				parent = parent -> left;
				ptr = ptr -> left;
		}
		if (ptr == NULL)
				ptr = parent;

		bnode *newNode = malloc(sizeof(bnode));
		newNode -> word = malloc(sizeof(char) * (strlen(input) + 1));
		strcpy(newNode -> word, input);
		newNode -> freq = 1;
		newNode -> left = NULL;
		newNode -> right = NULL;

		if (ptr -> left == NULL)
				ptr -> left = newNode;
		else if (ptr -> right == NULL)
		{
				ptr = rotateLeft(ptr);
				ptr -> right = ptr -> left;
				ptr -> left = newNode;
				if (parent -> left != NULL)
						parent -> left = ptr;
				if (ptr -> right == root)
						root = ptr;
		}

		root = rotateTree(root);
		return(root);
}
开发者ID:sphassan,项目名称:CS-2123,代码行数:55,代码来源:recit4.c



注:本文中的rotateLeft函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ rotateRight函数代码示例发布时间:2022-05-30
下一篇:
C++ ros_syscall函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap