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

C++ revert函数代码示例

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

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



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

示例1: RevertBinaryTree

void RevertBinaryTree(std::unique_ptr<TreeNode<T>>& root) {
    if (root != nullptr) {
        root->left.swap(root->right);
        revert(root->left);
        revert(root->right);
    }
}
开发者ID:Lightertu,项目名称:coding,代码行数:7,代码来源:RevertBinaryTree.cpp


示例2: play

/*
	Basically the same code as minimax. It initiates the move making process. 
*/
void AI::make_move(int current_player, Board* game_board) {
	//Defines max and min possible scores.
	int alpha = -2000;
	int beta = 2000;
	//The depth is initially 0. This will be incremented after every recursive call to minimax. 
	int depth = 0;
	//Defines the best possible score so far and a default position. 
	int best_score;
	int position = 4;

	//If player is X. 
	if (current_player == 1) {
		//We try to get a better score than alpha, so we default to alpha in the beginning. 
		best_score = alpha;
		//We basically perform all 7 (at most) possible moves. 
		for (int i = 1; i < 8; ++i) {
			//Only if i is a valid move.
			if (valid_move(i)) {
				//It plays the move i in the vector and simply recursively calls minimax to maximize (or minimize) its score and revert all moves.
				play(current_player, i);
				int score = minimax(best_score, beta, -current_player, game_board, depth);
				if (score > best_score) {
					//Score and position are stored. 
					best_score = score;
					position = i;
				}
				//Move is reverted. 
				revert(current_player, i);

				//Here we perform alpha beta pruning, which enables us to discard large sections of the Search Tree. 
				if (beta <= best_score) {
					break;
				}
			}
		}
	}

	//Same process as with 1. 
	else if (current_player == -1) {
		best_score = beta;
		for (int i = 1; i < 8; ++i) {
			if (valid_move(i)) {
				play(current_player, i);
				int score = minimax(alpha, best_score, -current_player, game_board, depth);
				if (score < best_score) {
					best_score = score;
					position = i;
				}
				revert(current_player, i);
				if (best_score <= alpha) {
					break;
				}
			}
		}
	}

	//After determining the best position (from the best score), it makes that move. 
	play(current_player, position);
}
开发者ID:athul777,项目名称:connectfour,代码行数:62,代码来源:AI.cpp


示例3: set_border_color

