本文整理汇总了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_);
}
示例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;
}
示例3: generate
void statement::generate_nested(state & state, ostream & stream)
{
state.increase_indentation();
state.new_line(stream);
generate(state, stream);
state.decrease_indentation();
}
示例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;
}
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}