本文整理汇总了C++中boost::unordered_set::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_set::empty方法的具体用法?C++ unordered_set::empty怎么用?C++ unordered_set::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::unordered_set
的用法示例。
在下文中一共展示了unordered_set::empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: distanceToCluster
float KernelKmeansClusterer::distanceToCluster(int sampleId,
const boost::unordered_set<int>& clusterIdSet) {
if (clusterIdSet.empty()) {
return FLT_MAX;
}
// the sum of weight of the cluster
float weightSum = 0.0f;
// the sum of kernels from the sample to all samples in the cluster, multiplied by the weight
float kernelSum = 0.0f;
// the sum of kernels from each pair of samples in the cluster, multiplied by weights
float kernelPairSum = 0.0f;
for (boost::unordered_set<int>::const_iterator iter = clusterIdSet.begin();
iter != clusterIdSet.end(); ++iter) {
float weight = mWeightArray[*iter];
weightSum += weight;
float kernelResult = (*mpKernel)(sampleId, *iter);
kernelSum += weight * kernelResult;
for (boost::unordered_set<int>::const_iterator _iter =
clusterIdSet.begin(); _iter != clusterIdSet.end(); ++_iter) {
float _kernelResult = (*mpKernel)(*iter, *_iter);
kernelPairSum += weight * mWeightArray[*_iter] * _kernelResult;
}
}
float kernelSelf = (*mpKernel)(sampleId, sampleId);
if (weightSum == 0.0f) {
return FLT_MAX;
}
return kernelSelf - 2 * kernelSum / weightSum
+ kernelPairSum / (weightSum * weightSum);
}
示例2: collectShortcuts
static bool collectShortcuts(const std::string & str, StringVector & vs)
{
static boost::unordered_set<std::string> commonFilters;
if(commonFilters.empty()) {
#if RULE_KEY_HASH_LENGTH==7 // 7
commonFilters.insert("http://");
commonFilters.insert("ttp://w");
commonFilters.insert("tp://ww");
commonFilters.insert("p://www");
commonFilters.insert("://www.");
#elif RULE_KEY_HASH_LENGTH==8 // 8
commonFilters.insert("http://w");
commonFilters.insert("ttp://ww");
commonFilters.insert("tp://www");
commonFilters.insert("p://www.");
#elif RULE_KEY_HASH_LENGTH==9 // 9
commonFilters.insert("http://ww");
commonFilters.insert("ttp://www");
commonFilters.insert("tp://www.");
#endif
}
int i = 0;
bool isFindShoutcut = false;
while (i < abpmin(str.length() - RULE_KEY_HASH_LENGTH,80))
{
unsigned int j = i;
for (; j < str.length(); j++) {
if ((str[j] == '*' || str[j] == '^'))
{
break;
}
}
for (unsigned int k = i; j - k >= RULE_KEY_HASH_LENGTH; k++)
{
std::string key = str.substr(k, RULE_KEY_HASH_LENGTH);
if(commonFilters.find(key)!=commonFilters.end())
continue;
isFindShoutcut = true;
vs.push_back(key); //append(key);
}
i = j + 1;
}
return isFindShoutcut;
}