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

C++ state类代码示例

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

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



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

示例1: decode_octal

    static CharT decode_octal (state &state_)
    {
        std::size_t accumulator_ = 0;
        CharT ch_ = *state_._curr;
        unsigned short count_ = 3;
        bool eos_ = false;

        for (;;)
        {
            accumulator_ *= 8;
            accumulator_ += ch_ - '0';
            --count_;
            state_.increment ();
            eos_ = state_.eos ();

            if (!count_ || eos_) break;

            ch_ = *state_._curr;

            // Don't consume invalid chars!
            if (ch_ < '0' || ch_ > '7')
            {
                break;
            }
        }

        return static_cast<CharT> (accumulator_);
    }
开发者ID:BioinformaticsArchive,项目名称:MulRFRepo,代码行数:28,代码来源:re_tokeniser_helper.hpp


示例2: process

bool process(state* astate, queue<state*>& bfsq)
{
	if(astate->clocks == ten9)
	{
		return print(astate);
	}
	
	for(int i=0; i<9; i++)
	{
		newstate.set(astate);
		newstate.inc(config[i]);
		//cout<<"trying state: "<<newstates[i].getnum()<<", foundsz="<<answers.size()<<endl;

		if(visited.find(newstate.clocks) == visited.end())
		{
			state *ns = new state();
			ns->clocks = newstate.clocks;
			ns->prevop = i+1;
		    ns->prevstate = astate;
			bfsq.push(ns);
			visited[ns->clocks] = true;
			nobj++;
		}
	}
	return true;
}
开发者ID:ragebiswas,项目名称:algorepo,代码行数:26,代码来源:clocks.cpp


示例3: generate

void statement::generate_nested(state & state, ostream & stream)
{
    state.increase_indentation();
    state.new_line(stream);
    generate(state, stream);
    state.decrease_indentation();
}
开发者ID:l0gicpath,项目名称:stream-lang,代码行数:7,代码来源:cpp-gen.cpp


示例4: main

int main() {
    ifstream in("/home/joshua/Downloads/s4.4.in");
    while(1) {
        done=0;
        int N;
        in>>N;
        if(!N) break;
        for(int i=0;i<32609;i++) MHASH[i].clear();
        _.clear();
        m.clear();
        int X;
        for(int i=0;i<N;i++) {
            place p,v;
            in>>X;
            p.push_back(X);
            _.push_back(p);
            v.push_back(i+1);
            m.push_back(v);
        }
        superhash=hash(m);
        recurse(_,0);
        while(Q.size()) {
            state l=Q.front().first;
            int m=Q.front().second;
            Q.pop_front();
            recurse(l,m);
        }
        bool ok=0;
        for(set<gstate>::iterator it=MHASH[superhash].begin();it!=MHASH[superhash].end();++it) {
            if((*it).first==m) { ok=1; cout<< ((*it).second)<<endl; break; }
        }
        if(!ok) cout<<"IMPOSSIBLE"<<endl;
    }
}
开发者ID:jnetterf,项目名称:contests,代码行数:34,代码来源:m4.cpp


示例5: need_calculate

bool table::need_calculate(const state & state) const
{
	return this->street != state.get_street()
		|| this->get_dealer_pos() != state.get_dealer_pos()
		|| this->get_my_player().get_hand() != state.get_pocket()
		|| this->active_players_count() != state.get_active_players_count();
}
开发者ID:levka17,项目名称:FullTiltEquity,代码行数:7,代码来源:poker.cpp


示例6: registerLib

/// Opens a library
///
/// \param s The Lua state.
/// \param name The name of the module to create.
/// \param members The list of member functions to add to the module.
void lutok::registerLib(state& s, const std::map< std::string, cxx_function >& members){
	assert(s.is_table());

    for (std::map< std::string, cxx_function >::const_iterator
         iter = members.begin(); iter != members.end(); iter++) {
        s.push_string((*iter).first);
        s.push_cxx_function((*iter).second);
        s.set_table(-3);
    }
}
开发者ID:LuaDist,项目名称:lutok,代码行数:15,代码来源:operations.cpp


示例7: luaL_getmetatable

static typename lutok::LObject<T>::Index lutok::LObject<T>::push(state& s, T* instance, bool gc) {
	if (!instance) {
		s.push_nil();
		return 0;
	}

	luaL_getmetatable(s._pimpl->lua_state, T::s_lunaClassName);
	if (s.is_nil()) {
		luaL_error(s._pimpl->lua_state, "[Luna::%s] Class %s has not been commited!", __func__, T::s_lunaClassName);
		return 0;
	}
	lutok::LObject<T>::Index metatable = s.get_top();

	subtable(s, metatable, "userdata", "v");
	lutok::LObject<T>::Userdata * userdata = allocUserdata(s, metatable, instance);
	if (userdata) {
		userdata->pT = instance;
		s.push_value(metatable);
		s.set_metatable();
		if (!gc) {
			lua_checkstack(s._pimpl->lua_state, 3);
			subtable(s, metatable, "unmanaged", "k");

			s.push_value(-2);
			s.push_boolean(1);
			s.set_table();
			s.pop(1);
		}
	}
	lua_replace(s._pimpl->lua_state, metatable);
	lua_settop(s._pimpl->lua_state, metatable);
	return metatable;
}
开发者ID:swc4848a,项目名称:LuaSDL-2.0,代码行数:33,代码来源:lobject.cpp


