本文整理汇总了C++中CConfig::Copy方法的典型用法代码示例。如果您正苦于以下问题:C++ CConfig::Copy方法的具体用法?C++ CConfig::Copy怎么用?C++ CConfig::Copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CConfig
的用法示例。
在下文中一共展示了CConfig::Copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TryFind
// Search config in the hash table, if it is not there, this config will be
// inserted. If inserted, *pCacheConfig will point to the location.
// return value
// 0 -- not found or can not be pruned
// 1 -- find a config that can be pruned in the cache
int TryFind(CConfig **arr, CConfig *pConfig, CConfig **pCacheConfig)
{
*pCacheConfig = NULL;
//return 0;
int index = pConfig->CalHashValue();
CConfig *p = arr[index];
if (!p) // the config is not found and insert this pConfig to it
{
#ifdef USE_OWN_CACHE
if (usedconfiglength>=MAXUSEDCONFIGSIZE) return 0;
CConfig* pNewConfig = newCacheConfig(pConfig->len);
if (!pNewConfig) return 0; // cache has been used up, just return;
#else
if (usedconfiglength>=MAXUSEDCONFIGSIZE) return 0;
CConfig* pNewConfig = new CConfig(pConfig->len);
assert(pNewConfig);
#endif
usedconfiglength++;
pNewConfig->Copy(pConfig);
arr[index] = pNewConfig;
*pCacheConfig = pNewConfig;
return 0;
}
if (p->ConfigCmp(pConfig)) return 0;
// now the configs are the same
if (p->depth <= pConfig->depth)
{
// if a config hits the hash table with length no less than that in the
// table, it cannot be on the path of any optimal solutions not found
// yet. Remember if an optimal solution is found, all configs along
// the solution path stored in the hash table are released in
// Solution_Found() in solver.cpp
return 1;
}
else
{
p->depth = pConfig->depth;
*pCacheConfig = p;
return 0;
}
}
示例2: SolveConfig
//.........这里部分代码省略.........
//// sort the matched pair array according to its matchret value
for (i=0;i<matchedPairNum-1;i++)
for (j=i+1;j<matchedPairNum;j++)
{
if (arrRetValue[i] > arrRetValue[j])
{
k = arrRetValue[i];
arrRetValue[i] = arrRetValue[j];
arrRetValue[j] = k;
k = arrMatchedPair[i];
arrMatchedPair[i] = arrMatchedPair[j];
arrMatchedPair[j] = k;
}
}
//// try the pair one by one
// count new length for config
newlen = pConfig->len+pPCP->offset+MAXLOOPCOUNT*pPCP->offset;
// create new config
#ifdef USE_CONFIG_POOL
pNewConfig = newConfig(newlen);
#else
pNewConfig = new CConfig(newlen);
#endif
// try all matched pairs
for (i=0;i<matchedPairNum;i++)
{
// the last matched pair and the config can be reused? Jump back!
if (i+1==matchedPairNum && arrRetValue[i]<=maxlen )
{
pConfig->MatchPair(&pPCP->arrPair[arrMatchedPair[i]], arrSelection);
if (pConfig->up)
if (pPCP->upmask) continue;
if (!pConfig->up)
if (pPCP->downmask) continue;
#ifdef USE_CONFIG_POOL
deleteConfig(newlen);
#else
delete pNewConfig;
#endif
succ = TryFind(hashTable, pConfig, &pCacheConfig);
if (succ==1 || succ==2) // this config is in the cache
{
Add_cutoff_node_number();
//if (succ==2) ret = 0;
RETURNANDCLEAR;
}
goto DEEP;
}
// duplicate pConfig to config
pNewConfig->Copy(pConfig);
// match it with the pair
pNewConfig->MatchPair(&pPCP->arrPair[arrMatchedPair[i]], arrSelection);
// test masks
if (pNewConfig->up)
if (pPCP->upmask) continue;
if (!pNewConfig->up)
if (pPCP->downmask) continue;
// check cache
succ = TryFind(hashTable, pNewConfig, &pCacheConfig);
if (succ==1 || succ==2) // this config is in the cache
{
Add_cutoff_node_number();
continue;
}
// recursively call the SolveConfig routine
solveret=SolveConfig(pPCP, pNewConfig, newlen);
// check result
if (solveret>0) // solve it
{
#ifdef USE_CONFIG_POOL
deleteConfig(newlen);
#else
delete pNewConfig;
#endif
return solveret;
}
if (solveret==0) // cannot solve it to the iterative_depth_threshold
ret=0;
}
#ifdef USE_CONFIG_POOL
deleteConfig(newlen);
#else
delete pNewConfig;
#endif
RETURNANDCLEAR;
}