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


C++ printState函数代码示例

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


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

示例1: printState

void Processor::run() {
	scheduler.init ();
	scheduler.updateProcQueue(globalCnt);
	curProc = scheduler.getNextProc();
	printState();
	while(scheduler.hasProc()) {
		execIO();
		if (curProc != 0) {
		  curProc->exec();
		 } else {
		    cycle = procTimeslice - 1;
		  }
		globalCnt++;
		cycle++;
		scheduler.updateProcQueue(globalCnt);
		if ( cycle == procTimeslice) {
		    if (curProc != 0) {
			if(!curProc->isEnd()) {
			    if (!curProc->isIO)
				scheduler.distribProc(curProc);
			} else {
			    scheduler.decreaseProc();
			  }
		      }
			Proc* p = curProc;
			curProc = scheduler.getNextProc();
			cycle = 0;
			if (curProc || p) {
				if (scheduler.hasProc())
					printState ();
			}
		}
	}
}
开发者ID:e-learning,项目名称:aptu-os,代码行数:34,代码来源:processor.cpp

示例2: setup_renderComponent

void setup_renderComponent(ILCLIENT_T *handle,
                           char *renderComponentName,
                           COMPONENT_T **renderComponent)
{
    int err;

    err = ilclient_create_component(handle,
                                    renderComponent,
                                    renderComponentName,
                                    ILCLIENT_DISABLE_ALL_PORTS |
                                        ILCLIENT_ENABLE_INPUT_BUFFERS);
    if (err == -1)
    {
        fprintf(stderr, "RenderComponent create failed\n");
        exit(1);
    }
    printState(ilclient_get_handle(*renderComponent));

    err = ilclient_change_component_state(*renderComponent,
                                          OMX_StateIdle);
    if (err < 0)
    {
        fprintf(stderr, "Couldn't change state to Idle\n");
        exit(1);
    }
    printState(ilclient_get_handle(*renderComponent));
}
开发者ID:bennettpeter,项目名称:mythscripts,代码行数:27,代码来源:il_deinterlace.c

示例3: setup_fxComponent

void setup_fxComponent(ILCLIENT_T *handle,
                       char *fxComponentName,
                       COMPONENT_T **fxComponent)
{
    int err;

    err = ilclient_create_component(handle,
                                    fxComponent,
                                    fxComponentName,
                                    ILCLIENT_DISABLE_ALL_PORTS |
                                        ILCLIENT_ENABLE_INPUT_BUFFERS |
                                        ILCLIENT_ENABLE_OUTPUT_BUFFERS);
    if (err == -1)
    {
        fprintf(stderr, "fxComponent create failed\n");
        exit(1);
    }
    printState(ilclient_get_handle(*fxComponent));

    err = ilclient_change_component_state(*fxComponent,
                                          OMX_StateIdle);
    if (err < 0)
    {
        fprintf(stderr, "Couldn't change state to Idle\n");
        exit(1);
    }
    printState(ilclient_get_handle(*fxComponent));

    // must be before we enable buffers
    setup_deinterlace(*fxComponent);
}
开发者ID:bennettpeter,项目名称:mythscripts,代码行数:31,代码来源:il_deinterlace.c

示例4: hillClimbing

