本文整理汇总了C++中map_type::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ map_type::begin方法的具体用法?C++ map_type::begin怎么用?C++ map_type::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map_type
的用法示例。
在下文中一共展示了map_type::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compare
static bool compare(map_type const & MA, map_type const & MB)
{
std::vector < std::pair<std::string,std::string> > SA, SB;
for ( typename map_type::const_iterator ita = MA.begin(); ita != MA.end(); ++ita )
SA.push_back(std::pair<std::string,std::string>(ita->first,ita->second));
for ( typename map_type::const_iterator ita = MB.begin(); ita != MB.end(); ++ita )
SB.push_back(std::pair<std::string,std::string>(ita->first,ita->second));
std::sort(SA.begin(),SA.end());
std::sort(SB.begin(),SB.end());
uint64_t ia = 0, ib = 0;
for ( ; ia != SA.size() && ib != SB.size() ; ++ia, ++ib )
if ( SA[ia] != SB[ib] )
{
#if 0
std::cerr << printPair(SA[ia]) << " != " << printPair(SB[ib]) << std::endl;
for ( uint64_t i = 0; i < SA.size(); ++i )
std::cerr << SA[i].first << ";";
std::cerr << MA.size();
std::cerr << std::endl;
for ( uint64_t i = 0; i < SB.size(); ++i )
std::cerr << SB[i].first << ";";
std::cerr << MB.size();
std::cerr << std::endl;
#endif
return SA[ia] < SB[ib];
}
return ia < ib;
}
示例2: main
int main(int argc, const char** argv)
{
std::string text;
for(int i = 1; i < argc; ++i)
{
cout << "Processing file " << argv[i] << endl;
std::ifstream fs(argv[i]);
load_file(text, fs);
fs.close();
// construct our iterators:
boost::sregex_iterator m1(text.begin(), text.end(), expression);
boost::sregex_iterator m2;
std::for_each(m1, m2, ®ex_callback);
// copy results:
cout << class_index.size() << " matches found" << endl;
map_type::iterator c, d;
c = class_index.begin();
d = class_index.end();
while(c != d)
{
cout << "class \"" << (*c).first << "\" found at index: " << (*c).second << endl;
++c;
}
class_index.erase(class_index.begin(), class_index.end());
}
return 0;
}
示例3: sum
/** Compute the sum of all the elements
* Implements compensated summation
*/
double sum() {
double s=0.;
for (map_type::iterator it=map.begin(),itend=map.end();it!=itend;++it) {
s += it->second;
}
return s;
}
示例4: clause
//! conversion to clause
clause_type clause() const {
clause_type C;
const iterator pa_end = pa.end();
for (iterator i = pa.begin(); i != pa_end; ++i)
C.ls.insert(literal_type(i->first, i->second));
return C;
}
示例5: max_index
/** Compute the max of the element values
* This operation returns the first element if the vector is empty.
*/
mwIndex max_index() {
mwIndex index=0;
double maxval=std::numeric_limits<double>::min();
for (map_type::iterator it=map.begin(),itend=map.end();it!=itend;++it) {
if (it->second>maxval) { maxval = it->second; index = it->first; }
}
return index;
}
示例6: flush
void flush(){
enterExclusive();
map_type::iterator iter = _item_map.begin();
for(; iter != _item_map.end(); ++iter){
iter->second->flush();
}
leaveExclusive();
}
示例7: print
void print() const{
enterExclusive();
map_type::const_iterator iter = _item_map.begin();
for(; iter != _item_map.end(); ++iter){
iter->second->print();
}
leaveExclusive();
}
示例8:
void
mapper::_free_map(map_type &m) {
map_type::iterator i = m.begin();
for (; i != m.end(); i++) {
if (i->first) free((void *)i->first);
if (i->second) free((void *)i->second);
}
m.clear();
}
示例9: find_unreachable_objects_impl
static void find_unreachable_objects_impl(map_type const & m, map2_type & m2)
{
// scan objects for shared_ptr members, compute internal counts
{
std::cout << "... " << m.size() << " objects in m.\n";
for(map_type::const_iterator i = m.begin(); i != m.end(); ++i)
{
abt_boost::detail::sp_counted_base const * p = static_cast<abt_boost::detail::sp_counted_base const *>(i->first);
BOOST_ASSERT(p->use_count() != 0); // there should be no inactive counts in the map
m2[ i->first ];
scan_and_count(i->second.first, i->second.second, m, m2);
}
std::cout << "... " << m2.size() << " objects in m2.\n";
}
// mark reachable objects
{
open_type open;
for(map2_type::iterator i = m2.begin(); i != m2.end(); ++i)
{
abt_boost::detail::sp_counted_base const * p = static_cast<abt_boost::detail::sp_counted_base const *>(i->first);
if(p->use_count() != i->second) open.push_back(p);
}
std::cout << "... " << open.size() << " objects in open.\n";
for(open_type::iterator j = open.begin(); j != open.end(); ++j)
{
m2.erase(*j);
}
while(!open.empty())
{
void const * p = open.front();
open.pop_front();
map_type::const_iterator i = m.find(p);
BOOST_ASSERT(i != m.end());
scan_and_mark(i->second.first, i->second.second, m2, open);
}
}
// m2 now contains the unreachable objects
}
示例10: main
int main(int argc, const char** argv)
{
std::string text;
for(int i = 1; i < argc; ++i)
{
cout << "Processing file " << argv[i] << endl;
std::ifstream fs(argv[i]);
load_file(text, fs);
fs.close();
IndexClasses(text);
cout << class_index.size() << " matches found" << endl;
map_type::iterator c, d;
c = class_index.begin();
d = class_index.end();
while(c != d)
{
cout << "class \"" << (*c).first << "\" found at index: " << (*c).second << endl;
++c;
}
class_index.erase(class_index.begin(), class_index.end());
}
return 0;
}
示例11: urlEncodeParams
static std::string urlEncodeParams(map_type const ¶ms)
{
std::string result;
typename map_type::const_iterator it;
for(it=params.begin(); it!=params.end(); it++) {
if( result.size() ) {
result += "&";
}
urlEncode(it->first.c_str(),result);
if( !it->second.empty() ) {
result += "=";
urlEncode(it->second.c_str(),result);
}
}
return result;
}
示例12: alphabet_size_and_map
static size_type alphabet_size_and_map(const reference_type rac, size_type n, map_type& map, inv_map_type& inv_map, value_type& first_symbol) {
if (n > 0)
first_symbol = rac[0];
map.clear();
inv_map.clear();
size_type alphabet_size = 0;
for (size_type i=0; i<n; ++i) {
if (map.find(rac[i]) == map.end()) {
map[rac[i]] = 1;
}
}
for (typename map_type::iterator it = map.begin(); it != map.end(); ++it) { // this preserves the order
it->second = alphabet_size;
inv_map[alphabet_size] = it->first;
++alphabet_size;
}
return alphabet_size;
}
示例13: most_common
label_type most_common(const gather_type& total) {
typedef gather_type::map_type map_type;
const map_type m = total.get();
label_type best_label = 0;
size_t best_freq = 0;
for (map_type::const_iterator it = m.begin(); it != m.end(); it++) {
label_type label = it->first;
size_t freq = it->second;
if (freq > best_freq || (freq == best_freq && label < best_label)) {
best_label = label;
best_freq = freq;
}
}
return best_label;
}
示例14: begin
virtual map_type::iterator begin() { return m_map.begin(); }
示例15:
~basic_parameter_map() {
for (typename map_type::iterator it = begin(); it != end(); ++it) {
delete it->second;
}
}