示例8: match

bool simulation::match(const state &left, const state &right)
{
  assert(left.size() == right.size());
  for (size_t i = 0; i < left.size(); i++)
  {
    if (!is_variable(left[i]) && !is_variable(right[i]) && left[i] != right[i])
    {
      return false;
    }
  }
  return true;
}
开发者ID:gijskant,项目名称:mcrl2-pmc,代码行数:12,代码来源:simulation.cpp


示例9: stateChanged

/**
 * @brief setter
 * Der aktuelle Zustand wird geaendert. Das Signal stateChanged(newState.getID()) wird ausgeloest.
 * @param newState neuer Zustand 
 * @return void
 */
void automaton::setState(state newState){
    currentState = newState;
    emit stateChanged(newState.getId());

    // Testfunktion
    QMessageBox msgBox;
    msgBox.setText("Die Id des States auf den zu setzen ist, ist: "+ QString::number(newState.getId()));
    msgBox.exec();

    msgBox.setText("Die Id des neuen States ist: "+ QString::number(currentState.getId()));
    msgBox.exec();
}
开发者ID:tangboshi,项目名称:kinectshop,代码行数:18,代码来源:automaton.cpp


示例10:

/**
FUNCTION: overload == operator
DESCRIPTION: Overloads the == operator so that it can be used to test wheather or not 'this' state is equal to otherState.
RETURN bool - True if in fact 'this' state is equal to otherState
*/
bool state::operator== (const state& otherState) const{
	if(otherState.boardMemoryAllocated == false) return false;
	if(this->getBoard()[0][0] != otherState.getBoard()[0][0])return false;
	if(this->getBoard()[0][1] != otherState.getBoard()[0][1])return false;
	if(this->getBoard()[0][2] != otherState.getBoard()[0][2])return false;
	if(this->getBoard()[1][0] != otherState.getBoard()[1][0])return false;
	if(this->getBoard()[1][1] != otherState.getBoard()[1][1])return false;
	if(this->getBoard()[1][2] != otherState.getBoard()[1][2])return false;
	if(this->getBoard()[2][0] != otherState.getBoard()[2][0])return false;
	if(this->getBoard()[2][1] != otherState.getBoard()[2][1])return false;
	if(this->getBoard()[2][2] != otherState.getBoard()[2][2])return false;
	return true;
}
开发者ID:rsanders16,项目名称:COMS-229--Project-3,代码行数:18,代码来源:8-puzzle.cpp


示例11:

static int lutok::LObject<T>::gcT(state& s) {
	if (luaL_getmetafield(s._pimpl->lua_state, 1, "unmanaged")) {
		s.push_value(1);
		s.get_table();
		if (!s.is_nil()) {
			return 0;
		}
	}

	Userdata* ud = s.to_userdata<UserData>(1);
	T* obj = ud->pT;
	delete obj;
	return 0;
}
开发者ID:swc4848a,项目名称:LuaSDL-2.0,代码行数:14,代码来源:lobject.cpp


示例12: cleaner

/// Creates a module: i.e. a table with a set of methods in it.
///
/// \param s The Lua state.
/// \param name The name of the module to create.
/// \param members The list of member functions to add to the module.
void
lutok::create_module(state& s, const std::string& name,
                     const std::map< std::string, cxx_function >& members)
{
    stack_cleaner cleaner(s);
    s.new_table();
    for (std::map< std::string, cxx_function >::const_iterator
         iter = members.begin(); iter != members.end(); iter++) {
        s.push_string((*iter).first);
        s.push_cxx_function((*iter).second);
        s.set_table(-3);
    }
    s.set_global(name);
}
开发者ID:LuaDist,项目名称:lutok,代码行数:19,代码来源:operations.cpp


示例13: bfs

int bfs(state init) {
	state u, v;
	queue<state> Q;
	map<state, int> R;
	int f;
	
	init = eraseGoal(init);
	Q.push(init), R[init] = 0;
//	print(init);
	if (init.isComplete())
		return 0;
	
	while (!Q.empty()) {
		u = Q.front(), Q.pop();
		int step = R[u];
		
//		print(u);
//		printf("step %d\n", step);
		for (int i = 0; i < 4; i++) {
			v = rotateMap(u, i, f);
			v = eraseGoal(v);
			if (!f || R.count(v))		continue;
			if (v.isComplete())
				return step + 1;
			R[v] = step + 1;
//			print(v);
			Q.push(v);
		}
//		puts("--------------");
//		getchar();
	}
	return -1;
}
开发者ID:JohnXinhua,项目名称:UVa,代码行数:33,代码来源:1063+-+Marble+Game.cpp


示例14: countBlack