void hillClimbing() {
    int iterations = 0;
    int optimum = (nqueens-1)*nqueens/2;
    
    int current_state[nqueens], i;
    for (i=0; i<nqueens; i++) {
        current_state[i] = queens_buffer[i];
    }
    
    while ((iterations < MAXITER) && (evaluateBuffer() != optimum)) {
        int best_move_evaluation = evaluateBuffer(); // Value to be maximized. Initialize with the current evaluation.
        nsuccessors = 0;
        
        // Loops through all possible moves
        int i, j;
        for (i=0; i<nqueens; i++) {
            for (j=0; j<nqueens; j++) {
                moveQueen(i,j);
                int successor_evaluation = evaluateBuffer();
                if (successor_evaluation > best_move_evaluation) {
                    saveToSuccessors(0);
                    nsuccessors = 1;
                    best_move_evaluation = successor_evaluation;
                }
                else if (successor_evaluation == best_move_evaluation) {
                    saveToSuccessors(nsuccessors);
                    nsuccessors++;
                }
                
                // Undo last move
                setBuffer(current_state);
            }
        }
        
        // Select randomly the best successor
        if (nsuccessors != 0) {
            int random_successor = rand() % nsuccessors;
            setBuffer(successors[random_successor]);
        }
        
        // Update current state
        for (i=0; i<nqueens; i++) {
            current_state[i] = queens_buffer[i];
        }
        
        iterations++;
    }
    if (evaluateBuffer() == optimum) {
        printf ("Solved puzzle.\n");
        printf ("Solution:");
        printState();
        solutions_found++;
    }
    else {
        printf("Puzzle not solved (maximum number of iterations). Final state:\n");
        printState();
    }
}
开发者ID:guilhermealles,项目名称:ArtificialIntelligence,代码行数:58,代码来源:nqueens.c

示例5: simulator_view

static bool simulator_view(WINDOW *out, WINDOW *state, struct program *program,
                           enum STATE *current_state)
{
        int input;
        static int timeout = 0;

        set_state(current_state);

        while (1) {
                wtimeout(state, timeout);
                input = wgetch(status);

                if (program->simulator.memory[program->simulator.PC].isBreakpoint) {
                        popup_window("Breakpoint hit!", 0, true);
                        program->simulator.isPaused = true;
                        program->simulator.memory[program->simulator.PC]
                                .isBreakpoint = false;
                }

                if (QUIT == input) {
                        return false;
                } else if (GOBACK == input) {
                        *current_state = MAIN;
                        program->simulator.isPaused = true;
                        return true;
                } else if (PAUSE == input) {
                        program->simulator.isPaused = !program->simulator.isPaused;
                } else if (START == input || RUN == input) {
                        program->simulator.isPaused = program->simulator.isHalted;
                } else if (RESTART == input) {
                        memPopulated = -1;
                        init_machine(program);
                        wclear(out);
                        wrefresh(out);
                } else if (STEP_NEXT == input) {
                        executeNext(&(program->simulator), output);
                        program->simulator.isPaused = true;
                        printState(&(program->simulator), state);
                } else if (CONTINUE == input) {
                        memPopulated = -1;
                        init_machine(program);
                } else if (CONTINUE_RUN == input) {
                        memPopulated = -1;
                        init_machine(program);
                        program->simulator.isPaused = false;
                }

                if (!program->simulator.isPaused && !program->simulator.isHalted) {
                        executeNext(&(program->simulator), out);
                        timeout = 0;
                } else {
                        set_state(current_state);
                        printState(&(program->simulator), state);
                        timeout = -1;
                        generateContext(context, program, 0, program->simulator.PC);
                }
        }
}
开发者ID:Pyxxil,项目名称:Ncurses-LC3-Simulator,代码行数:58,代码来源:Machine.c

示例6: test_reshape_algorithm

void test_reshape_algorithm() {

	int num1 = tidfa_num;
	
	reshape();
	
	int num2 = tidfa_num;
	
	printf("%d new states are needed!\n", num2 - num1);

	int p = 0;
	int i = 0;
	bool http_accept = false;
	for (; i < strlen(indata); i++) {
		p = tidfa_newtr[p][indata[i]];
		if (new_tidfa_accept[p] != -1) {
			http_accept = true;
			break;
		}
	}
	if (http_accept) i++;
	printf("Tidfa accept state = %d\n", p);
	printf("Character consump = %d\n", i);
	
	tsNode *t = tidfaState[getfa(p)];
	while(t != NULL) {
		if (t->tidfa_q == p) break;
		t = t->next;
	}

	matches = t->matches;
	run_string(indata + i, t->x);

	printState(t->x);
	printf("matches=%d\n", matches);
	
	printf("----------------run all character all once---------------\n");
	state st;
	matches = 0;
	st.flow_data_length = strlen(indata);
	st.flow_data = (const u_char*)indata;
  	while (st.fdpos < st.flow_data_length && st.q != NULL)
		CALL_MEMBER_FN(st, st.q)();
	printState(st);
	printf("matches=%d\n", matches);

	printf("---------------run_fs function---------\n");
	matches = 0;
	state st1;
	for (int j = 0; j < strlen(indata); j++)
		run_fs(indata[j], st1);
	printState(st1);
	
	printf("matches=%d\n", matches);
	
	return ;
}
开发者ID:kun2012,项目名称:OnePassProtocolParsing,代码行数:57,代码来源:genTidfa.cpp

