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


C++ TNode::getValue方法代码示例

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


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

示例1: if

void bsTree<T>::remove(const T & item)
{	
		TNode<T> *tN = search(root, item);					//Returns node of value, item.
		if(!tN) 											//if node is not found, remove nothing.
			return;	

		TNode<T> *pN= tN->getParent();						//Points to tN's parent.
		
		if(tN->getLeft() == NULL && tN->getRight() == NULL) //node is leaf
		{
			removeLink(tN, pN, NULL);
		}
		else if(tN->hasOnlyLeft())						    //Node has only left child
		{
			removeLink(tN, pN, tN->getLeft());
		}
		else if(tN->hasOnlyRight())						    //Node has only right child
		{
			removeLink(tN, pN, tN->getRight());
		}
		else 											    // has two children
		{
			if(tN->getValue() > root->getValue())
			{
				getSmallest(tN->getRight(), tN, tN);
			}
			else
			{
				getBiggest(tN->getLeft(), tN, tN);
			}
		}
}
开发者ID:austinhofmann,项目名称:School,代码行数:32,代码来源:bsTree.cpp

示例2: fillResult

string QueryEvaluator::fillResult(TNode * node, int value) {
	string name = node->getValue();
	string type = table.getType(name); 
	// special case
	if (type==KEYWORD_CALL) {
		if (node->getNumChildren()!=0) {
			TNode * attr = node->getChildAtIndex(0);
			if (attr->getType()==Attr &&
				attr->getValue()=="procName") {
					value = PKB::getCalledProc(value);
					type=KEYWORD_PROCEDURE;
			}
		}
	}

	if (type==KEYWORD_PROCEDURE) {
		return PKB::getProcName(value);
	} else if (type==KEYWORD_VAR) {
		return PKB::getVarName(value);
	} else if (type==KEYWORD_CONST) {
		return PKB::getConstName(value);
	} else if (type==KEYWORD_PROG_LINE || SyntaxHelper::isStmtSymbol(type)) {
		return to_string((long long)value); 
	} else {
	}
	return "-1";
}
开发者ID:SeanNguyen,项目名称:cs3202-team-4-repo,代码行数:27,代码来源:QueryEvaluator.cpp

示例3: atoi

vector<int> QueryEvaluator::getAttrIndex(TNode * node, string attr_value) {
	vector<int> result;

	string symbol_name = node->getValue();
	Symbol symbol_type = SyntaxHelper::getSymbolType(table.getType(symbol_name));

	if (symbol_type==CallStmt) {
		TNode * attr = node->getChildAtIndex(0);
		if (attr->getValue()=="procName") {
			result = PKB::getCallingStmt(PKB::getProcIndex(attr_value).front());
			return result;
		}
	}

	switch(symbol_type) {
	case Procedure:
		{
			result.push_back(PKB::getProcIndex(attr_value).front());
			break;
		}
	case Var:
		{
			result.push_back(PKB::getVarIndex(attr_value));
			break;
		}
	case Const:
		{
			result.push_back(PKB::getConstIndex(attr_value));
			break;
		}
	case Prog_line:
	case Stmt:
	case Assign:
	case If:
	case While:
	case CallStmt:
		{
			int value = atoi(attr_value.c_str());
			if ((value>0 && value<PKB::getStatTableSize()) && 
				(table.getType(symbol_name)==KEYWORD_STMT ||
				table.getType(symbol_name)==KEYWORD_PROG_LINE ||
				table.getType(symbol_name)==PKB::getStmtName(value))) {
				result.push_back(value);
			}
			break;
		}
	default:
		break;
	}

	//remove all values = -1
	if (result.size()==1 && result[0]==-1) {
		result.clear();
	}

	return result;
}
开发者ID:SeanNguyen,项目名称:cs3202-team-4-repo,代码行数:57,代码来源:QueryEvaluator.cpp

示例4: getAttrValue

string QueryEvaluator::getAttrValue(TNode * node, int index) {
	string result = "-1";

	if (index==-1) return result;

	string symbol_name = node->getValue();
	Symbol symbol_type = SyntaxHelper::getSymbolType(table.getType(symbol_name));

	switch(symbol_type) {
	case Procedure:
		{
			result = PKB::getProcName(index);
			break;
		}
	case Var:
		{
			result = PKB::getVarName(index);
			break;
		}
	case Const:
		{
			result = PKB::getConstName(index);
			break;
		}
	case Stmt:
	case Prog_line:
	case Assign:
	case While:
	case If:
	case CallStmt:
		{
			if (symbol_type==CallStmt) {
				TNode * attr = node->getChildAtIndex(0);
				if (attr->getValue()=="procName") {
					result = PKB::getProcName(PKB::getCalledProc(index));
				} else {
					result = to_string((long long)index);
				}
			} else {
				result = to_string((long long)index);
			}
			break;
		}
	default:
		break;
	}

	return result;
}
开发者ID:SeanNguyen,项目名称:cs3202-team-4-repo,代码行数:49,代码来源:QueryEvaluator.cpp

示例5: getSymbolsUsedBy

vector<string> QueryEvaluator::getSymbolsUsedBy(TNode * node) {
	vector<string> results;

	int size = node->getNumChildren();
	for (int i=0; i<size; i++) {
		TNode * child = node->getChildAtIndex(i);
		if (child->getType()==QuerySymbol) {
			results.push_back(child->getValue());
		}
		vector<string> sub_results = getSymbolsUsedBy(child);
		for (size_t j=0; j<sub_results.size(); j++) {
			if (find(results.begin(), results.end(), sub_results[j])==results.end())
				results.push_back(sub_results[j]);
		}
 	}

	return results;
}
开发者ID:SeanNguyen,项目名称:cs3202-team-4-repo,代码行数:18,代码来源:QueryEvaluator.cpp


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