本文整理汇总了C++中AssociativeContainer::size方法的典型用法代码示例。如果您正苦于以下问题:C++ AssociativeContainer::size方法的具体用法?C++ AssociativeContainer::size怎么用?C++ AssociativeContainer::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssociativeContainer
的用法示例。
在下文中一共展示了AssociativeContainer::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: erase_if_dispatch
void erase_if_dispatch(AssociativeContainer& c, Predicate p,
associative_container_tag, unstable_tag)
{
// This method is really slow, so hopefully we won't have any
// associative containers with unstable iterators!
// Is there a better way to do this?
typename AssociativeContainer::iterator i;
typename AssociativeContainer::size_type n = c.size();
while (n--)
for (i = c.begin(); i != c.end(); ++i)
if (p(*i)) {
c.erase(i);
break;
}
}
示例2: 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);
}
}
}
}
示例3: 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++)
//.........这里部分代码省略.........