示例7: simulatedAnnealing

void simulatedAnnealing() {
    clock_t clock_start;
    int optimum = (nqueens-1)*nqueens/2;
    int iterations = 0;
    double current_temperature = INITIAL_TEMPERATURE;
    
    // Starts the clock counter
    clock_start = clock();
    while (evaluateBuffer() != optimum && current_temperature > 0.005) {
        // Save current state
        int current_evaluation = evaluateBuffer();
        int current_state[nqueens], i;
        for (i=0; i<nqueens; i++) {
            current_state[i] = queens_buffer[i];
        }
        setBuffer(current_state);
        
        // Make a random move
        int random_queen = rand() % nqueens;
        int random_column = rand() % nqueens;
        moveQueen(random_queen, random_column);
        int successor_evaluation = evaluateBuffer();
        
        int delta = successor_evaluation - current_evaluation;
        // If the chosen successor is better than the current state
        if (delta > 0) {
            // do nothing
        }
        else {
            double probability_of_change = exp(delta/current_temperature);
            double random_number = (rand() % 100) / (double)100;
            if (random_number < probability_of_change) {
                // do nothing
            }
            else { // Else, revert state to the original one
                setBuffer(current_state);
            }
        }
        
        // Update temperature
        current_temperature = timeToTemperature(clock_start);
        iterations++;
    }
    if (evaluateBuffer() == optimum) {
        printf ("Solved puzzle.\n");
        printf ("Solution:");
        printState();
        solutions_found++;
    }
    else {
        printf("Not solved in this iteration. Final state:");
        printState();
    }
}
开发者ID:guilhermealles,项目名称:ArtificialIntelligence,代码行数:54,代码来源:nqueens.c

示例8: test_subroutine_dfa_algorithm

void test_subroutine_dfa_algorithm() {
	int num1 = tidfa_num;
	get_subroutine_dfa();
	int num2 = tidfa_num;
	printf("%d new states are needed!\n", num2 - num1);
	
	
		int p = 0;
	int i = 0;
	bool http_accept = false;
	state midst;
	int mid_matches = 0;
	
	for (; i < strlen(indata); i++) {
		char c = indata[i];
		if (tran_edge[p][c] != NULL) {
			mid_matches += tran_edge[p][c]->matches;
			set_result(tran_edge[p][c]->st, midst);
		}
		
		p = tidfa_newtr[p][c];
		
		if (new_tidfa_accept[p] != -1) {
			http_accept = true;
			break;
		}
	}
	if (http_accept) i++;
	printf("Tidfa accept state = %d\n", p);
	printf("Character consump = %d\n", i);
	
	tsNode *t = tidfaState[getfa(p)];
	while(t != NULL) {
		if (t->tidfa_q == p) break;
		t = t->next;
	}
	set_result(midst, t->x);
	matches = t->matches + mid_matches;
	run_string(indata + i, t->x);

	printState(t->x);
	printf("matches=%d\n", matches);
	
	printf("----------------run all character all once---------------\n");
	state st;
	matches = 0;
	st.flow_data_length = strlen(indata);
	st.flow_data = (const u_char*)indata;
  	while (st.fdpos < st.flow_data_length && st.q != NULL)
		CALL_MEMBER_FN(st, st.q)();
	printState(st);
	printf("matches=%d\n", matches);
	
}
开发者ID:kun2012,项目名称:OnePassProtocolParsing,代码行数:54,代码来源:genTidfa.cpp

