本文整理汇总了C++中boost::unordered_map::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ unordered_map::begin方法的具体用法?C++ unordered_map::begin怎么用?C++ unordered_map::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::unordered_map
的用法示例。
在下文中一共展示了unordered_map::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
static double
score2(const boost::unordered_map<int, double> &m0,
const boost::unordered_map<int, double> &m1)
{
int tmp = 0;
auto i0 = m0.begin();
auto i1 = m1.begin();
while (i0 != m0.end() && i1 != m1.end()) {
if (i0->first < i1->first) ++i0;
else if (i0->first > i1->first) ++i1;
else ++tmp, ++i0, ++i1;
}
return m0.size() + m1.size() - tmp;
}
示例2: slotObjectsSelected
void IfcTreeWidget::slotObjectsSelected( boost::unordered_map<int, shared_ptr<IfcPPEntity> >& map )
{
if( m_block_selection_signals )
{
return;
}
if( map.size() < 1 )
{
return;
}
// take the first object from map and highlight it
shared_ptr<IfcPPEntity> object = (*(map.begin())).second;
int selected_id = object->m_id;
for( int i=0; i<topLevelItemCount(); ++i )
{
QTreeWidgetItem* toplevel_item = topLevelItem( i );
QTreeWidgetItem* selected_item = ViewerUtil::findItemByIfcId( toplevel_item, selected_id );
if( selected_item != 0 )
{
blockSignals(true);
m_block_selection_signals = true;
setCurrentItem( selected_item, 1, QItemSelectionModel::SelectCurrent );
blockSignals(false);
m_block_selection_signals = false;
break;
}
}
}
示例3: set
void IndexingVariables::set(
boost::unordered_map<std::string, boost::shared_ptr<ArrayStorage> > as,
int offset) {
hm.clear();
hm.insert(as.begin(), as.end());
this->offset = offset;
}
示例4: dumpLegendrePolynomialCacheData
//! Dump Legendre polynomial cache data to stream (table and history).
void dumpLegendrePolynomialCacheData( std::ostream& outputStream,
boost::unordered_map< Point, double > cacheTable,
boost::circular_buffer< Point > cacheHistory )
{
outputStream << "Table:\n";
for ( boost::unordered_map< Point, double >::iterator iteratorCacheTable = cacheTable.begin( );
iteratorCacheTable != cacheTable.end( ); iteratorCacheTable++ )
{
outputStream << "\t" << writeLegendrePolynomialStructureToString(
iteratorCacheTable->first ).c_str( ) << " => "
<< iteratorCacheTable->second << std::endl;
}
outputStream << "History:\n";
for ( boost::circular_buffer< Point >::iterator iteratorCacheHistory = cacheHistory.begin( );
iteratorCacheHistory != cacheHistory.end( ); iteratorCacheHistory++ )
{
outputStream << "\t"
<< writeLegendrePolynomialStructureToString( *iteratorCacheHistory ).c_str( )
<< ", ";
}
outputStream << std::endl;
}
示例5:
TKmerMapSimple
kmerify_graph_simple(String<TVertexDescriptor const> const & order,
TGraph const & graph,
std::vector<VertexLabels> & vertex_vector,
boost::unordered_set<TVertexDescriptor> const & free_nodes,
boost::unordered_map< std::pair<TVertexDescriptor, TVertexDescriptor>, boost::dynamic_bitset<> > & edge_ids,
int const & kmer_size
)
{
TKmerMapSimple kmer_map;
for (Iterator<String<TVertexDescriptor const> const>::Type it = begin(order) ; it != end(order) ; ++it)
{
TVertexDescriptor const & source_vertex = *it;
if (free_nodes.count(source_vertex) == 0)
{
boost::dynamic_bitset<> id_bits(edge_ids.begin()->second.size());
id_bits.flip();
check_kmers_simple(vertex_vector[source_vertex].dna, graph, source_vertex, vertex_vector, free_nodes, edge_ids, id_bits, kmer_map, static_cast<std::size_t>(kmer_size));
}
}
return kmer_map;
}
示例6: checkKmers
TKmerMap
kmerifyGraph(String<TVertexDescriptor const> const & order,
TGraph const & graph,
std::vector<VertexLabels> & vertex_vector,
boost::unordered_set<TVertexDescriptor> const & free_nodes,
boost::unordered_map< std::pair<TVertexDescriptor, TVertexDescriptor>, boost::dynamic_bitset<> > & edge_ids,
int const & kmer_size
)
{
TKmerMap kmer_map;
for (Iterator<String<TVertexDescriptor const> const>::Type it = begin(order) ; it != end(order) ; ++it)
{
TVertexDescriptor const & source_vertex = *it;
if (free_nodes.count(source_vertex) == 0)
{
boost::dynamic_bitset<> id_bits(edge_ids.begin()->second.size());
id_bits.flip();
checkKmers(vertex_vector[source_vertex].dna, source_vertex, source_vertex, graph, vertex_vector, free_nodes, edge_ids, id_bits, kmer_map, static_cast<std::size_t>(kmer_size));
// std::cout << "source_vertex = " << source_vertex << " kmer_map.size() = " << kmer_map.size() << " kmer_size = " << kmer_size;
// std::cout << " vertex_vector[source_vertex].level = " << vertex_vector[source_vertex].level << std::endl;
}
}
return kmer_map;
}
示例7: processPickups
void Streamer::processPickups(Player &player, const std::vector<SharedCell> &cells)
{
static boost::unordered_map<int, Item::SharedPickup> discoveredPickups;
for (std::vector<SharedCell>::const_iterator c = cells.begin(); c != cells.end(); ++c)
{
for (boost::unordered_map<int, Item::SharedPickup>::const_iterator p = (*c)->pickups.begin(); p != (*c)->pickups.end(); ++p)
{
boost::unordered_map<int, Item::SharedPickup>::iterator d = discoveredPickups.find(p->first);
if (d == discoveredPickups.end())
{
if (checkPlayer(p->second->players, player.playerID, p->second->interiors, player.interiorID, p->second->worlds, player.worldID))
{
if (boost::geometry::comparable_distance(player.position, p->second->position) <= p->second->streamDistance)
{
boost::unordered_map<int, int>::iterator i = internalPickups.find(p->first);
if (i == internalPickups.end())
{
p->second->worldID = !p->second->worlds.empty() ? player.worldID : -1;
}
discoveredPickups.insert(*p);
}
}
}
}
}
if (processingFinalPlayer)
{
boost::unordered_map<int, int>::iterator i = internalPickups.begin();
while (i != internalPickups.end())
{
boost::unordered_map<int, Item::SharedPickup>::iterator d = discoveredPickups.find(i->first);
if (d == discoveredPickups.end())
{
DestroyPickup(i->second);
i = internalPickups.erase(i);
}
else
{
discoveredPickups.erase(d);
++i;
}
}
for (boost::unordered_map<int, Item::SharedPickup>::iterator d = discoveredPickups.begin(); d != discoveredPickups.end(); ++d)
{
if (internalPickups.size() == visiblePickups)
{
break;
}
int internalID = CreatePickup(d->second->modelID, d->second->type, d->second->position[0], d->second->position[1], d->second->position[2], d->second->worldID);
if (internalID == INVALID_ALTERNATE_ID)
{
break;
}
internalPickups.insert(std::make_pair(d->second->pickupID, internalID));
}
discoveredPickups.clear();
}
}
示例8: gini
///Calculates the Gini impurity of a node. The impurity is defined as
///1-sum_j p(j|t)^2
///i.e the 1 minus the sum of the squared probability of observing class j in node t
double CARTTrainer::gini(boost::unordered_map<std::size_t, std::size_t>& countMatrix, std::size_t n){
double res = 0;
boost::unordered_map<std::size_t, std::size_t>::iterator it;
double denominator = n;
for ( it=countMatrix.begin() ; it != countMatrix.end(); it++ ){
res += sqr(it->second/denominator);
}
return 1-res;
}
示例9: buildNameLookupTable
bool buildNameLookupTable(Kompex::SQLiteStatement * stmt,
boost::unordered_map<std::string,int32_t> &table_names)
{
std::string stmt_insert = "INSERT INTO name_lookup";
stmt_insert += "(name_id,name_lookup) VALUES(@name_id,@name_lookup);";
try {
stmt->BeginTransaction();
stmt->Sql(stmt_insert);
}
catch(Kompex::SQLiteException &exception) {
qDebug() << "ERROR: SQLite exception with insert statement:"
<< QString::fromStdString(exception.GetString());
return false;
}
// keep track of the number of transactions and
// commit after a certain limit
size_t transaction_limit=5000;
size_t transaction_count=0;
// write name lookup info the database
boost::unordered_map<std::string,int32_t>::iterator it;
for(it = table_names.begin(); it != table_names.end(); ++it) {
// prepare sql
try {
//[name_id, name_lookup]
stmt->BindInt(1,it->second);
stmt->BindString(2,it->first);
stmt->Execute();
stmt->Reset();
if(transaction_count > transaction_limit) {
stmt->FreeQuery();
stmt->CommitTransaction();
stmt->BeginTransaction();
stmt->Sql(stmt_insert);
transaction_count=0;
}
transaction_count++;
}
catch(Kompex::SQLiteException &exception) {
qDebug() << "ERROR: SQLite exception writing tile data:"
<< QString::fromStdString(exception.GetString());
qDebug() << "ERROR: name_id:" << it->second;
qDebug() << "ERROR: name_lookup:" << QString::fromStdString(it->first);
return false;
}
}
stmt->FreeQuery();
stmt->CommitTransaction();
return true;
}
示例10: read_db_users
void read_db_users()
{
m_read_db_users_time = srv_time();
if (!m_use_sql)
return;
try
{
Csql_query q(m_database, "select @uid");
if (m_read_users_can_leech)
q += ", can_leech";
if (m_read_users_peers_limit)
q += ", peers_limit";
if (m_read_users_torrent_pass)
q += ", torrent_pass";
q += ", torrent_pass_version";
if (m_read_users_wait_time)
q += ", wait_time";
q += " from @users";
Csql_result result = q.execute();
// m_users.reserve(result.size());
for (auto& i : m_users)
i.second.marked = true;
m_users_torrent_passes.clear();
while (Csql_row row = result.fetch_row())
{
t_user& user = m_users[row[0].i()];
user.marked = false;
int c = 0;
user.uid = row[c++].i();
if (m_read_users_can_leech)
user.can_leech = row[c++].i();
if (m_read_users_peers_limit)
user.peers_limit = row[c++].i();
if (m_read_users_torrent_pass)
{
if (row[c].size() == 32)
m_users_torrent_passes[to_array<char, 32>(row[c])] = &user;
c++;
}
user.torrent_pass_version = row[c++].i();
if (m_read_users_wait_time)
user.wait_time = row[c++].i();
}
for (auto i = m_users.begin(); i != m_users.end(); )
{
if (i->second.marked)
m_users.erase(i++);
else
i++;
}
}
catch (bad_query&)
{
}
}
示例11: serialize
static void serialize(storage_type& s, const boost::unordered_map<T1, T2>& o)
{
uint32_t sz = o.size();
s.serialize(sz);
for (typename boost::unordered_map<T1,T2>::const_iterator it = o.begin(), it_end = o.end(); it != it_end; ++it)
{
s.serialize(it->first);
s.serialize(it->second);
}
}
示例12: gini
///Calculates the Gini impurity of a node. The impurity is defined as
///1-sum_j p(j|t)^2
///i.e the 1 minus the sum of the squared probability of observing class j in node t
double RFTrainer::gini(boost::unordered_map<std::size_t, std::size_t> & countMatrix, std::size_t n){
double res = 0;
boost::unordered_map<std::size_t, std::size_t>::iterator it;
if(n){
n = n*n;
for ( it=countMatrix.begin() ; it != countMatrix.end(); it++ ){
res += sqr(it->second)/(double)n;
}
}
return 1-res;
}
示例13: find_range
int TwoSum::find_range(int lower, int upper) {
int count = 0;
numbers_to_check.resize(upper-lower);
for (int i=lower; i<= upper; i++ ) {
numbers_to_check.push_back(i);
};
for( auto it = numbers.begin(); it != numbers.end(); ++it ) {
if( find_sum(it->first) ) {
++count;
};
};
return count;
};
示例14: hist
RealVector CARTTrainer::hist(boost::unordered_map<std::size_t, std::size_t> countMatrix){
//create a normed histogram
std::size_t totalElements = 0;
RealVector normedHistogram(m_maxLabel+1);
normedHistogram.clear();
boost::unordered_map<std::size_t, std::size_t>::iterator it;
for ( it=countMatrix.begin() ; it != countMatrix.end(); it++ ){
normedHistogram(it->first) = it->second;
totalElements += it->second;
}
normedHistogram /= totalElements;
return normedHistogram;
}
示例15: drawKeypoints
void Task::drawKeypoints(const base::samples::frame::Frame &frame2,
const std::vector<cv::KeyPoint> &keypoints1,
const std::vector<cv::KeyPoint> &keypoints2,
const std::vector<cv::DMatch> &matches,
const boost::unordered_map<boost::uuids::uuid, StereoFeature> &hash)
{
/** Convert Images to opencv **/
cv::Mat img2 = frameHelperLeft.convertToCvMat(frame2);
::cv::Mat img_out(img2);
cv::drawKeypoints (img2, keypoints1, img_out, cv::Scalar(0, 255, 0));//green previous
for (std::vector<cv::DMatch>::const_iterator it= matches.begin(); it!= matches.end(); ++it)
{
cv::Point point1 = keypoints1[it->queryIdx].pt;
cv::Point point2 = keypoints2[it->trainIdx].pt;
//cv::circle(img_out, point1, 3, cv::Scalar(0, 255, 0), 1);// green previous
cv::circle(img_out, point2, 3, cv::Scalar(255, 0, 0), 1);// blue current
cv::line (img_out, point1, point2, cv::Scalar(0, 0, 255)); // red line
}
if (_draw_hash_uuid_features.value())
{
/** Draw hash features **/
for (boost::unordered_map<boost::uuids::uuid, StereoFeature>::const_iterator
it = hash.begin(); it != hash.end(); ++it)
{
/** Only current features but with the hash id and the image frame index in the label **/
if (it->second.img_idx == this->fcurrent_left.img_idx)
{
float red = 255.0 - (255.0/(this->frame_window_hash_size)*(this->ffinal_left.img_idx-it->second.img_idx));
cv::circle(img_out, it->second.keypoint_left.pt, 5, cv::Scalar(0, 0, red), 2);
std::vector<std::string> uuid_tokens = this->split(boost::lexical_cast<std::string>(it->first), '-');
cv::putText(img_out, uuid_tokens[uuid_tokens.size()-1]+"["+boost::lexical_cast<std::string>(it->second.img_idx)+"]",
it->second.keypoint_left.pt, cv::FONT_HERSHEY_COMPLEX_SMALL, 1.0, cv::Scalar(0,0,0), 2.5);
}
}
}
::base::samples::frame::Frame *frame_ptr = this->inter_frame_out.write_access();
frameHelperLeft.copyMatToFrame(img_out, *frame_ptr);
frame_ptr->time = this->frame_pair.time;
this->inter_frame_out.reset(frame_ptr);
_inter_frame_samples_out.write(this->inter_frame_out);
return;
}