本文整理汇总了C++中VariableList类的典型用法代码示例。如果您正苦于以下问题:C++ VariableList类的具体用法?C++ VariableList怎么用?C++ VariableList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VariableList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNumVar
OptError CGProblem::CreateApplicationOptimizer(OptimizeClass* &objfcn,
NLP0* &func)
{
OptError error;
int numVar = GetNumVar();
VariableList* variables = GetVariables();
AppLauncher* launcher = GetAppLauncher();
USERFCN0APP userFcn = &(launcher->run_app);
INITFCNAPP initFcn = &(launcher->init_app);
if ((variables->upperExists()) || (variables->lowerExists()) ||
(variables->linearExists()) || (variables->nonlinearExists()))
{
cout << "CG does not support constraints." << endl;
cout << "Constraints being ignored" << endl;
}
FDNLF1APP * myFunc = new FDNLF1APP(numVar, userFcn, initFcn,
launcher);
myFunc->setIsExpensive(true);
func = myFunc;
objfcn = new OptCG(myFunc);
error.value = 0;
error.msg = "Success";
return error;
}
示例2: whereClause
virtual void whereClause (const WhereClause* const, const TableOperation* p_GroupGraphPattern, const BindingClause* p_BindingClause) {
ResultSet* joined(NULL);
const ResultSet* working = &rs;
if (p_BindingClause != NULL) {
working = joined = new ResultSet(rs);
p_BindingClause->bindVariables(NULL, joined);
}
vars.clear(); // probably got filled with e.g. select vars.
p_GroupGraphPattern->express(this);
const TableOperation* op = last.tableOperation;
const VariableList* knownVars = working->getKnownVars();
std::vector<const POS*> v(vars.size() + knownVars->size());
std::vector<const POS*>::iterator needed =
std::set_intersection (vars.begin(), vars.end(), knownVars->begin(),
knownVars->end(), v.begin());
const std::set<const POS*> s(v.begin(), v.end());
const Expression* filter = working->getFederationExpression(s, false);
if (filter) {
Filter* f = new Filter(op);
f->addExpression(filter);
op = f;
}
if (joined)
delete joined;
last.whereClause = new WhereClause(op, NULL);
}
示例3:
std::vector<FormalParameter> juli::Function::transformParameterList(VariableList args, const TypeInfo& typeInfo) {
std::vector<FormalParameter> formalArguments;
for (VariableList::iterator i = args.begin(); i != args.end(); ++i) {
formalArguments.push_back(FormalParameter((*i)->type->resolve(typeInfo), (*i)->name->name));
}
return formalArguments;
}
示例4: handleFunctionDeclaration
BaseExpression* Parser::handleFunctionDeclaration(DragonType type, string name)
{
VariableList args;
LexerToken nextToken;
DragonVariable argument = {TYPE_NONE, ""};
while(nextToken.value[0] != ')') {
nextToken = mLexer->getToken();
switch (nextToken.type) {
case TYPE:
argument.type = toDragonType(nextToken.value);
break;
case IDENTIFIER:
if(argument.type != TYPE_NONE) {
argument.name = nextToken.value;
args.push_back(argument);
argument.type = TYPE_NONE;
} else {
printf("No type specified '%s' in argument list for function '%s'", argument.name.c_str(), name.c_str());exit(0);
}
break;
case BRACE:
case SPECIAL_SYMBOL:
break;
default:
printf("Unexpected '%s' in argument list for function '%s',"
" expected ','", nextToken.value.c_str(), name.c_str());exit(0);
break;
}
}
return new FunctionDeclExpr(type, name, args);
}
示例5: env
//执行
void COpScript::Execute(CMoveShape* pShape)
{
#ifdef _RUNSTACKINFO1_
CMessage::AsyWriteFile(GetGame()->GetStatckFileName(), "COpScript::Execute() begin");
#endif
// [5/4/2009 chenxianj]
//CScript *pTempScript = PopFreeScript("COpScript::Execute");
//if (pTempScript)
//{
// pTempScript->SetVariableList(m_pParam->pVariableList);
// pTempScript->SetUsedItemID(m_pParam->GoodsGuid);
// pTempScript->SetSrcShapeEx(m_pParam->pUser);
// // [5/4/2009 chenxianj]
// itExpress it = m_Expressions.begin();
// for(;it != m_Expressions.end();it++)
// {
// if(m_pParam->pUser)
// pTempScript->SetRegion(dynamic_cast<CRegion*>(m_pParam->pUser->GetFather()));
// else
// pTempScript->SetRegion(NULL);
// (*it)->Execute(pTempScript,pShape);
// }
// // [5/4/2009 chenxianj]
// PushFreeScript(pTempScript);
//}
Script::RunEnv env( m_pParam->pUser, pShape, static_cast<CRegion*>( m_pParam->pUser->GetFather() ),
m_pParam->pVariableList );
VariableList *varList = m_pParam->pVariableList;
if( !varList->AddVar( "$ParamA", (double)(DWORD)m_pParam->pUser ) )
{
varList->SetVarValue( "$ParamA", (double)(DWORD) m_pParam->pUser );
}
if( !varList->AddVar( "$ParamB", (double)(DWORD)pShape ) )
{
varList->SetVarValue( "$ParamB", (double)(DWORD) pShape );
}
Script *script = GetInst( ScriptSys ).NewScript( env );
for( itExpress it = m_Expressions.begin(); it != m_Expressions.end(); ++ it )
{
CExpressions *exp = *it;
int ret = exp->Execute( script, pShape );
if( !script->CanDelete( ret ) )
{
// yield script, cannot run.
assert( "Yield script" && 0 );
}
}
GetInst( ScriptSys ).DelScript( script );
#ifdef _RUNSTACKINFO1_
CMessage::AsyWriteFile(GetGame()->GetStatckFileName(), "COpScript::Execute() end");
#endif
}
示例6: GetParameterXML
void NewtonProblem::SetParameters(OptimizeClass* objfcn)
{
Problem::SetParameters(objfcn);
DOMElement* searchXML = GetParameterXML();
VariableList* variables = GetVariables();
string gradMult, searchSize, maxBack;
OptNewtonLike * objfcnNewt = (OptNewtonLike *) objfcn;
if(searchType_ == trustPDS)
{
objfcnNewt->setSearchStrategy(TrustPDS);
gradMult =
XMLString::transcode(searchXML->getAttribute(XMLString::transcode("gradMult")));
if (gradMult != "")
objfcnNewt->setGradMult(atof(gradMult.c_str()));
searchSize =
XMLString::transcode(searchXML->getAttribute(XMLString::transcode("searchSize")));
if (searchSize != "")
objfcnNewt->setSearchSize(atoi(searchSize.c_str()));
}
else if (searchType_ == lineSearch)
{
objfcnNewt->setSearchStrategy(LineSearch);
maxBack =
XMLString::transcode(searchXML->getAttribute(XMLString::transcode("maxBTIter")));
if (maxBack != "")
objfcnNewt->setMaxBacktrackIter(atoi(maxBack.c_str()));
}
else if (searchType_ == trustRegion)
{
if ((variables->upperExists()) || (variables->lowerExists()))
{
cout << "Newton with Trust Region does not support bounds." << endl;
cout << "Using Line Search instead." << endl;
objfcnNewt->setSearchStrategy(LineSearch);
}
else
{
objfcnNewt->setSearchStrategy(TrustRegion);
gradMult =
XMLString::transcode(searchXML->getAttribute(XMLString::transcode("gradMult")));
if (gradMult != "")
objfcnNewt->setGradMult(atof(gradMult.c_str()));
}
}
else
{
cerr << "Unrecognized search strategy type" << endl;
exit(1);
}
}
示例7: calculateSignature
std::string NFunctionSignature::calculateSignature(const NType& returnType, const VariableList& arguments)
{
std::string name = "fp-(";
name += returnType.name + "-";
for (VariableList::const_iterator i = arguments.begin(); i != arguments.end(); i++)
name += (*i)->type.name + ",";
name += ")";
return name;
}
示例8: SetVar
///
/// 设置指定列表里某个变量的值
///
/// ret = SetVar( operType, "$varName", val, pos )
/// @param operType:VT_SCRIPT, VT_SRCSHAPE, VT_DESTSHAPE, VT_GLOBAL
/// @param varName 变量名
/// @param val 变量值
/// @param pos [可选]数组索引
///
static int SetVar( lua_State *L )
{
Script *script = GetInst( ScriptSys ).GetScript( L );
long operType = (long) tolua_tonumber( L, 1, 0 );
VariableList *varList = ( script != NULL ? script->GetVarList( operType ) : NULL );
bool ret = false;
if( varList != NULL )
{
ret = true;
long index = (long) tolua_tonumber( L, 4, 0 );
const char *varName = TOLUA_TOSTRING( varName, L, 2, "" );
long varType = VarList::VarType( varName );
if( varType == VariableList::VAR_NUM )
{
VariableList::Number val = (VariableList::Number) tolua_tonumber( L, 3, 0 );
varList->SetVarValue( varName, val, index );
if( operType == Script::VT_GLOBAL )
{
ScriptUtils::UpdateValToWS( varName, val, index );
}
}
else if( varType == VariableList::VAR_STRING )
{
const char *val = TOLUA_TOSTRING( val, L, 3, "" );
varList->SetVarValue( varName, tString( val ), index );
if( operType == Script::VT_GLOBAL )
{
ScriptUtils::UpdateValToWS( varName, tString( val ), index );
}
}
else if( varType == VariableList::VAR_GUID )
{
const CGUID *val = TOLUA_TOGUID( val, L, 3, &NULL_GUID );
varList->SetVarValue( varName, *val, index );
if( operType == Script::VT_GLOBAL )
{
ScriptUtils::UpdateValToWS( varName, *val, index );
}
}
else
{
// argument error
ret = false;
}
}
else
{
// pop the arguments.
int top = lua_gettop( L );
lua_settop( L, top - 3 );
}
lua_pushboolean( L, ret ? 1 : 0 );
return 1;
}
示例9: locker
uint32_t
ModuleList::FindGlobalVariables (const ConstString &name,
bool append,
uint32_t max_matches,
VariableList& variable_list)
{
size_t initial_size = variable_list.GetSize();
Mutex::Locker locker(m_modules_mutex);
collection::iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
(*pos)->FindGlobalVariables (name, NULL, append, max_matches, variable_list);
}
return variable_list.GetSize() - initial_size;
}
示例10: locker
size_t
ModuleList::FindGlobalVariables (const RegularExpression& regex,
bool append,
size_t max_matches,
VariableList& variable_list) const
{
size_t initial_size = variable_list.GetSize();
Mutex::Locker locker(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
(*pos)->FindGlobalVariables (regex, append, max_matches, variable_list);
}
return variable_list.GetSize() - initial_size;
}
示例11: guard
size_t
ModuleList::FindGlobalVariables (const ConstString &name,
bool append,
size_t max_matches,
VariableList& variable_list) const
{
size_t initial_size = variable_list.GetSize();
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
(*pos)->FindGlobalVariables(name, nullptr, append, max_matches, variable_list);
}
return variable_list.GetSize() - initial_size;
}
示例12: FindGlobalVariables
uint32_t SymbolFile::FindGlobalVariables(
const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches, VariableList &variables) {
if (!append)
variables.Clear();
return 0;
}
示例13: RemoveVar
///
/// 移除指定列表里的某个脚本变量
///
/// RemoveVar( operType, "$varName" )
/// @param operType:VT_SCRIPT, VT_SRCSHAPE, VT_DESTSHAPE
/// @param varName 变量名
///
static int RemoveVar( lua_State *L )
{
Script *script = GetInst( ScriptSys ).GetScript( L );
long operType = (long) tolua_tonumber( L, 1, 0 );
VariableList *varList = ( script != NULL ? script->GetVarList( operType ) : NULL );
if( operType == Script::VT_GLOBAL )
{
// not support global variable list
varList = NULL;
}
const char *varName = TOLUA_TOSTRING( varName, L, 2, "" );
if( varList != NULL )
{
varList->RemoveVar( varName );
}
return 0;
}
示例14: abstract_rates
void Location::abstract_rates(const VariableList &cvl,
const Valuations &dvl,
vector<int> &v_rates) const
{
int pos = 0;
for ( auto it = cvl.begin(); it != cvl.end(); it++, pos++) {
auto x = *it;
for ( auto iit = rates.begin(); iit != rates.end(); iit++) {
if (x == iit->get_var()) {
int r = iit->eval(dvl);
v_rates[pos] = r;
break;
}
}
}
}
示例15: GetNumVar
OptError NewtonProblem::CreateApplicationOptimizer(OptimizeClass * &objfcn,
NLP0 * &func)
{
OptError error;
int numVar = GetNumVar();
VariableList* variables = GetVariables();
CompoundConstraint* constraints = 0;
AppLauncher * launcher = GetAppLauncher();
USERFCN0APP userFcn = &(launcher->run_app);
INITFCNAPP initFcn = &(launcher->init_app);
if(userFcn == NULL)
{
error.value = -4;
error.msg = "Error loading user function";
return error;
}
else if(initFcn == NULL)
{
error.value = -4;
error.msg = "Error loading init function";
return error;
}
if ((variables->linearExists()) || (variables->nonlinearExists()))
{
cout << "Newton does not support linear or nonlinear constraints." << endl;
cout << "Linear and nonlinear constraints being ignored." << endl;
}
if ((variables->upperExists()) || (variables->lowerExists()))
{
constraints = new CompoundConstraint(Constraint(variables->GetBoundConstraints()));
}
FDNLF1APP * myFunc = new FDNLF1APP(numVar, userFcn, initFcn,
launcher, constraints);
myFunc->setIsExpensive(true);
if(searchType_ == trustPDS)
myFunc->setSpecOption(NoSpec);
func = myFunc;
if ((variables->upperExists()) || (variables->lowerExists()))
{
objfcn = new OptBCQNewton(myFunc);
}
else
{
objfcn = new OptQNewton(myFunc);
}
error.value = 0;
error.msg = "Success";
return error;
}