示例9: while

/* **********************************
@ Implemented by Daniel Santos & Hung Q Nguyen
@ Note:
* ***********************************/
void Universe::Universe::run() {
  while (window_.isOpen() && elapsedTime_ < uni_total_times) {
    sf::Event event;
    while (window_.pollEvent(event)) {
      switch (event.type) {
        case sf::Event::Closed:
          window_.close();
          break;
        case sf::Event::KeyPressed:
          shipMove(event.key);
          break;
        default:
          break;
      }
    }
    window_.clear();
    // Update and draw
    checkClickOnSprite();
    updateDialog(selectedPlanet_);
    updateUniverse();
    window_.draw(dialogBox_);
    window_.draw(dialogText_);
    window_.draw(textTime_);
    drawStars();
    window_.draw(*ship_);
    window_.display();

    // Update current
    updateTime(step_time);
  }
  printState();
}
开发者ID:dsantosp12,项目名称:finalprojectcomp4,代码行数:36,代码来源:Universe.cpp

示例10: randomSearch

/* A very silly random search 'algorithm' */
void randomSearch() {
    int queen, iter = 0;
    int optimum = (nqueens-1)*nqueens/2;

    while (evaluateBuffer() != optimum) {
        printf("iteration %d: evaluation=%d\n", iter++, evaluateBuffer());
        if (iter == MAXITER) break;  /* give up */
        /* generate a (new) random state: for each queen do ...*/
        for (queen=0; queen < nqueens; queen++) {
            int pos, newpos;
            /* position (=column) of queen */
            pos = columnOfQueen(queen);
            /* change in random new location */
            newpos = pos;
            while (newpos == pos) {
                newpos = random() % nqueens;
            }
            moveQueen(queen, newpos);
        }
    }
    if (iter < MAXITER) {
        printf ("Solved puzzle. ");
    }
    printf ("Final state is");
    printState();
}
开发者ID:guilhermealles,项目名称:ArtificialIntelligence,代码行数:27,代码来源:nqueens.c

示例11: handleInputLine

void handleInputLine() {
  led(ledToggle); 
  ledToggle = ledToggle ? 0 : 1;

  char *value = strchr(inputBuffer, '=');
  if (value) {
    *value = 0; // Zero terminate the key.
    value++;    
    int val = atoi(value);

    for (int i=0;i<P_RW_COUNT;i++) {
      if (!strcmp_P(inputBuffer, getParameterNamePGM(i))) {
	  parameters[i] = val;
	  mprintf(PSTR("Ok: Set p%d = %d\n"), i, val);	
      }
    }
	    
  } else if (*inputBuffer) {
    mprintf(PSTR("Fail '%s'\n"), inputBuffer);
  } else {
    mprintf(PSTR("Status:\n"));	
  }
  
  printState();
}
开发者ID:BsAtHome,项目名称:PhotonSaw,代码行数:25,代码来源:chillerctrl.c

示例12: printState

/*!

 */
bool
TextPrinter::handleShow( const int,
                         const rcsc::rcg::ShowInfoT & show )
{
    if ( ! M_init_written )
    {
        M_init_written = true;
        M_os << "(Init)" << "\n";
    }

    M_os << "(Info ";
    printState( M_os, show.time_ );

    // ball
    M_os << " (ball "
         << show.ball_.x_ << ' ' << show.ball_.y_ << ' '
         << show.ball_.vx_ << ' ' << show.ball_.vy_ << ')';

    // players
    for ( int i = 0; i < rcsc::MAX_PLAYER*2; ++i )
    {
        rcsc::rcg::player_t p;
        rcsc::rcg::Serializer::convert( show.player_[i], p );

        printPlayer( M_os,
                     show.player_[i].side(),
                     show.player_[i].unum_,
                     M_command_count[i],
                     p );
        M_command_count[i].update( show.player_[i] );
    }

    M_os << ")\n";
    return true;
}
开发者ID:AaronCLH,项目名称:IEEE-SB-SETUP,代码行数:38,代码来源:rcg2txt.cpp

