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


C++ unordered_set::size方法代码示例

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


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

示例1: 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);
        }
    }
开发者ID:higgscc,项目名称:quantlib,代码行数:28,代码来源:observable.hpp

示例2: sanity_checks

void sanity_checks() {
 ASSERT_TRUE(cm.begin() == cm.end());

  for (size_t i = 0;i < NINS; ++i) {
    um.insert(17 * i);
  }
  
  graphlab::thread_group thrgroup;
  for (size_t i = 0; i < 10; ++i) {
    thrgroup.launch(boost::bind(parallel_inserter, 
                                i * NINS/10, 
                                (i + 1) * NINS / 10));

  }

  thrgroup.join();
   
  std::cout << "Size: " << cm.size() << std::endl;
  std::cout << "Capacity: " << cm.capacity() << std::endl;
  std::cout << "Load Factor: " << cm.load_factor() << std::endl;

  for (size_t i = 0;i < NINS; ++i) {
    if (cm.get_sync(17 * i).first == false) {
      std::cout << cm.count(17 * i) << "\n";
      std::cout << "Failure on: " << 17 * i << std::endl;
      assert(cm.get_sync(17 * i).first == true);
    }
    assert(um.count(17 * i) == 1);
  }
  assert(cm.size() == NINS);
  assert(um.size() == NINS);

  for (size_t i = 0;i < NINS; i+=2) {
    um.erase(17*i);
  }

  for (size_t i = 0; i < 10; ++i) {
    thrgroup.launch(boost::bind(parallel_erase, 
                                i * NINS/10, 
                                (i + 1) * NINS / 10));
  }

  thrgroup.join();
   

  for (size_t i = 0;i < NINS; i+=2) {
    assert(cm.get_sync(17*i).first == (bool)(i % 2));
    assert(um.count(17*i) == i % 2);
  }

  assert(cm.size() == NINS / 2);
  assert(um.size() == NINS / 2);
} 
开发者ID:HanumathRao,项目名称:graphlab,代码行数:53,代码来源:hopscotch_test.cpp

示例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());
	}
    }
开发者ID:higgscc,项目名称:quantlib,代码行数:7,代码来源:observable.hpp

示例4: 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;
}
开发者ID:vergeman,项目名称:DeGustibus,代码行数:27,代码来源:cluster.cpp

示例5: 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);
			}
开发者ID:WantonSoup,项目名称:ufora,代码行数:8,代码来源:BoostContainerSerializers.hpp

示例6: print

void print(const std::string& outputFile, const boost::unordered_set<ZCTA>& zctas, const AdjacencySet& adjacencies) {
	std::ofstream out(outputFile.c_str());
	out << zctas.size() << std::endl;
	for (boost::unordered_set<ZCTA>::const_iterator i = zctas.cbegin(); i != zctas.cend(); ++i)
		out << i->id() << " " << i->interiorPoint().x().get_num() << " "
			<< i->interiorPoint().y().get_num() << std::endl;
	out << adjacencies.size() << std::endl;
	for (AdjacencySet::iterator i = adjacencies.begin(), end = adjacencies.end(); i != end; ++i)
		out << i->first.id() << " " << i->second.id() << std::endl;
}
开发者ID:DrSunglasses,项目名称:zcta,代码行数:10,代码来源:Printer.cpp

示例7: notifyObservers

    inline void Observable::notifyObservers() {
    	// check whether the notifications should be triggered
    	if (!settings_.updatesEnabled())
    	{
    	    // if updates are only deferred, flag this for later notification
    	    // these are held centrally by the settings singleton
            if (settings_.updatesDeferred())
    		settings_.registerDeferredObservers(observers_);

    	    return;
    	}

        if (observers_.size() > 0)
        {
            bool successful = true;
            std::string errMsg;

            QL_TRACE("direct notification of " << observers_.size() << " observers");
            for (iterator i=observers_.begin(); i!=observers_.end(); ++i) {
                try {
                   (*i)->update();
                } catch (std::exception& e) {
                    // quite a dilemma. If we don't catch the exception,
                    // other observers will not receive the notification
                    // and might be left in an incorrect state. If we do
                    // catch it and continue the loop (as we do here) we
                    // lose the exception. The least evil might be to try
                    // and notify all observers, while raising an
                    // exception if something bad happened.
                    successful = false;
                    errMsg = e.what();
                } catch (...) {
                    successful = false;
                }
            }
            QL_ENSURE(successful,
                  "could not notify one or more observers: " << errMsg);
        }
    }
开发者ID:higgscc,项目名称:quantlib,代码行数:39,代码来源:observable.hpp

示例8: 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++;
    }
}
开发者ID:selmanj,项目名称:repel,代码行数:14,代码来源:boost_serialize_unordered_set.hpp

示例9: exec

 static void exec(OutArcType& oarc, const boost::unordered_set<T>& vec){
   serialize_iterator(oarc,
                      vec.begin(), vec.end(), vec.size());
 }
开发者ID:vovoma,项目名称:GraphLab-Create-SDK,代码行数:4,代码来源:unordered_set.hpp

示例10: get_count

 int get_count() const { return seen_.size(); }
开发者ID:AljGaber,项目名称:imp,代码行数:1,代码来源:test_grid_apply.cpp


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