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


C++ States::is_element方法代码示例

本文整理汇总了C++中States::is_element方法的典型用法代码示例。如果您正苦于以下问题:C++ States::is_element方法的具体用法?C++ States::is_element怎么用?C++ States::is_element使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在States的用法示例。


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

示例1: validate

	/* Name: validate
	* Purpose: To find if the all of the transtions are valid.
	* Operation: This method it checks that each transition is based on the class States,
		Tape_Alphabet, and moves R or L.
	*/
void Transition_Function::validate(const Tape_Alphabet &tape_alphabet, States states, bool & valid){

		// Prevent two transitions from having the same source_state and Read_Character
	for (unsigned int i = 0; i < transitions.size(); i++){		
		for(unsigned int z = i + 1; z < transitions.size(); z++){			
			if(transitions[i].Source_State() == transitions[z].Source_State()
			&& transitions[i].Read_Character() == transitions[z].Read_Character()){
				valid = false;
				cout << "Error: Two transitions have the same source state '" << transitions[i].Source_State() << "' and read character '" << transitions[i].Read_Character() << "'.\n";
			}			
		}		
	}

		// Validate the the tape alphabet elements.
	for (unsigned int i = 0; i < transitions.size(); i++){

			// The read character is not contained within the tape alphabet.
		if (!tape_alphabet.is_element(transitions[i].Read_Character())){			
			cout << "Error: Transition read character '" << transitions[i].Read_Character() << "' is not in tape alphabet.\n";
			valid = false;
		}

			// The write character is not contained within the tape alphabet.
		if (!tape_alphabet.is_element(transitions[i].Write_Character())){
			cout << "Error: Transition write character '" << transitions[i].Write_Character() << "' is not in tape alphabet.\n";
			valid = false;
		}
	}

		// Validate that all of the states are in the list of states.
	for (unsigned int i = 0; i < transitions.size(); i++){

			// The source state is not in the list of states.
		if (!states.is_element(transitions[i].Source_State())){
			cout << "Error: Transition source state '" << transitions[i].Source_State() << "' is not in states.\n";

			valid = false;
		}

			// The destination state is not in the list of states. 
		if (!states.is_element(transitions[i].Destination_State())){
			cout << "Error: Transition destination state '" << transitions[i].Destination_State() << "' is not in states.\n";

			valid = false;
		}
	}
	
}
开发者ID:SkullCrusher,项目名称:Rex-The-Biplane,代码行数:53,代码来源:Transition_Function.cpp


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