本文整理汇总了C++中map_t::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ map_t::begin方法的具体用法?C++ map_t::begin怎么用?C++ map_t::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map_t
的用法示例。
在下文中一共展示了map_t::begin方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: glClear
void ModuleOpenGL::display(map_t const & map)
{
uint x;
uint y = 0;
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, this->width, this->height);
xglBegin(GL_QUADS);
glColor3ub(51, 51, 51);
glVertex2d(-1,-1);
glVertex2d(-1,1);
glColor3ub(30, 30, 30);
glVertex2d(1,1);
glVertex2d(1,-1);
xglEnd();
for (std::vector<std::vector<slot_t> >::const_iterator it_y = map.begin(); it_y != map.end(); ++it_y)
{
x = 0;
for (std::vector<slot_t>::const_iterator it_x = (*it_y).begin(); it_x != (*it_y).end(); ++it_x)
{
display_slot(x, y, (*it_x));
++x;
}
++y;
}
xglFlush();
SDL_GL_SwapBuffers();
}
示例2:
~constants()
{
#ifndef NDEBUG
for( map_t::const_iterator it = map.begin(); it != map.end(); ++it )
if( !used[ it->first ].as<bool>() )
fprintf( stdout, ( moon9::iostring() << "<moon9/play/constants.hpp> says: warning, unused constant '" << it->first << "'" << std::endl ).c_str() );
#endif
}
示例3: debug
std::string debug( const moon9::iostring &head = moon9::iostring(), const moon9::iostring &format12 = "\t\1=\2\n", const moon9::iostring &footer = moon9::iostring() ) //const
{
moon9::iostring body;
for( map_t::const_iterator it = map.begin(); it != map.end(); ++it )
body << moon9::iostring( format12, it->first, it->second );
return head + body + footer;
}
示例4: set_fields
void set_fields(doid_t do_id, const map_t &fields)
{
m_log->trace() << "Setting fields on obj-" << do_id << endl;
YAML::Node document;
if(!load(do_id, document))
{
return;
}
// Get the fields from the file that are not being updated
const Class* dcc = g_dcf->get_class_by_name(document["class"].as<string>());
ObjectData dbo(dcc->get_id());
YAML::Node existing = document["fields"];
for(auto it = existing.begin(); it != existing.end(); ++it)
{
const Field* field = dcc->get_field_by_name(it->first.as<string>());
if(!field)
{
m_log->warning() << "Field '" << it->first.as<string>()
<< "', loaded from '" << filename(do_id)
<< "', does not exist." << endl;
continue;
}
auto found = fields.find(field);
if(found == fields.end())
{
vector<uint8_t> value = read_yaml_field(field, it->second, do_id);
if(value.size() > 0)
{
dbo.fields[field] = value;
}
}
}
// Add in the fields that are being updated:
for(auto it = fields.begin(); it != fields.end(); ++it)
{
dbo.fields[it->first] = it->second;
}
write_yaml_object(do_id, dcc, dbo);
}
示例5: write
void write()
{
static comma::csv::output_stream< interval_t< From, To > > ostream( std::cout, ocsv );
static comma::csv::ascii< from_t< std::string > > from_ascii( ascii_csv );
static comma::csv::ascii< to_t< std::string > > to_ascii( ascii_csv );
for( typename map_t::iterator it = map.begin(); it != map.end(); ++it )
{
bound_t< bound_type > from = it->first.lower();
bound_t< bound_type > to = it->first.upper();
interval_t< From, To > interval;
bool from_has_value = true;
bool to_has_value = true;
if( from.value ) { interval.from.value = *from.value; }
else if( use_limits ) { interval.from.value = limits< From >::lowest(); }
else if( empty ) { interval.from.value = static_cast< From >( *empty ); }
else { from_has_value = false; }
if( to.value ) { interval.to.value = *to.value; }
else if( use_limits ) { interval.to.value = limits< To >::max(); }
else if( empty ) { interval.to.value = static_cast< To >( *empty ); }
else { to_has_value = false; }
const set_t& s = it->second;
if( csv.binary() )
{
if( intervals_only ) { ostream.write( interval ); ostream.flush(); continue; }
for( typename set_t::const_iterator v = s.begin(); v != s.end(); ++v ) { ostream.write( interval, *v ); }
ostream.flush();
}
else
{
for( typename set_t::const_iterator v = s.begin(); v != s.end(); ++v )
{
std::string payload( intervals_only ? "" : *v );
ostream.ascii().ascii().put( interval, payload );
if( !from_has_value ) { from_ascii.put( from_t< std::string >(), payload ); }
if( !to_has_value ) { to_ascii.put( to_t< std::string >(), payload); }
std::cout << payload << std::endl;
if( intervals_only ) { break; }
}
}
}
}
示例6: Exception
void ModuleSDL::display(map_t const & map)
{
uint x, y;
int r;
y = 0;
r = SDL_FillRect(this->s_ecran, NULL, SDL_MapRGB(this->s_ecran->format, 0, 0, 0));
if (r == -1)
throw Exception(SDL_GetError());
for (std::vector<std::vector<slot_t> >::const_iterator it_y = map.begin(); it_y != map.end(); ++it_y)
{
x = 0;
for (std::vector<slot_t>::const_iterator it_x = (*it_y).begin(); it_x != (*it_y).end(); ++it_x)
{
display_slot(x, y, (*it_x));
++x;
}
++y;
}
r = SDL_Flip(this->s_ecran);
if (r == -1)
throw Exception(SDL_GetError());
}
示例7: set_fields_if_equals
bool set_fields_if_equals(doid_t do_id, const map_t &equals, map_t &values)
{
m_log->trace() << "Setting fields if equals on obj-" << do_id << endl;
YAML::Node document;
if(!load(do_id, document))
{
values.clear();
return false;
}
// Get current field values from the file
const Class* dcc = g_dcf->get_class_by_name(document["class"].as<string>());
ObjectData dbo(dcc->get_id());
YAML::Node existing = document["fields"];
for(auto it = existing.begin(); it != existing.end(); ++it)
{
const Field* field = dcc->get_field_by_name(it->first.as<string>());
if(!field)
{
m_log->warning() << "Field '" << it->first.as<string>()
<< "', loaded from '" << filename(do_id)
<< "', does not exist." << endl;
continue;
}
vector<uint8_t> value = read_yaml_field(field, it->second, do_id);
if(value.size() > 0)
{
dbo.fields[field] = value;
}
}
// Check if equals matches current values
bool fail = false;
for(auto it = equals.begin(); it != equals.end(); ++it)
{
auto found = dbo.fields.find(it->first);
if(found == dbo.fields.end())
{
values.erase(it->first);
fail = true;
}
else if(it->second != found->second)
{
values.erase(it->first);
fail = true;
}
}
// Return current values on failure
if(fail)
{
for(auto it = values.begin(); it != values.end(); ++it)
{
it->second = dbo.fields[it->first];
}
return false;
}
// Update existing values on success
for(auto it = values.begin(); it != values.end(); ++it)
{
dbo.fields[it->first] = it->second;
}
write_yaml_object(do_id, dcc, dbo);
return true;
}
示例8: begin
const_iterator begin() const noexcept { return map_index_n.begin(); }
示例9: begin
iterator begin() { return object_map.begin();}
示例10: begin
// begin
typename map_t::const_iterator begin() const {
return map->begin();
}
示例11: write
void write()
{
static comma::csv::output_stream< interval_t< From, To > > ostream( std::cout, ocsv );
static comma::csv::ascii< from_t< std::string > > from_ascii( ascii_csv );
static comma::csv::ascii< to_t< std::string > > to_ascii( ascii_csv );
for( typename map_t::iterator it = map.begin(); it != map.end(); ++it )
{
bound_t< bound_type > from = it->first.lower();
bound_t< bound_type > to = it->first.upper();
interval_t< From, To > interval;
bool from_has_value = true;
bool to_has_value = true;
if( from.value ) { interval.from.value = *from.value; }
else if( use_limits ) { interval.from.value = limits< From >::lowest(); }
else if( empty ) { interval.from.value = static_cast< From >( *empty ); }
else { from_has_value = false; }
if( to.value ) { interval.to.value = *to.value; }
else if( use_limits ) { interval.to.value = limits< To >::max(); }
else if( empty ) { interval.to.value = static_cast< To >( *empty ); }
else { to_has_value = false; }
const set_t& s = it->second;
if( s.size() < min_overlap_count || s.size() > max_overlap_count ) { continue; }
if( append )
{
if( csv.binary() )
{
for( typename set_t::const_iterator v = s.begin(); v != s.end(); ++v )
{
std::cout.write( &( *v )[0], v->size() );
ostream.write( interval );
}
ostream.flush(); // todo: use csv.flush flag
}
else
{
//std::ostringstream oss;
//comma::csv::output_stream< interval_t< From, To > > osstream( oss ); // todo! quick and dirty, watch performance!
if( !from_has_value || !to_has_value ) { std::cerr << "csv-interval: support for empty from/to values for --append: todo" << std::endl; exit( 1 ); }
for( typename set_t::const_iterator v = s.begin(); v != s.end(); ++v )
{
std::cout << *v << csv.delimiter;
ostream.write( interval );
}
}
}
else
{
if( csv.binary() )
{
if( intervals_only ) { ostream.write( interval ); ostream.flush(); continue; }
for( typename set_t::const_iterator v = s.begin(); v != s.end(); ++v ) { ostream.write( interval, *v ); }
ostream.flush();
}
else
{
for( typename set_t::const_iterator v = s.begin(); v != s.end(); ++v )
{
std::string payload( intervals_only ? "" : *v );
ostream.ascii().ascii().put( interval, payload );
if( !from_has_value ) { from_ascii.put( from_t< std::string >(), payload ); }
if( !to_has_value ) { to_ascii.put( to_t< std::string >(), payload); }
std::cout << payload << std::endl;
if( intervals_only ) { break; }
}
}
}
}
}
示例12: begin
map_t::iterator begin() //const
{
return map.begin();
}