double GTPWrapper::countBlack(state bboard){
  double ret=0;
  for(unsigned int i=0;i<(bboard.size()/2);i++)
    if(bboard[2*i]==0 && bboard[(2*i)+1]==1)
      ret++;
  return ret;
}
开发者ID:epichub,项目名称:neatzsche,代码行数:7,代码来源:gtpwrapper.cpp


示例15: next_state

state next_state(const state &s)
{
    auto state_size = s.size();
    state ret;
    ret.reserve(state_size);

    if (!state_size) {
        throw std::runtime_error("empty state");
    }

    // trivial case
    if (state_size == 1) {
        ret.push_back(false);
        return ret;
    }

    // Left border
    ret.push_back(s[1] != s[state_size - 1]);

    for (std::vector<bool>::size_type i = 1; i < state_size - 1; ++i) {
        ret.push_back(s[i - 1] != s[i + 1]);
    }

    // Right border
    ret.push_back(s[state_size - 2] != s[0]);

    return ret;
}
开发者ID:chrisieh,项目名称:dailyprogrammer,代码行数:28,代码来源:main.cpp


示例16: hash

int hash(state& s) {
    int l=0;
    for(int i=0;i<s.size();i++) {
        l+=primes[i]*hash(s[i]);
        l%=32609;
    }
    return l;
}
开发者ID:jnetterf,项目名称:contests,代码行数:8,代码来源:m4.cpp


示例17: while

void PTS::set_frequency_ttls(state& the_state) {

  // find the frequency informations...
  // and exchange the phase informations
  analogout* pts_aout=NULL;
  /* find a analogout section with suitable id */
  state::iterator i=the_state.begin();
  while(i!=the_state.end()) {
    analogout* aout=dynamic_cast<analogout*>(*i);
    if (aout!=NULL && aout->id==id) {
      if (pts_aout==NULL) {
	/* save the informations */
	pts_aout=aout;
      }
      else {
	fprintf(stderr, "found another pts decade section, ignoring\n");
	delete aout;
      }
      /* remove the analog out section */
      the_state.erase(i++);
    }
    else
      ++i;
  } /* state members loop */

  /* now, add the ttl information*/
  if (pts_aout!=NULL) {
    phase_add_ttls(the_state, pts_aout->phase);
    if (pts_aout->frequency!=0) {
      if (frequency==0) {
	set_frequency(pts_aout->frequency);
      }
      /* different frequencies are forbidden */
      else if (frequency!=pts_aout->frequency) {
	fprintf(stderr, "ignoring frequency %g at analogout %d\n",pts_aout->frequency,id);
      }
    }
    delete pts_aout;
  }
  else {
    /* because we use transparent mode, we have to set phase everywhere */
    phase_add_ttls(the_state, phase);
  }

}
开发者ID:BackupTheBerlios,项目名称:damaris-svn,代码行数:45,代码来源:PTS.cpp


示例18: lua_remove

static int lutok::LObject<T>::newT(state& s) {
	lua_remove(s._pimpl->lua_state, 1);

	T* obj = new T(s);
	Userdata* ud = s.new_userdata<Userdata>();
	ud->pT = obj;
	luaL_getmetatable(s._pimpl->lua_state, T::s_lunaClassName);
	s.set_metatable();
	return 1;
}
开发者ID:swc4848a,项目名称:LuaSDL-2.0,代码行数:10,代码来源:lobject.cpp


示例19: heat_capacity_volume

double gasinfo::heat_capacity_volume(const state &st) const {
    double Cv = 0;

    for (int i = 0; i < nc; i++) {
        double x = st.rho[i] * Rspecific[i] * beta[i];
        Cv += x;
    }

    return Cv / st.density();
}
开发者ID:uranix,项目名称:ventilation,代码行数:10,代码来源:gasinfo.cpp


示例20: state

	/**
	COPY CONSTRUCTOR:  state(const state& obj)
	DESCRIPTION:  Deep copyes obj to this object
	PARAMS:
	obj - The obj that this object is about to become.
	*/
state::state(const state& obj){
	this->g = obj.g;
	this->parent = obj.parent;
	if(obj.boardMemoryAllocated == true){
		this->board = new int*[NUM_ROWS_ON_BOARD];
		for(int i = 0 ; i < NUM_ROWS_ON_BOARD; i++)
		{
			this->board[i] = new int[NUM_COLS_ON_BOARD];
		}
		this->board[0][0] = obj.getBoard()[0][0];
		this->board[0][1] = obj.getBoard()[0][1];
		this->board[0][2] = obj.getBoard()[0][2];
		this->board[1][0] = obj.getBoard()[1][0];
		this->board[1][1] = obj.getBoard()[1][1];
		this->board[1][2] = obj.getBoard()[1][2];
		this->board[2][0] = obj.getBoard()[2][0];
		this->board[2][1] = obj.getBoard()[2][1];
		this->board[2][2] = obj.getBoard()[2][2];
		this->move = obj.move;
	}
}
开发者ID:rsanders16,项目名称:COMS-229--Project-3,代码行数:27,代码来源:8-puzzle.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ state_type类代码示例发布时间:2022-05-31
下一篇:
C++ stan类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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