本文整理汇总了C++中boost::unordered_set::end方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_set::end方法的具体用法?C++ unordered_set::end怎么用?C++ unordered_set::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::unordered_set
的用法示例。
在下文中一共展示了unordered_set::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:
inline Observer& Observer::operator=(const Observer& o) {
iterator i;
for (i=observables_.begin(); i!=observables_.end(); ++i)
(*i)->unregisterObserver(this);
observables_ = o.observables_;
for (i=observables_.begin(); i!=observables_.end(); ++i)
(*i)->registerObserver(this);
return *this;
}
示例3: registerDeferredObservers
inline void ObservableSettings::registerDeferredObservers(boost::unordered_set<Observer*>& observers) {
if (updatesDeferred())
{
QL_TRACE("adding " << observers.size() << " observers to the deferred list");
deferredObservers_.insert(observers.begin(), observers.end());
}
}
示例4: collect_vnodes
void VNode::collect_vnodes(boost::unordered_set<Node*>& nodes,uint& total)
{
total++;
boost::unordered_set<Node*>::iterator it = nodes.find(this);
if(it==nodes.end())
nodes.insert(this);
}
示例5: double
//calculates average of vectors
boost::unordered_map<string, double> Cluster::_centroid(boost::unordered_set<int>& cluster_list) {
unordered_string_map centroid;
int cluster_size = cluster_list.size();
for (boost::unordered_set<int>::iterator it = cluster_list.begin(); it != cluster_list.end(); ++it) {
//add each element of vector to centroid
for (unordered_string_map::iterator ivec = doc_term_index[ *it ].begin(); ivec != doc_term_index[ *it ].end(); ++ivec) {
//element (term) doesn't exist, we add it to the map
if ( centroid.count ( ivec->first ) == 0) {
//cout << "ivec second: " << ivec->second <<endl;
//cout << "cluster_size: " << cluster_size <<endl;
centroid.insert(unordered_string_map::value_type( ivec->first, double( (double)ivec->second / cluster_size ) ));
}
else {
centroid[ivec->first] += double( ((double)ivec->second / cluster_size) );
}
}
}
return centroid;
}
示例6: TRACE
PNS_NODE::~PNS_NODE()
{
TRACE( 0, "PNS_NODE::delete %p", this );
if( !m_children.empty() )
{
TRACEn( 0, "attempting to free a node that has kids.\n" );
assert( false );
}
#ifdef DEBUG
if( allocNodes.find( this ) == allocNodes.end() )
{
TRACEn( 0, "attempting to free an already-free'd node.\n" );
assert( false );
}
allocNodes.erase( this );
#endif
for( PNS_INDEX::ITEM_SET::iterator i = m_index->begin(); i != m_index->end(); ++i )
{
if( (*i)->BelongsTo( this ) )
delete *i;
}
releaseGarbage();
unlinkParent();
delete m_index;
}
示例7: enableUpdates
inline void ObservableSettings::enableUpdates() {
updatesEnabled_ = true;
updatesDeferred_ = false;
// if there are outstanding deferred updates, do the notification
if (deferredObservers_.size() > 0)
{
bool successful = true;
std::string errMsg;
QL_TRACE("deferred notification of " << deferredObservers_.size() << " observers");
for (iterator i=deferredObservers_.begin(); i!=deferredObservers_.end(); ++i) {
try {
(*i)->update();
} catch (std::exception& e) {
successful = false;
errMsg = e.what();
} catch (...) {
successful = false;
}
}
deferredObservers_.clear();
QL_ENSURE(successful,
"could not notify one or more observers: " << errMsg);
}
}
示例8: serialize
static void serialize(storage_type& s, const boost::unordered_set<T>& o)
{
uint32_t sz = o.size();
s.serialize(sz);
for (auto it = o.begin(), it_end = o.end(); it != it_end; ++it)
s.serialize(*it);
}
示例9: dfs
void cluster_machine::dfs(const size_t curr, boost::unordered_set<size_t> &vis)
{
vis.insert(curr);
for (size_t e = first_[curr]; e != -1; e = next_[e]) {
if ( vis.find(v_[e]) == vis.end() )
dfs(v_[e], vis);
}
}
示例10: make_pair
inline std::pair<boost::unordered_set<boost::shared_ptr<Observable> >::iterator, bool>
Observer::registerWith(const boost::shared_ptr<Observable>& h) {
if (h) {
h->registerObserver(this);
return observables_.insert(h);
}
return std::make_pair(observables_.end(), false);
}
示例11: get_live_object_names
Strings get_live_object_names() {
IMP::Vector<std::string> ret;
for (boost::unordered_set<Object*>::const_iterator it = live_.begin();
it != live_.end(); ++it) {
ret.push_back((*it)->get_name());
}
return ret;
}
示例12: check_live_objects
IMPKERNEL_END_NAMESPACE
IMPKERNEL_BEGIN_INTERNAL_NAMESPACE
void check_live_objects() {
for (boost::unordered_set<Object*>::const_iterator it = live_.begin();
it != live_.end(); ++it) {
IMP_USAGE_CHECK((*it)->get_ref_count() > 0,
"Object " << (*it)->get_name() << " is not ref counted.");
}
}
示例13: update
void update(const key_type& inKey, const boost::unordered_set<value_type>& inValues)
{
{
boost::unordered_set<value_type> curValues(getValues(inKey));
for (auto it = curValues.begin(); it != curValues.end(); ++it)
if (inValues.find(*it) == inValues.end())
drop(inKey, *it);
}
insert(inKey, inValues);
}
示例14: check_live_objects
IMPKERNEL_END_NAMESPACE
IMPKERNEL_BEGIN_INTERNAL_NAMESPACE
void check_live_objects() {
for (boost::unordered_set<Object*>::const_iterator it = live_.begin();
it != live_.end(); ++it) {
IMP_USAGE_CHECK((*it)->get_ref_count() > 0,
"Object " << (*it)->get_name()
<< " is alive but not ref counted - memory leakage possible."
<< " This usually happens if an owning pointer is released"
<< " without being either deleted manually or assigned to"
<< " another owning pointer.");
}
}
示例15: save
void save(Archive & ar, const boost::unordered_set<T> & t, unsigned int version)
{
// write the size
// TODO: should we handle bucket size as well?
typedef typename boost::unordered_set<T>::size_type size_type;
typedef typename boost::unordered_set<T>::const_iterator const_iterator;
size_type size = t.size();
ar & BOOST_SERIALIZATION_NVP(size);
unsigned int count = 0;
for (const_iterator it = t.begin(); it != t.end(); it++) {
ar & boost::serialization::make_nvp("item" + count, *it);
count++;
}
}