当前位置: 首页>>代码示例>>C++>>正文


C++ state类代码示例

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


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


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