示例13: search3x4

/**
 *	@brief		search 3x4 -> 3x3
 *	@param[in]	ac_InitState		state on start
 *	@param[out]	ac_MidState			state on first search end
 *	@param[in]	ac_MoveLog			space moved log
 */
void	search3x4(char* ac_InitState, char* ac_MidState, char* ac_MoveLog)
{
    char	ac_MoveState[FIELD_SIZE];

    printState((char(*)[FIELD_WIDTH])ac_InitState);

    moveState(ac_MoveState, ac_InitState, ac_MoveLog);

    printf("moved :\n");
    printState((char(*)[FIELD_WIDTH])ac_MoveState);

    convertState(ac_MidState, ac_MoveState);

    printf("converted :\n");
    printState((char(*)[FIELD_WIDTH])ac_MidState);
}
开发者ID:andromedroid,项目名称:ame,代码行数:22,代码来源:search_3x4.c

示例14: chi2

//============================================================================
// Print some debug info
//============================================================================
void TbKalmanTrack::print() const {
  std::cout << "This is a kalman fitted tracks with chi2/ndof=" << chi2() << "/"
            << ndof() << std::endl;
  // compute forward/backward chi2
  LHCb::ChiSquare forwardchi2, backwardchi2;
  double chi2X(0), chi2Y(0);
  std::cout << "These are the nodes, with some residuals: " << std::endl;
  for (const LHCb::TbKalmanNode * node : m_nodes) {
    std::cout << node->index() << " " << node->z() << " ";
    //<< node->hasInfoUpstream( LHCb::TbKalmanNode::Forward) << " "
    //<< node->hasInfoUpstream( LHCb::TbKalmanNode::Backward) << " " ;
    printState(node->state(), std::cout);
    //std::cout << node->filterStatus( LHCb::TbKalmanNode::Forward) << " "
    //<< node->filterStatus( LHCb::TbKalmanNode::Backward) << " " ;
    const TbKalmanPixelMeasurement* pixelhit =
        dynamic_cast<const TbKalmanPixelMeasurement*>(node);
    if (pixelhit) {
      std::cout << "residual x = " << pixelhit->residualX() << " +/- "
                << std::sqrt(pixelhit->residualCovX()) << " "
                << "residual y = " << pixelhit->residualY() << " +/- "
                << std::sqrt(pixelhit->residualCovY()) << " ";
      chi2X += pixelhit->residualX() * pixelhit->residualX() / pixelhit->covX();
      chi2Y += pixelhit->residualY() * pixelhit->residualY() / pixelhit->covY();
    }
    std::cout << std::endl;
    forwardchi2 += node->deltaChi2(LHCb::TbKalmanNode::Forward);
    backwardchi2 += node->deltaChi2(LHCb::TbKalmanNode::Backward);
  }
  std::cout << "Forward/backward chi2: " << forwardchi2.chi2() << "/"
            << backwardchi2.chi2() << std::endl;
  std::cout << "X/Y chi2: " << chi2X << "/" << chi2Y << std::endl;
}
开发者ID:ruby64,项目名称:Tb,代码行数:35,代码来源:TbKalmanTrack.cpp

示例15: operator

				void operator()(libmaus2::rank::DNARankMEM const & smem, uint64_t const z) const
				{
					std::ostringstream ostr;
					ostr << prefix << "\t" << z << "\t" << smem;
					setState(tid,ostr.str());
					printState();
				}
开发者ID:gt1,项目名称:yalora,代码行数:7,代码来源:selfie.cpp


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