static void
set_border_color(char *arg)
{
	int color;

	color = get_color_number(arg);
	if (color == -1) {
		revert();
		errx(1, "invalid color '%s'", arg);
	}
	if (ioctl(0, KDSBORDER, color) != 0) {
		revert();
		err(1, "ioctl(KD_SBORDER)");
	}
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:15,代码来源:vidcontrol.c


示例4: KDialog

void IdleTimeDetector::informOverrun()
{
    if (!_overAllIdleDetect)
        return; // In the preferences the user has indicated that he do not
            // want idle detection.

    _timer->stop();
    start = QDateTime::currentDateTime();
    idlestart = start.addSecs(-60 * _maxIdle);
    QString backThen = KGlobal::locale()->formatTime(idlestart.time());
    // Create dialog
        KDialog *dialog=new KDialog( 0 );
        QWidget* wid=new QWidget(dialog);
        dialog->setMainWidget( wid );
        QVBoxLayout *lay1 = new QVBoxLayout(wid);
        QHBoxLayout *lay2 = new QHBoxLayout();
        lay1->addLayout(lay2);
        QString idlemsg=QString( "Desktop has been idle since %1. What do you want to do ?" ).arg(backThen);
        QLabel *label = new QLabel( idlemsg, wid );
        lay2->addWidget( label );
        connect( dialog , SIGNAL(cancelClicked()) , this , SLOT(revert()) );
        connect( wid , SIGNAL(changed(bool)) , wid , SLOT(enabledButtonApply(bool)) );
        QString explanation=i18n("Continue timing. Timing has started at %1", backThen);
        QString explanationrevert=i18n("Stop timing and revert back to the time at %1.", backThen);
        dialog->setButtonText(KDialog::Ok, i18n("Continue timing."));
        dialog->setButtonText(KDialog::Cancel, i18n("Revert timing"));
        dialog->setButtonWhatsThis(KDialog::Ok, explanation);
        dialog->setButtonWhatsThis(KDialog::Cancel, explanationrevert);
        // The user might be looking at another virtual desktop as where ktimetracker is running
        KWindowSystem::self()->setOnDesktop( dialog->winId(), KWindowSystem::self()->currentDesktop() );
        KWindowSystem::self()->demandAttention( dialog->winId() );
        kDebug(5970) << "Setting WinId " << dialog->winId() << " to deskTop " << KWindowSystem::self()->currentDesktop();
        dialog->show();
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:34,代码来源:idletimedetector.cpp


示例5: mw

View::View(Kate::MainWindow *mainWindow)
  : Kate::PluginView(mainWindow)
  , mw(mainWindow)
{
  toolView = mainWindow->createToolView("KatecodeinfoPlugin", Kate::MainWindow::Bottom, SmallIcon("msg_info"), i18n("Codeinfo"));
  QWidget* w = new QWidget(toolView);
  setupUi(w);
  config();
  w->show();

  btnConfig->setIcon(KIcon("configure"));

  m_nregex = NamedRegExp();
  updateCmbActions();
  updateGlobal();

  connect(btnFile, SIGNAL(clicked()), this, SLOT(loadFile()));
  connect(btnClipboard, SIGNAL(clicked()), this, SLOT(loadClipboard()));
  connect(btnRun, SIGNAL(clicked()), this, SLOT(run()));
  connect(btnConfig, SIGNAL(clicked()), this, SLOT(config()));
  connect(btnSave, SIGNAL(clicked()), this, SLOT(save()));
  connect(btnRevert, SIGNAL(clicked()), this, SLOT(revert()));

  connect(lstCodeinfo, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(infoSelected(QTreeWidgetItem*, int)));
  connect(cmbActions, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(actionSelected(const QString &)));
  connect(txtRegex, SIGNAL(textChanged(QString)), this, SLOT(regexChanged(QString)));
  connect(txtCommand, SIGNAL(textChanged(QString)), this, SLOT(commandChanged(QString)));
  actionSelected(cmbActions->currentText());
}
开发者ID:hgrecco,项目名称:KateCodeinfo,代码行数:29,代码来源:kciview.cpp


示例6: main

int main(int argc, char* argv) {
    long long sum = 0;
    int digits[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    long long num = is_qualified(digits);
    if (num > 0) {
        //printf("qualified number = %lld\n", num);
        sum = sum + num;
    }
    int n = 9;
    int i = n;
    while (i > 0) {
        int prev = i - 1;
        if (digits[prev] < digits[i]) {
            for (int j = n; j >= i; j--) {
                if (digits[j] > digits[prev]) {
                    swap(&digits[j], &digits[prev]);
                    if (i < n) revert(digits, i, n);
                    i = n;
                    break;
                }
            }
            num = is_qualified(digits);
            if (num > 0) {
                //printf("qualified number = %lld\n", num);
                sum = sum + num;
            }
        } else {
            i--;
        }
    }
    printf("sum = %lld\n", sum);
}
开发者ID:yizha,项目名称:projecteuler,代码行数:32,代码来源:main.c


示例7: revert

weighted_point eigen_feature_mapper::revert(
    const eigen_wsvec_t& src) const {
  weighted_point ret;
  ret.weight = src.weight;
  ret.data = revert(src.data);
  return ret;
}
开发者ID:AutonomicSecurity,项目名称:jubatus,代码行数:7,代码来源:eigen_feature_mapper.cpp


示例8: revert

void MickeyApplyDialog::on_RevertButton_pressed()
{
  timer.stop();
  //std::cout<<"Reverting..."<<std::endl;
  emit revert();
  hide();
}
开发者ID:FreakTheMighty,项目名称:linux-track,代码行数:7,代码来源:mickey.cpp


示例9: JUBATUS_EXCEPTION

  // return at most n nodes, if theres nodes less than n, return size is also less than n.
  // find(hash)    :: lock_service -> key -> [node] where hash(node0) <= hash(key) < hash(node1)
  bool cht::find(const std::string& key, std::vector<std::pair<std::string,int> >& out, size_t n){
    out.clear();
    std::vector<std::string> hlist;
    if(! get_hashlist_(key, hlist)){
      throw JUBATUS_EXCEPTION(not_found(key));
    }
    std::string hash = make_hash(key);
    std::string path = ACTOR_BASE_PATH + "/" + name_ + "/cht";

    std::vector<std::string>::iterator node0 = std::lower_bound(hlist.begin(), hlist.end(), hash);
    size_t idx = int(node0 - hlist.begin()) % hlist.size();
    std::string loc;
    for(size_t i=0; i<n; ++i){
      std::string ip;
      int port;
      if(lock_service_->read(path + "/" + hlist[idx], loc)){
        revert(loc, ip, port);
        out.push_back(make_pair(ip,port));
      }else{
        // TODO: output log
        throw JUBATUS_EXCEPTION(not_found(path));
      }
      idx++;
      idx %= hlist.size();
    }
    return !hlist.size();
  }
开发者ID:PKConsul,项目名称:jubatus,代码行数:29,代码来源:cht.cpp


示例10: connect

void IgnoreListModel::clientConnected() {
  connect(Client::ignoreListManager(), SIGNAL(updated()), SLOT(revert()));
  if(Client::ignoreListManager()->isInitialized())
    initDone();
  else
    connect(Client::ignoreListManager(), SIGNAL(initDone()), SLOT(initDone()));
}
开发者ID:hades,项目名称:quassel,代码行数:7,代码来源:ignorelistmodel.cpp


示例11: revert

void IgnoreListModel::commit() {
  if(!_configChanged)
    return;

  Client::ignoreListManager()->requestUpdate(_clonedIgnoreListManager.toVariantMap());
  revert();
}
开发者ID:hades,项目名称:quassel,代码行数:7,代码来源:ignorelistmodel.cpp


示例12: QObject

VideoProcessor::VideoProcessor(QObject *parent)
  : QObject(parent)
  , delay(-1)
  , rate(0)
  , fnumber(0)
  , length(0)
  , stop(true)
  , modify(false)
  , curPos(0)
  , curIndex(0)
  , curLevel(0)
  , digits(0)
  , extension(".avi")
  , levels(4)
  , alpha(10)
  , lambda_c(80)
  , fl(0.05)
  , fh(0.4)
  , chromAttenuation(0.1)
  , delta(0)
  , exaggeration_factor(2.0)
  , lambda(0)
{
    connect(this, SIGNAL(revert()), this, SLOT(revertVideo()));
}
开发者ID:1a2b,项目名称:QtEVM,代码行数:25,代码来源:VideoProcessor.cpp


示例13: tr

	void GraffitiTab::renameFiles ()
	{
		if (!FilesModel_->GetModified ().isEmpty ())
		{
			auto res = QMessageBox::question (this,
					"LMP Graffiti",
					tr ("You have unsaved files with changed tags. Do you want to save or discard those changes?"),
					QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
			if (res == QMessageBox::Save)
				save ();
			else if (res == QMessageBox::Discard)
				revert ();
			else
				return;
		}

		QList<MediaInfo> infos;
		for (const auto& index : Ui_.FilesList_->selectionModel ()->selectedRows ())
			infos << index.data (FilesModel::Roles::MediaInfoRole).value<MediaInfo> ();
		if (infos.isEmpty ())
			return;

		auto dia = new RenameDialog (LMPProxy_, this);
		dia->SetInfos (infos);

		dia->setAttribute (Qt::WA_DeleteOnClose);
		dia->show ();
	}
开发者ID:MellonQ,项目名称:leechcraft,代码行数:28,代码来源:graffititab.cpp


示例14: SLOT

	void GraffitiTab::SetupToolbar ()
	{
		Save_ = Toolbar_->addAction (tr ("Save"),
				this, SLOT (save ()));
		Save_->setProperty ("ActionIcon", "document-save");
		Save_->setShortcut (QString ("Ctrl+S"));

		Revert_ = Toolbar_->addAction (tr ("Revert"),
				this, SLOT (revert ()));
		Revert_->setProperty ("ActionIcon", "document-revert");

		Toolbar_->addSeparator ();

		RenameFiles_ = Toolbar_->addAction (tr ("Rename files"),
				this, SLOT (renameFiles ()));
		RenameFiles_->setProperty ("ActionIcon", "edit-rename");

		Toolbar_->addSeparator ();

		GetTags_ = Toolbar_->addAction (tr ("Fetch tags"),
				this, SLOT (fetchTags ()));
		GetTags_->setProperty ("ActionIcon", "download");

		SplitCue_ = Toolbar_->addAction (tr ("Split CUE..."),
				this, SLOT (splitCue ()));
		SplitCue_->setProperty ("ActionIcon", "split");
		SplitCue_->setEnabled (false);
	}
开发者ID:MellonQ,项目名称:leechcraft,代码行数:28,代码来源:graffititab.cpp


示例15: make_hash

  // find(hash)    :: lock_service -> key -> [node] where hash(node0) <= hash(key) < hash(node1)
  bool cht::find(const std::string& key, std::vector<std::pair<std::string,int> >& out){
    out.clear();
    std::string path = ACTOR_BASE_PATH + "/" + name_ + "/cht";
    std::string hash = make_hash(key);
    std::vector<std::pair<std::string, int> > ret;
    std::vector<std::string> hlist;
    lock_service_->list(path, hlist);

    if(hlist.empty()) return false;
    std::sort(hlist.begin(), hlist.end());

    std::vector<std::string>::iterator node0 = std::lower_bound(hlist.begin(), hlist.end(), hash);
    size_t idx = int(node0 - hlist.begin()) % hlist.size();
    std::string loc;
    for(int i=0; i<2; ++i){
      std::string ip;
      int port;
      if(lock_service_->read(path + "/" + hlist[idx], loc)){
        revert(loc, ip, port);
        out.push_back(make_pair(ip,port));
      }else{
        // TODO: output log
      }
      idx++;
      idx %= hlist.size();
    }
    return !hlist.size();
  }
开发者ID:profjsb,项目名称:jubatus,代码行数:29,代码来源:cht.cpp


示例16: dfaRightQuotient

void dfaRightQuotient(DFA *a, unsigned var_index) 
{
  graph *G;
  int i;
  state_inf_fwd *R = mem_alloc(sizeof(*R)*(a->ns));
  int *f = mem_alloc(sizeof(*f)*(a->ns));
    
  for (i=0; i<a->ns; i++) {
    R[i].go_1 = read00(a->bddm, a->q[i], var_index, 0);
    R[i].go_2 = read00(a->bddm, a->q[i], var_index, 1);
    R[i].is_final = (a->f[i] == 1)? 1 : 0;
  };
  /* find states from which some string of 00..00X00..00
     letters can reach a +1 state; put result in f */
  G = revert(R, a->ns);
  make_finals(G, R, a->ns);
  color(G);
  for(i=0;i<a->ns;i++) 
    f[i] = (G->F[i]? 1 : 0);
  /* find states from which some string of 00..00X00..00
     letters can reach a -1 state */
  for (i=0; i<a->ns; i++) 
    R[i].is_final = (a->f[i] == -1)? 1 : 0;
  make_finals(G, R, a->ns);
  color(G);
  /* now a state is +1 if some path along 00..00x00..00 letters takes
     it to an original +1 state; otherwise, the state is -1 if some
     such path takes it to an original -1 state: */
  for(i=0;i<a->ns;i++) {
    a->f[i] = (f[i]? 1 : (G->F[i]? -1 : 0));
  }
  free_G(G, a->ns);
  mem_free(f);
  mem_free(R);
}
开发者ID:ondrik,项目名称:mona-vata,代码行数:35,代码来源:quotient.c


示例17: main

int main()
{
	char  text[] = {"hello i am a student"};
	//text[5] = 'm';
	char*  start = text;
	char*  end = text;
	while (*start != '\0')
	{
		if (*end == ' ' || *end == '\0')
		{
			revert(start, end - 1);
			if (*end == '\0')
			{
				break;
			}
			start = ++end;
		}
		else
		{
			++end;
		}
	}
	printf("length = %d\n", strlen(text));
	printf("value = %s\n", text);
	return 0;
}
开发者ID:OJ-China,项目名称:language,代码行数:26,代码来源:textRevert.c


示例18: switch

int QAbstractItemModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: dataChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break;
        case 1: headerDataChanged((*reinterpret_cast< Qt::Orientation(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 2: layoutChanged(); break;
        case 3: layoutAboutToBeChanged(); break;
        case 4: rowsAboutToBeInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 5: rowsInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 6: rowsAboutToBeRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 7: rowsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 8: columnsAboutToBeInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 9: columnsInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 10: columnsAboutToBeRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 11: columnsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 12: modelAboutToBeReset(); break;
        case 13: modelReset(); break;
        case 14: rowsAboutToBeMoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QModelIndex(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break;
        case 15: rowsMoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QModelIndex(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break;
        case 16: columnsAboutToBeMoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QModelIndex(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break;
        case 17: columnsMoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3])),(*reinterpret_cast< const QModelIndex(*)>(_a[4])),(*reinterpret_cast< int(*)>(_a[5]))); break;
        case 18: { bool _r = submit();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 19: revert(); break;
        default: ;
        }
        _id -= 20;
    }
    return _id;
}
开发者ID:venkatarajasekhar,项目名称:ECE497,代码行数:34,代码来源:moc_qabstractitemmodel.cpp


示例19: isPalindrome

 bool isPalindrome(ListNode* head) {
     if (head == NULL)
     {
         return true;
     }
     ListNode *quick = head;
     ListNode *slow = head;
     while (quick->next && quick->next->next)
     {
         quick  = quick->next->next;
         slow = slow->next;
     }
     ListNode *left = head;
     ListNode *right = revert(slow);
     while (left != NULL)
     {
         if (left->val != right->val)
         {
             return false;
         }
         left = left->next;
         right = right->next;
     }
     return true;
 }
开发者ID:shuye00123,项目名称:shuye,代码行数:25,代码来源:Palindrome+Linked+List.cpp


示例20: TF_ASSERT

void BaseEditor::actionSaveAs()
{
	auto uiFramework = pImpl_->get<IUIFramework>();
	TF_ASSERT(uiFramework != nullptr);
	if (!uiFramework)
	{
		return;
	}

	auto path = uiFramework->showSaveAsFileDialog("Save As", lastSaveFolder(), fileSaveFilter(), IUIFramework::None);
	if (!path.empty())
	{
		clearCheckoutState();
		setLastSaveFolder(FilePath::getFolder(path));
		if(onSaveAs(path.c_str()))
		{
			auto editor = pImpl_->get<IEditor>();
			TF_ASSERT(editor != nullptr);
			if (editor)
			{
				editor->saveAs(path.c_str());
			}
			auto assetManager = pImpl_->get<IAssetManager>();
			if (assetManager)
			{
				auto assetModel = assetManager->assetModel();
				if (assetModel)
				{
					assetModel->revert();
				}
			}
		}
	}
}
开发者ID:wgsyd,项目名称:wgtf,代码行数:34,代码来源:base_editor.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ rewind函数代码示例发布时间:2022-05-30
下一篇:
C++ reverseList函数代码示例发布时间: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