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


C++ AssociativeContainer::begin方法代码示例

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


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

示例1: while

static void construct_adjacency_matrix 
                        (const GraphType& graph,
                         const AssociativeContainer& vertices,
    __gnu_cxx::hash_map<VertexIndexType, VertexIndexType>& label_map,
    __gnu_cxx::hash_map<VertexIndexType, VertexIndexType>& reverse_label_map,
                         std::vector<EdgeWeightType>& adjacency_matrix) {
  typedef typename AssociativeContainer::const_iterator 
                              AssociativeContainerConstIterator;
                                        
  /* resize the adjacency matrix to hold the adjacencies */
  const int num_vertices = vertices.size ();
  adjacency_matrix.resize (num_vertices*num_vertices, 0.0);

  /* Create a map, which remaps the old vertices into new vertices */
  VertexIndexType new_label=0;
  AssociativeContainerConstIterator iter = vertices.begin();
  AssociativeContainerConstIterator end = vertices.end();

  while (iter!=end) {
    const VertexIndexType current_vertex = *iter++;
    label_map [current_vertex] = new_label;
    reverse_label_map [new_label] = current_vertex;
    ++new_label;
  }
  assert (new_label==num_vertices);
  
  /* now do the adjacencies */
  iter = vertices.begin();
  while (iter!=end) {
    const VertexIndexType old_vertex = *iter++;
    const VertexIndexType new_vertex = label_map [old_vertex];
    for (int target_index=graph.begin(old_vertex); 
         target_index<graph.end(old_vertex);
         ++target_index) {
      const VertexIndexType adjacent_vertex=graph.get_target (target_index);

      /* only add the adjacency if the target is one of "vertices". */
      if (vertices.end()!=vertices.find (adjacent_vertex)) {
        const int element_offset = 
          (num_vertices*new_vertex) + label_map [adjacent_vertex];
        adjacency_matrix [element_offset] = graph.get_weight (target_index);
      }
    }
  }
}
开发者ID:pkambadu,项目名称:EffectiveResistance,代码行数:45,代码来源:effective_resistance.cpp

示例2: erase_if_dispatch

 void erase_if_dispatch(AssociativeContainer& c, Predicate p,
                        associative_container_tag, stable_tag)
 {
   typename AssociativeContainer::iterator i, next;
   for (i = next = c.begin(); next != c.end(); i = next) {
     ++next;
     if (p(*i))
       c.erase(i);
   }
 }
开发者ID:2asoft,项目名称:xray-16,代码行数:10,代码来源:container_traits.hpp

示例3: remove_if

void remove_if(AssociativeContainer& C, Predicate p)
{
	typedef typename AssociativeContainer::iterator iterator;

	iterator cur = C.begin();
	const iterator last = C.end();

	while ((cur = std::find_if(cur, last, p)) != last)
	{
		iterator tmp = cur++;
		C.erase(tmp);
	}
}
开发者ID:dhawt,项目名称:Bananna-Slug-Invasion,代码行数:13,代码来源:PreferenceStore.cpp

示例4: writeLatex

void writeLatex(  AssociativeContainer & p, 
                  bool draw_box = true, 
                  bool dumpcout = false,
                  std::ostream & ostr = std::cout)
{   
   typedef typename AssociativeContainer::iterator Iterator;
   Iterator it;

   ostr << std::fixed << std::setprecision(8);

   int sum = 0;
   for(it = p.begin(); it != p.end(); it++)
   {
      sum += it->second;
   }

   // ##########
   // create statistics plot

   
   // a priori computation of the vertical position of the histogram bar names
   //
   long size_entries = p.size();
   size_t key_size_max = 0;
   double text_vertical_position = 0.0;
   double box_vertical_size = 0.0;
   double box_horizontal_size = 0.0;
   
   for(it = p.begin(); it != p.end(); it++)
   {
      // determine the maximal key size of all entries
      if( (it->first).size() > key_size_max )
         key_size_max = (it->first).size();

      // the reference is: for a key of 8 characters, the vspace is 40.0
      // so conclude about the actual size of the key by using this ratio.
      text_vertical_position = key_size_max * 40.0 / 8.0;
      
      // determine the size of the pspicture box. 
      // use some reference ratios to derive a suitable size
      box_vertical_size = text_vertical_position;
      box_horizontal_size = size_entries * 4.0 / 3.0;
   }     

   ostr << std::endl;
   ostr << "%-----------" << std::endl;
   ostr << "%%% PLOT %%%" << std::endl;
   ostr << "%-----------" << std::endl;
   ostr << "\\begin{minipage}[ht]{0.20\\textwidth}" << std::endl;
   if(draw_box)
      ostr << "\\fbox{" << std::endl;
   ostr << "\\setlength{\\unitlength}{1cm}" << std::endl;
   ostr << "\\psset{xunit=0.7cm, yunit=0.03017058cm}" << std::endl;
   ostr << "\\begin{pspicture}(-1.0,-" << box_vertical_size << ")("<< box_horizontal_size <<",130)" << std::endl;
   ostr << "\\psaxes[labels=y,Dx=1,Dy=50.](0,0)(" << size_entries << ",100)" << std::endl;
   ostr << "\\pspolygon[fillcolor=black, fillstyle=solid](-0.08,104.55414013)(0,109.53290870)(0.08,104.55414013)" << std::endl;
   
   int i=0;
   for(it = p.begin(); it != p.end(); it++)
   {
      // detect underscores in the key and prefix them with a '\' 
      // so its latex conform
      std::string key = gsse::check_for_special_characters(it->first);      

      double percentage = ( boost::lexical_cast<double>(it->second) /  boost::lexical_cast<double>(sum))*100.0;

   #ifdef DEBUG
      std::cout << "  key_size" << key_size << std::endl;
      std::cout << "  text_vertical_position: " << text_vertical_position << std::endl;
   #endif         
      ostr.precision(2);
      ostr << "\\psframe[linewidth=1pt, fillcolor=gray, fillstyle=solid] (" << i 
         << ".30000000,0)(" << i << ".70000000," << percentage << ")" << std::endl;
      ostr << "\\rput[bl](" << i++ << ".35000000,-" << text_vertical_position << "){\\rotateleft{\\footnotesize " 
         << key << "}}" << std::endl;
   }

   ostr << "\\end{pspicture}" << std::endl;
   if(draw_box)
      ostr << "}" << std::endl;      
   ostr << "\\end{minipage}" << std::endl;

   ostr << std::endl;

   ostr << "%------------" << std::endl;
   ostr << "%%% TABLE %%%" << std::endl;
   ostr << "%------------" << std::endl;

   // ##########
   // create statistics table
   ostr << "\\begin{minipage}[ht]{0.20\\textwidth}" << std::endl;
   ostr << "\\begin{tabular}{crr}" << std::endl;

   if(dumpcout)
   {
      std::cout << "## mesh classification: " << std::endl;
      std::cout << "---------------------------------------------" << std::endl;
   }

   for(it = p.begin(); it != p.end(); it++)
//.........这里部分代码省略.........
开发者ID:AlexanderToifl,项目名称:viennamesh-dev,代码行数:101,代码来源:latex_histogram.hpp


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